From 62e5bce7e8ca888fed8809d76b8049abece2ae7d Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 10 Nov 2026 13:24:10 +0000 Subject: [PATCH] Record a monotone chain for every unequal T1 mask pair. All 2280 six-source characteristic-6 endpoint pairs with different masks of (6,6,6,7,7,7) have an explicit floor word. No kappa change. Co-authored-by: unpaidmoon --- research/c6-t1-unequal-mask-chains/PROOF.md | 169 ++++++++ research/c6-t1-unequal-mask-chains/README.md | 87 ++++ .../c6-t1-unequal-mask-chains/SOURCES.json | 18 + research/c6-t1-unequal-mask-chains/TASK.json | 62 +++ .../c6-t1-unequal-mask-chains/VERIFY.json | 30 ++ research/c6-t1-unequal-mask-chains/verify.py | 383 ++++++++++++++++++ 6 files changed, 749 insertions(+) create mode 100644 research/c6-t1-unequal-mask-chains/PROOF.md create mode 100644 research/c6-t1-unequal-mask-chains/README.md create mode 100644 research/c6-t1-unequal-mask-chains/SOURCES.json create mode 100644 research/c6-t1-unequal-mask-chains/TASK.json create mode 100644 research/c6-t1-unequal-mask-chains/VERIFY.json create mode 100644 research/c6-t1-unequal-mask-chains/verify.py diff --git a/research/c6-t1-unequal-mask-chains/PROOF.md b/research/c6-t1-unequal-mask-chains/PROOF.md new file mode 100644 index 0000000000..2d6e7f4391 --- /dev/null +++ b/research/c6-t1-unequal-mask-chains/PROOF.md @@ -0,0 +1,169 @@ +# Unequal T1 masks are joined by a monotone chain + +No new κ. In the unsigned six-source characteristic-6 floor model, every +legal endpoint pair whose masks differ is realized by a floor word that +keeps the multiset `(6,6,6,7,7,7)` at every diagonal index `s = 4,...,18`. +There are 2280 such pairs. The selected conditional κ stays +`781451/250000000`. + +This is an exhaustive finite census of those pairs, with an explicit word +for each pair. It is not a search that failed, and it is not a statement +about weight-3 shapes outside this multiset. The equal-mask pairs are the +120 words already constructed in PR #7042. They are not recounted here. + +## 1. Hypotheses carried from the endpoint lemmas + +A floor word has length 36 and calls each of six sources exactly six times. +`q_t` is the count of the first `t` letters, and + +```text +S(s) = q_s + q_{39-s}. +``` + +The one-step identity, for `s = 4,...,17`, is + +```text +S(s+1) = S(s) + e_{w_s} - e_{w_{38-s}}. +``` + +PR #7042 proves two facts that this note uses and that `verify.py` rechecks +on their finite domains. + +**Lemma 1.** If `S(18)` is a permutation of `(6,6,6,7,7,7)`, then +`q_18 = (3,3,3,3,3,3)` and the three coordinates equal to 7 are exactly the +three bridge letters in positions 18, 19 and 20. There are 20 such splits. + +**Lemma 2.** If `S(4)` is a permutation of `(6,6,6,7,7,7)`, write +`M_4` for its mask and `D` for the final letter. Either `D` is outside +`M_4` and `q_4` is 1 on `M_4 ∪ {D}`, or `D` is in `M_4` and `q_4` is 2 at +`D` and 1 on the rest of `M_4`. There are 60 pairs of each type, and every +pair `(M_4, D)` occurs once. + +The recheck visits every row assignment in the four-row table of Lemma 1 +and every vector of sum 4 in `{0,...,6}^6` against every final letter. The +counts are 20 and 120, with no extra shape. + +## 2. Budgets + +Fix masks `M_4` and `M_18` and a final letter `D`. Let `p = q_4` be the +vector in Lemma 2, let `b` be the indicator of `M_18`, and let `d` be the +indicator of `D`. The letters still to place are 14 early letters, in +positions 4 through 17, and 14 late letters, in positions 21 through 34. +Their per-source budgets are + +```text +e = (3,3,3,3,3,3) - p, +l = (3,3,3,3,3,3) - d - b. +``` + +Every coordinate of `p` is 0, 1 or 2, so `e` is positive. Every coordinate +of `d` and of `b` is 0 or 1, so `l` is positive: the smallest entry is 1, +when `D` lies in `M_18`. The sums are `∑ p = 4`, `∑ b = 3` and `∑ d = 1`, +hence `∑ e = ∑ l = 14`. These formulas are checked on every orbit +representative. + +A chain step consumes one early letter `a` and one late letter `b`. + +- If `a = b`, the mask is unchanged. +- If `a ≠ b`, the step is legal only when `a` is currently a 6 and `b` is + currently a 7. The mask then loses `b` and gains `a`. + +Either step preserves the multiset `(6,6,6,7,7,7)`. After 14 steps the +budgets are exhausted. + +## 3. From a path to a word + +Given such a path `(a_t, b_t)` for `t = 0,...,13`, build + +```text +prefix + (a_0,...,a_13) + sorted(M_18) + (b_13,...,b_0) + (D). +``` + +The prefix is the increasing list `M_4 ∪ {D}` when `D` is outside `M_4`, +and `(D, D, u, v)` with `u < v` the other two mask sources when `D` is in +`M_4`. Position `4+t` holds `a_t` and position `34-t` holds `b_t`. The +bridge is positions 18, 19 and 20. It lies in every late prefix used by +`s = 4,...,17`, so it cancels in the one-step difference. It contributes +to `S(18)` exactly once. + +The call count of source `j` is `p_j + e_j + b_j + l_j + d_j = 6`. The +length is `4 + 14 + 3 + 14 + 1 = 36`. Starting from the Lemma-2 vector +`S(4)`, the path rule keeps the multiset through `s = 18`, and the final +mask is `M_18` because the bridge indicator is `b` and `q_18 = p + e` is +identically 3. The program checks `q_18`, both endpoint masks, and the +multiset at every `s = 4,...,18`, rather than trusting this paragraph alone. + +## 4. The ten orbits + +Two unequal triples `(M_4, D, M_18)` and `(M_4', D', M_18')` lie in one +orbit of the symmetric group on the six sources when they have the same +intersection size and `D` lies in the same combination of the two masks. +The sources then split into four regions whose sizes depend only on that +intersection size `k`: + +| region | size | +|---|---:| +| `M_4 ∩ M_18` | `k` | +| `M_4 \ M_18` | `3-k` | +| `M_18 \ M_4` | `3-k` | +| neither | `k` | + +For `k = 0` the regions `both` and `neither` are empty, so `D` lies in +exactly one mask. The other two intersection sizes admit all four +membership patterns. That is ten nonempty classes. Their sizes, from +listing every pair, are + +| intersection | `D` in `M_4` | `D` in `M_18` | pairs | +|---:|---|---|---:| +| 0 | no | yes | 60 | +| 0 | yes | no | 60 | +| 1 | no | no | 180 | +| 1 | no | yes | 360 | +| 1 | yes | no | 360 | +| 1 | yes | yes | 180 | +| 2 | no | no | 360 | +| 2 | no | yes | 180 | +| 2 | yes | no | 180 | +| 2 | yes | yes | 360 | + +The total is 2280. Equal masks are excluded: there are `20 · 6 = 120` of +them, already realized by pure slides. + +A permutation that matches the four regions, and sends `D` to `D'`, sends +a realizing word to a realizing word. Masks and the final letter move with +the sources, and the multiset of values of `S(s)` does not change. The +program builds one such permutation for every pair in an orbit and checks +the image word. + +## 5. The census + +For each of the ten orbits the program searches the budget graph from the +Lemma-2 mask, with the budgets of Section 2. The state is the remaining +early budget, the remaining late budget, and the current mask. Each +coordinate is at most 3, and the mask has three members. Breadth-first +search returns a path of length 14 in every orbit. The assembled +representative keeps the multiset, has `q_18` identically 3, and has the +requested endpoint masks. Transporting that word along the region +bijection succeeds for all 2280 pairs. + +The recorded moving word of PR #7042, + +```text +012340011223344555014555443322110023 +``` + +is one pair in the intersection-2 class with `D` in neither mask. It is +checked directly. Swapping its first two early letters leaves the +multiset. That is a failure control, not a second census. + +No orbit is reported empty. An empty search is not used as a nonexistence +proof, because none occurred. The statement is existence for every pair in +a finite, fully listed domain. + +## 6. What this does not say + +The alphabet is unchanged. No signed bill is computed, and the selected +frontier is not changed. Lemma 1 still forces `q_18` to be identically 3, +so these words remain outside the `(0, 9)` shape that PR #7029 called +(H1). The other five separation-3 families are not searched. A word that +keeps this multiset is not a classification of every weight-3 diagonal. diff --git a/research/c6-t1-unequal-mask-chains/README.md b/research/c6-t1-unequal-mask-chains/README.md new file mode 100644 index 0000000000..11b9b9c935 --- /dev/null +++ b/research/c6-t1-unequal-mask-chains/README.md @@ -0,0 +1,87 @@ +# Every unequal T1 mask pair has a monotone chain + +**Exhaustive finite census, with an explicit word for every pair. No new κ.** +In the unsigned six-source characteristic-6 floor model, all 2280 endpoint +pairs whose masks differ are realized by a floor word that keeps the +multiset `(6,6,6,7,7,7)` at every index `s = 4,...,18`. The equal-mask +pairs are the 120 pure slides of PR #7042 and are not rebuilt as the new +claim. The selected conditional κ remains `781451/250000000`. + +The argument and the orbit table are in [PROOF.md](PROOF.md). + +## Scope and evidence + +Original card: `connector-alphabet-change`. The card asks whether one new +connector operation has a favorable budget. Scope status: **changed**. The +alphabet stays the unsigned dirty connector. The assigned question is open +question 1 of PR #7042: which unequal endpoint masks are joined by a +monotone chain of this multiset. + +The predecessor already showed that every equal-mask pair works and that +one unequal pair works. The missing statement was the boundary of that +transport. This package lists every unequal pair, splits them into the ten +orbits of the symmetric group on the six sources, finds one 14-step path +in each orbit, and checks the transported word on all 2280 pairs. + +Evidence class: **exhaustive finite census**. The domain is the finite set +of triples `(M_4, D, M_18)` with `M_4 ≠ M_18`. The enumeration is every +3-subset pair and every final letter. Each word is checked against the +diagonal multiset at all fifteen indices. A failed search is not used; every +orbit returned a witness. This is not a proof about shapes other than +`(6,6,6,7,7,7)`, and it is not unrestricted nonexistence or existence +outside this model. + +`current-priorities.md` on this base still prints the older decimal from +#5599. The verifier reads `certificates/selected-result.json` and does not +edit it. + +## Reproduce + +Python 3.12, standard library only, from the repository root: + +```sh +python3 -B research/c6-t1-unequal-mask-chains/verify.py +python3 -O -B research/c6-t1-unequal-mask-chains/verify.py +python3 -B scripts/research_package.py --package research/c6-t1-unequal-mask-chains +``` + +The marker is + +```text +PASS_C6_T1_UNEQUAL_MASK_CHAINS pairs=2280 orbits=10 witnesses=10 checked=2280 controls=7 +``` + +The controls recheck the two endpoint domains (20 splits at `s = 18`, 120 +splits at `s = 4`), the recorded moving word, a swapped-letter failure, the +ten orbit sizes, and the selected κ string. Checks raise `SystemExit`, so +`-O` does not strip them. + +Not run: a proof assistant, a SAT solver, a supplier or native replay, and +`scripts/research_selected_baseline.py`. The selected record is provenance +and the κ guard only. + +## Open next questions + +- For one separation-3 family other than type T1, which unequal endpoint + masks are joined by a monotone chain of that family's multiset? *Why:* + T1 is the only family with no coordinate 12, and its transport is now + complete. A family that uses a 12 has a different legal step. *First + step:* fix that family's multiset, list its legal exchange, and search + one symmetry class of unequal masks. *Blocked by:* the step rule in this + package exchanges a 6 with a 7 only. It does not apply to a coordinate + 12. + +## Credit + +The depth-two interface is Nick Petalas's (PR #4231, PR #4248, PR #6107), +with the Ross Richardson PR #934/PR #943 lineage. JosieElliston's PR #6141 +records the c=6 solver verdict. PR #6955 classifies the empty centre. +PR #7029 isolates type T1 as the family with no frozen 12. PR #7042, head +`807149a85d185b8272aa1fda43ba6d8d7c541cfe`, constructs the 120 equal-mask +words, one moving word, and the two endpoint lemmas used here. Those lemmas +are rechecked on the same finite domains and are not a new classification. +The upstream finding that records the open question is discussion comment +19514157. + +Prepared by unpaidmoon with substantial Cursor Grok assistance. Independent +human review and a proof-assistant proof are unclaimed. Apache-2.0. diff --git a/research/c6-t1-unequal-mask-chains/SOURCES.json b/research/c6-t1-unequal-mask-chains/SOURCES.json new file mode 100644 index 0000000000..3768aa7498 --- /dev/null +++ b/research/c6-t1-unequal-mask-chains/SOURCES.json @@ -0,0 +1,18 @@ +{ + "schema_version": 1, + "base_commit": "17469fff78c22941280f04d39dc5a1faee09c840", + "files": [ + { + "path": "certificates/selected-result.json", + "usage": "input", + "git_blob": "d59b5035e7b4cbaa9d688a1d32dd0d6eb79c466a", + "sha256": "9b8d0eea95b3bf0dfcb7938a732a6439b87a2685dec2a5ab9e525b3b34debbfa" + }, + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "3404fbdd5e7529a0674eef26114b5071e4586cec", + "sha256": "ead6cdc9d0af6d58e8a49744d8ec8c7c15e13d2ba93c276c434bcf9b51b93a81" + } + ] +} diff --git a/research/c6-t1-unequal-mask-chains/TASK.json b/research/c6-t1-unequal-mask-chains/TASK.json new file mode 100644 index 0000000000..1811917b48 --- /dev/null +++ b/research/c6-t1-unequal-mask-chains/TASK.json @@ -0,0 +1,62 @@ +{ + "schema_version": 1, + "task_id": "connector-alphabet-change", + "priority_revision": 8, + "base_commit": "17469fff78c22941280f04d39dc5a1faee09c840", + "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": "changed", + "actual_scope": "In the unsigned six-source characteristic-6 floor model, all 2280 endpoint pairs with unequal masks of the multiset (6,6,6,7,7,7) are realized by an explicit floor word that keeps that multiset at every s=4..18.", + "scope_change_reason": "The card asks whether one new connector operation has a favorable budget. This package keeps the unsigned dirty connector alphabet fixed and answers open question 1 of PR #7042: which unequal endpoint masks are joined by a monotone chain of this multiset. No signed bill is computed.", + "bottleneck_link": "A missing unequal-mask chain would have been a diagonal obstruction inside type T1 that uses neither the (0, 9) hypothesis nor a frozen 12. Every such chain exists, so this multiset adds no further obstruction of that kind. The selected frontier stays 781451/250000000.", + "budget_minutes": 60, + "stop_rule": "Stop after the ten orbit witnesses and the check of all 2280 transported words. Do not price a supplier and do not search the other five separation-3 families.", + "outcome": "completed", + "evidence": "verify.py rechecks the endpoint domains, finds a 14-step path in each of the ten orbits, and checks the transported floor word on all 2280 unequal pairs. It prints PASS_C6_T1_UNEQUAL_MASK_CHAINS. Python 3.12, standard library only.", + "author": "unpaidmoon", + "ai_assistance": "Substantial Cursor Grok assistance. Independent human review and a proof-assistant proof are unclaimed.", + "open_questions": [ + { + "question": "For one separation-3 family other than type T1, which unequal endpoint masks are joined by a monotone chain of that family's multiset?", + "why_it_matters": "T1 is the only one of the six families with no coordinate 12, and every unequal T1 pair now has a chain. A family that uses a 12 has a different legal step.", + "first_step": "Fix that family's multiset, write the legal exchange, and search one symmetry class of unequal masks.", + "blocked_by": "The step rule used here only exchanges a 6 with a 7. It does not apply to a coordinate equal to 12." + } + ] +} diff --git a/research/c6-t1-unequal-mask-chains/VERIFY.json b/research/c6-t1-unequal-mask-chains/VERIFY.json new file mode 100644 index 0000000000..08f6ad4e11 --- /dev/null +++ b/research/c6-t1-unequal-mask-chains/VERIFY.json @@ -0,0 +1,30 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [ + "certificates/selected-result.json" + ], + "commands": [ + { + "argv": [ + "{python}", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 120, + "checks": "Endpoint-domain recheck, ten orbit searches, explicit transport of all 2280 unequal pairs, moving-word control, swapped-letter failure, and the selected kappa string." + }, + { + "argv": [ + "{python}", + "-O", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 120, + "checks": "The same census under python -O. Checks raise SystemExit, so optimized mode does not drop them." + } + ] +} diff --git a/research/c6-t1-unequal-mask-chains/verify.py b/research/c6-t1-unequal-mask-chains/verify.py new file mode 100644 index 0000000000..b6e8def415 --- /dev/null +++ b/research/c6-t1-unequal-mask-chains/verify.py @@ -0,0 +1,383 @@ +#!/usr/bin/env python3 +"""Every unequal T1 endpoint pair has a monotone (6,6,6,7,7,7) chain. + +The written argument is PROOF.md. This program rechecks the two endpoint +domains, searches one representative of each symmetry class, and checks the +transported floor word at every unequal endpoint pair. It does not call a +SAT solver and it does not change the selected frontier. +""" + +import itertools +import json +from collections import deque +from pathlib import Path + +K = 6 +LENGTH = 36 +TARGET = (6, 6, 6, 7, 7, 7) +ROOT = Path(__file__).resolve().parents[2] + +# Orbit sizes of unequal pairs (intersection, D in M_4, D in M_18). +ORBIT_COUNTS = { + (0, False, True): 60, + (0, True, False): 60, + (1, False, False): 180, + (1, False, True): 360, + (1, True, False): 360, + (1, True, True): 180, + (2, False, False): 360, + (2, False, True): 180, + (2, True, False): 180, + (2, True, True): 360, +} + +MOVING_WORD = "012340011223344555014555443322110023" + + +def fail(message): + raise SystemExit("FAIL: " + message) + + +def digits(word): + return [int(character) for character in word] + + +def prefixes(word): + counts = [0] * K + table = [tuple(counts)] + for source in word: + counts[source] += 1 + table.append(tuple(counts)) + return table + + +def diagonal(table, index): + early = table[index] + late = table[39 - index] + return tuple(early[j] + late[j] for j in range(K)) + + +def mask_of(sum_vec): + return tuple(source for source, value in enumerate(sum_vec) if value == 7) + + +def is_target_multiset(sum_vec): + return tuple(sorted(sum_vec)) == TARGET + + +def keeps_multiset(word): + if len(word) != LENGTH: + return False + table = prefixes(word) + if table[LENGTH] != (6, 6, 6, 6, 6, 6): + return False + return all(is_target_multiset(diagonal(table, index)) for index in range(4, 19)) + + +def budgets(mask4, deficit, mask18): + """Early and late letter budgets forced by Lemmas 1 and 2.""" + start = set(mask4) + finish = set(mask18) + if deficit not in start: + prefix = tuple(1 if source in start or source == deficit else 0 for source in range(K)) + else: + prefix = tuple( + 2 if source == deficit else 1 if source in start else 0 for source in range(K) + ) + early = tuple(3 - prefix[source] for source in range(K)) + late = tuple( + 3 - (1 if source == deficit else 0) - (1 if source in finish else 0) + for source in range(K) + ) + return prefix, early, late + + +def search_path(mask4, deficit, mask18): + """Breadth-first path in the finite budget graph, or None.""" + _prefix, early0, late0 = budgets(mask4, deficit, mask18) + start_mask = 0 + for source in mask4: + start_mask |= 1 << source + goal = 0 + for source in mask18: + goal |= 1 << source + + def pack(early, late, mask): + packed = mask + for value in early: + packed = packed * 4 + value + for value in late: + packed = packed * 4 + value + return packed + + start = (early0, late0, start_mask) + start_key = pack(*start) + seen = {start_key} + queue = deque([start]) + parent = {} + while queue: + early, late, mask = queue.popleft() + packed = pack(early, late, mask) + for early_letter in range(K): + if early[early_letter] == 0: + continue + for late_letter in range(K): + if late[late_letter] == 0: + continue + if early_letter == late_letter: + next_mask = mask + else: + enters = (mask >> early_letter) & 1 + leaves = (mask >> late_letter) & 1 + if enters or not leaves: + continue + next_mask = mask ^ (1 << early_letter) ^ (1 << late_letter) + next_early = ( + early[:early_letter] + + (early[early_letter] - 1,) + + early[early_letter + 1 :] + ) + next_late = ( + late[:late_letter] + + (late[late_letter] - 1,) + + late[late_letter + 1 :] + ) + key = pack(next_early, next_late, next_mask) + if key in seen: + continue + seen.add(key) + parent[key] = (packed, early_letter, late_letter) + if next_mask == goal and not any(next_early) and not any(next_late): + path = [] + cursor = key + while cursor != start_key: + previous, early_letter, late_letter = parent[cursor] + path.append((early_letter, late_letter)) + cursor = previous + path.reverse() + return path + queue.append((next_early, next_late, next_mask)) + return None + + +def assemble(mask4, deficit, mask18, path): + start = set(mask4) + if deficit not in start: + prefix = sorted(list(start) + [deficit]) + else: + others = sorted(source for source in start if source != deficit) + prefix = [deficit, deficit, others[0], others[1]] + early = [early_letter for early_letter, _late_letter in path] + late = [late_letter for _early_letter, late_letter in reversed(path)] + return prefix + early + list(mask18) + late + [deficit] + + +def regions(mask4, deficit, mask18): + start = set(mask4) + finish = set(mask18) + return { + "both": start & finish, + "only_start": start - finish, + "only_finish": finish - start, + "neither": set(range(K)) - start - finish, + "deficit": deficit, + } + + +def source_map(source_regions, target_regions): + """Bijection of sources carrying one endpoint triple onto another.""" + image = [None] * K + for name in ("both", "only_start", "only_finish", "neither"): + left = sorted(source_regions[name]) + right = sorted(target_regions[name]) + if len(left) != len(right): + return None + if source_regions["deficit"] in left: + left = [source_regions["deficit"]] + [ + source for source in left if source != source_regions["deficit"] + ] + right = [target_regions["deficit"]] + [ + source for source in right if source != target_regions["deficit"] + ] + for origin, destination in zip(left, right): + image[origin] = destination + if any(source is None for source in image) or len(set(image)) != K: + return None + return image + + +def endpoint_census(): + """Recheck the finite domains of the two endpoint lemmas.""" + rows = [] + for early in range(7): + for bridge in range(4): + if early + bridge <= 6 and (2 * early + bridge) in (6, 7): + rows.append((early, bridge, 2 * early + bridge)) + if rows != [(2, 2, 6), (2, 3, 7), (3, 0, 6), (3, 1, 7)]: + fail(f"s=18 row table changed: {rows}") + splits18 = 0 + for choice in itertools.product(rows, repeat=K): + if sum(row[0] for row in choice) != 18: + continue + if sum(row[1] for row in choice) != 3: + continue + summed = tuple(row[2] for row in choice) + if not is_target_multiset(summed): + continue + splits18 += 1 + pairs = sorted(row[:2] for row in choice) + if pairs != [(3, 0), (3, 0), (3, 0), (3, 1), (3, 1), (3, 1)]: + fail(f"unexpected s=18 split: {choice}") + if splits18 != 20: + fail(f"s=18 split count changed: {splits18}") + + type_a = 0 + type_b = 0 + other = 0 + domain4 = 0 + for early in itertools.product(range(7), repeat=K): + if sum(early) != 4: + continue + for deficit in range(K): + domain4 += 1 + summed = tuple( + early[source] + (5 if source == deficit else 6) for source in range(K) + ) + if not is_target_multiset(summed): + continue + mask = set(mask_of(summed)) + if deficit not in mask and all( + early[source] == (1 if source in mask or source == deficit else 0) + for source in range(K) + ): + type_a += 1 + elif deficit in mask and all( + early[source] + == (2 if source == deficit else 1 if source in mask else 0) + for source in range(K) + ): + type_b += 1 + else: + other += 1 + if (domain4, type_a, type_b, other) != (756, 60, 60, 0): + fail( + "s=4 split census changed: " + f"domain={domain4} A={type_a} B={type_b} other={other}" + ) + return 2 + + +def unequal_pairs(): + pairs = [] + for start in itertools.combinations(range(K), 3): + for finish in itertools.combinations(range(K), 3): + if start == finish: + continue + for deficit in range(K): + key = ( + len(set(start) & set(finish)), + deficit in start, + deficit in finish, + ) + pairs.append((key, start, deficit, finish)) + return pairs + + +def main(): + controls = 0 + selected = json.loads((ROOT / "certificates/selected-result.json").read_text()) + if selected.get("kappa") != "781451/250000000": + fail(f"selected kappa moved: {selected.get('kappa')}") + controls += 1 + + controls += endpoint_census() + + moving = digits(MOVING_WORD) + if not keeps_multiset(moving): + fail("recorded moving word lost the multiset") + moving_table = prefixes(moving) + if mask_of(diagonal(moving_table, 4)) != (0, 1, 2): + fail("recorded moving word lost its s=4 mask") + if mask_of(diagonal(moving_table, 18)) != (0, 1, 4): + fail("recorded moving word lost its s=18 mask") + controls += 1 + + broken = list(moving) + broken[4], broken[5] = broken[5], broken[4] + if keeps_multiset(broken): + fail("swapped moving-word letters still kept the multiset") + controls += 1 + + pairs = unequal_pairs() + if len(pairs) != 2280: + fail(f"unequal pair count changed: {len(pairs)}") + by_orbit = {} + for key, start, deficit, finish in pairs: + by_orbit.setdefault(key, []).append((start, deficit, finish)) + if set(by_orbit) != set(ORBIT_COUNTS): + fail(f"orbit keys changed: {sorted(by_orbit)}") + for key, expected in ORBIT_COUNTS.items(): + if len(by_orbit[key]) != expected: + fail(f"orbit {key} has {len(by_orbit[key])} pairs, expected {expected}") + if sum(ORBIT_COUNTS.values()) != 2280: + fail("orbit sizes do not add to 2280") + controls += 1 + + checked = 0 + for key in sorted(by_orbit): + start, deficit, finish = by_orbit[key][0] + prefix, early, late = budgets(start, deficit, finish) + if any(value < 0 for value in early + late) or sum(early) != 14 or sum(late) != 14: + fail(f"budgets failed on the representative of {key}") + if sum(prefix) != 4: + fail(f"prefix sum moved on the representative of {key}") + path = search_path(start, deficit, finish) + if path is None or len(path) != 14: + fail(f"no 14-step path for orbit {key}") + if sorted(letter for letter, _late in path) != sorted( + source for source, count in enumerate(early) for _ in range(count) + ): + fail(f"early letters missed the budget in orbit {key}") + if sorted(letter for _early, letter in path) != sorted( + source for source, count in enumerate(late) for _ in range(count) + ): + fail(f"late letters missed the budget in orbit {key}") + representative = assemble(start, deficit, finish, path) + if not keeps_multiset(representative): + fail(f"representative word missed the multiset in orbit {key}") + table = prefixes(representative) + if table[18] != (3, 3, 3, 3, 3, 3): + fail(f"q_18 left 3 in orbit {key}") + if mask_of(diagonal(table, 4)) != start or mask_of(diagonal(table, 18)) != finish: + fail(f"endpoint masks moved in orbit {key}") + source_regions = regions(start, deficit, finish) + for target_start, target_deficit, target_finish in by_orbit[key]: + image = source_map(source_regions, regions(target_start, target_deficit, target_finish)) + if image is None: + fail(f"no source bijection in orbit {key}") + word = [image[source] for source in representative] + if not keeps_multiset(word): + fail( + "transported word missed the multiset: " + f"{key} {target_start} {target_deficit} {target_finish}" + ) + transported = prefixes(word) + if mask_of(diagonal(transported, 4)) != target_start: + fail(f"transported s=4 mask changed in orbit {key}") + if mask_of(diagonal(transported, 18)) != target_finish: + fail(f"transported s=18 mask changed in orbit {key}") + if transported[18] != (3, 3, 3, 3, 3, 3): + fail(f"transported q_18 left 3 in orbit {key}") + checked += 1 + if checked != 2280: + fail(f"checked {checked} pairs, expected 2280") + controls += 1 + + print( + "PASS_C6_T1_UNEQUAL_MASK_CHAINS " + f"pairs=2280 orbits=10 witnesses=10 checked={checked} controls={controls}" + ) + + +if __name__ == "__main__": + main()