diff --git a/research/six-source-c6-prefix-pair-03/PROOF.md b/research/six-source-c6-prefix-pair-03/PROOF.md new file mode 100644 index 0000000000..0c896281ab --- /dev/null +++ b/research/six-source-c6-prefix-pair-03/PROOF.md @@ -0,0 +1,207 @@ +# The pair (0, 3) on the sharp T2 window + +Scoped written proof with an exhaustive finite certificate in `verify.py`. +The model is six sources, characteristic 6, and floor words of length 36. +No claim is made about the unrestricted six-source depth-two exclusion, which +remains the solver verdict of PR6141. The selected frontier is unchanged. + +## 0. Setting + +The interface is the one in the merged package +`research/six-source-c6-centre-classification`, pinned in `SOURCES.json`. +A floor word calls each source `0,...,5` exactly six times. `q_t` counts the +first `t` letters. For `4 <= s <= 18`, + +```text +S(s) = q_s + q_{39-s}. +``` + +`S(s)` is weight-3 when every coordinate lies in `{0,1,6,7,12}` and exactly +three lie in `{1,7}`. The same predicate applied to `q_t` is the weight-3 +condition at the pair `(0,t)`. A chain on `[8,18]` is a floor word whose +`S(s)` is weight-3 for every `s` in that interval. Its family is the sorted +tuple `S(18)`. The T2 family is `(0,6,7,7,7,12)`. + +Open PR #7176 proves that this family has sharp window `[8,18]`, that exactly +720 of the `180 * 120` endpoint pairs are joined there, and that weight-3 at +`(0,9)` coexists with a chain on `[s0,18]` exactly for `s0 >= 8`. Its first +open question asks which further pair with `s + t ≡ 3 (mod 6)` can hold +together with `(0,9)` and that window, starting from the 180 extendible states +at `s = 8` and retaining prefix order. This note answers that question for the +named pair `(0,3)`. + +## 1. Lemma. One-low states at s = 8 + +*There are exactly 180 weight-3 diagonal states at `s = 8` with one coordinate +at most 1. Each has `q_8` a permutation of `(6,1,1,0,0,0)` and `S(8)` a +permutation of `(1,6,6,7,7,12)`. None has sorted sum `(0,6,7,7,7,12)`.* + +A weight-3 vector sums to 39 and has exactly three coordinates congruent to 1 +modulo 6, so its bases `6 * floor(S_j / 6)` sum to 36. Writing `n0, n6, n12` +for the number of coordinates of each base gives `n0 + n6 + n12 = 6` and +`n6 + 2 n12 = 6`, hence `n12 = n0`. Call this common value `L`. + +At `s = 8` the complementary count is `q_31`, the state records a pair +`(q, t)` with `0 <= q_j <= t_j <= 6` and `S = q + t`, and +`sum_j (6 - t_j) = 5`. Those five letters occupy positions `31,...,35`. A +coordinate of base 0 has `t_j <= 1`, so it contributes at least five of those +suffix letters. Two such coordinates need at least ten suffix letters. Thus +`L <= 1`. If the unique low coordinate has `S_j = 0`, then `t_j = 0` and that +coordinate alone needs six suffix letters. So `S_j = 1`, which forces +`(q_j, t_j) = (0, 1)`, and the suffix is five copies of this low source. + +The unique high coordinate has sum 12. The only solution of `q + t = 12` with +`0 <= q <= t <= 6` is `(6, 6)`. The four middle coordinates then have +`t`-sum `31 - 6 - 1 = 24` and each `t_j <= 6`, so each equals 6. Their allowed +sums are 6 or 7, so their `q` entries lie in `{0,1}` and sum to +`8 - 6 - 0 = 2`. Exactly two of them equal 1. + +Choose the high source in 6 ways, the low source in 5 ways, and which two of +the remaining four sources have prefix count 1 in `C(4,2) = 6` ways: +`6 * 5 * 6 = 180`. Each choice is a weight-3 state, and the two paragraphs +above exclude every other one-low state. The sorted sum is +`(1,6,6,7,7,12)`. In particular the T2 tuple `(0,6,7,7,7,12)` does not occur +at `s = 8`. + +`verify.py` enumerates the diagonal states independently from the ten legal +column pairs and checks that the one-low subset is exactly this set of 180. +The same enumeration finds 3,420 zero-low states at `s = 8` and no state with +two or more low coordinates. + +## 2. Lemma. Prefixes that make (0, 3) weight-3 + +*For each of these 180 states, exactly 6 of the 56 words of length 8 with +letter counts `q_8` make `q_3` weight-3.* + +The count vector is six copies of a heavy source `H` and one copy each of two +sources `A` and `B`. The number of distinct words is `8 * 7 = 56`. A length-3 +prefix has sum 3, so the only weight-3 shape available to it is a permutation +of `(1,1,1,0,0,0)`: three distinct letters. The only three letters present are +`H, A, B`, and the two singletons must occupy two of the first three positions. +There are `3 * 2 = 6` such words; the other five positions are `H`. The other +50 words repeat `H` often enough that `q_3` has a coordinate outside +`{0,1,6,7,12}` or has fewer than three residues 1. + +The diagonal sums `S(s)` for `s >= 8`, and the count `q_9`, depend on `q_8` +and on letters at positions `>= 8`. They do not depend on the order inside +the first eight letters. Reordering that prefix preserves every chain of +diagonal states and preserves the truth value of weight-3 at `(0,9)`. + +## 3. Theorem. An explicit word for every state + +*For every one-low state at `s = 8` and every one of its six favorable +prefixes, there is a floor word that is weight-3 at `(0,3)`, at `(0,9)`, and +at every `s` in `[8,18]`, with `S(18) = S(9)` equal to a permutation of +`(0,6,7,7,7,12)`.* + +Let `H` be heavy, `L` low, `{A,B}` the two middle sources of prefix count 1, +and `{C,D}` the two middle sources of prefix count 0. Put a permutation of +`(A,B,H)` in positions `0,1,2` and `H` in positions `3,...,7`. Put `C` in +position 8. On each pair of positions `(s, 38-s)` for `s = 9,...,17`, put the +same letter, using `A,A,B,B,C,C,D,D,D` in that order of `s`. Put `A,B,C` in +positions `18,19,20`, put `L` in position 30, and put `L` in positions +`31,...,35`. + +Each source occurs six times: `H` six times in the prefix; `A` once in the +prefix, four times in two pairs, and once in the middle, and likewise `B`; +`C` once at position 8, four times in two pairs, and once in the middle; `D` +six times in three pairs; `L` once at position 30 and five times in the +suffix. The word is a floor word. Its prefix count is the state of Section 1, +and its first three letters are `A,B,H` in some order, so `(0,3)` is weight-3. +Position 8 contributes `C`, so + +```text +q_9 = e_A + e_B + e_C + 6 e_H, +``` + +which is a permutation of `(1,1,1,6,0,0)` and is weight-3. + +The first 31 letters contain every copy of every source except five copies of +`L`, so `q_31 = 6(1,...,1) - 5 e_L`. Therefore + +```text +S(8)_H = 12, S(8)_A = S(8)_B = 7, S(8)_C = S(8)_D = 6, S(8)_L = 1. +``` + +The step from `s = 8` to `s = 9` adds `e_C` and subtracts `e_L`, because +position 8 is `C` and position 30 is `L`. Hence `S(9)` is the same tuple with +the `C` coordinate raised from 6 to 7 and the `L` coordinate lowered from 1 to +0: a permutation of `(0,6,7,7,7,12)`. For `s = 9,...,17` the letters at `s` +and at `38-s` were chosen equal, so `S(s+1) = S(s)`. Thus `S(s) = S(9)` for +every `s` in `[9,18]`, and the endpoint family is T2. + +There are 180 states and 6 prefixes, so the construction produces 1,080 words. +`verify.py` checks each word from the letters alone. The lexicographically +first parameter tuple `(H,L,A,B,C,D) = (0,1,2,3,4,5)`, with prefix order +`(A,B,H)`, produces + +```text +230000004223344555234555443322111111 +``` + +## 4. The 180 states are the T2 start states, and (0, 9) keeps every joined pair + +Section 3 already shows that every one-low state reaches at least one T2 +endpoint through a word that is weight-3 at `(0,9)`. The certificate also +enumerates the whole weight-3 graph for `8 <= s <= 18`: + +- column pairs `(q,t)` with `0 <= q <= t <= 6` and `q+t` in `{0,1,6,7,12}`: + exactly the ten pairs `(0,0), (0,1), (3,3), (2,4), (3,4), (1,5), (2,5), + (0,6), (1,6), (6,6)`; +- a state is any 6-tuple of those pairs whose `q`-sum is `s`, whose `t`-sum + is `39-s`, and whose coordinate sums have exactly three residues 1; +- an edge increments one `q` coordinate and decrements one positive `t` + coordinate, landing on a state at `s+1`. + +The layer sizes are `3600, 5520, 7740, 9900, 11220, 11280, 9780, 7240, 4500, +2040, 700`. Every one of the 592,020 edges preserves the base vector. The 700 +endpoint states split into the six families with sizes `20, 20, 120, 180, 180, +180`, and the T2 family has 120 states. + +Backward reachability and a second, forward reachability agree on the +following. Exactly the 180 one-low states reach T2. Between them and the 120 +T2 endpoints there are 720 joined pairs. For each of the 180 states, the set +of reachable T2 endpoints is the same when every `s = 9` state with +non-weight-3 `q_9` is deleted. The same equality holds for the other one-low +endpoint family `(1,6,6,7,7,12)`, whose 1,080 joined pairs are a by-product of +the same masks. Thus weight-3 at `(0,9)` coexists with every T2 pair joined +on `[8,18]`. + +The graph does not say that every path is weight-3 at `(0,9)`. The word + +```text +345555554433222111234111220334400000 +``` + +printed by PR #7176 is a chain on `[8,18]` with T2 endpoint and with weight-3 +`(0,3)`, while its `q_9` is a permutation of `(0,0,0,1,2,6)`. Deleting the +non-weight-3 layer leaves a path to the same endpoints; it does not delete +the endpoints. The companion word + +```text +345555552443322111234111223344000000 +``` + +from the same PR is one more explicit point in the coexistence set: weight-3 +at `(0,3)`, at `(0,9)`, and on the whole window, with T2 endpoint. + +For each of the 720 joined pairs the certificate lifts one filtered path to a +word, using one favorable prefix, and checks that word from the letters. A +favorable prefix does not change `q_8`, so the same lift works for all six +prefixes of Section 2. Every T2 pair joined on `[8,18]` therefore has a floor +word that is also weight-3 at `(0,9)` and at `(0,3)`. + +## 5. What this does and does not settle + +Settled, in this model: the classification of the 180 states; the 6-out-of-56 +prefix count for `(0,3)`; coexistence of `(0,3)` with `(0,9)` and with every +T2 pair joined on `[8,18]`; the explicit 1,080-word family; and the equality +of the filtered and unfiltered T2 endpoint sets. + +Not settled: any pair other than `(0,3)` and the already assumed `(0,9)`; +constant-multiset chains, which Section 1 already forbids at `s = 8` for the +T2 tuple; other characteristics and source counts; and the unrestricted +depth-two exclusion. A single exhibited word would have shown bare +coexistence. The census is the stronger statement that the obstruction fails +for every extendible state and for every previously joined T2 pair, on an +explicit 6/56 fraction of the prefix orders. diff --git a/research/six-source-c6-prefix-pair-03/README.md b/research/six-source-c6-prefix-pair-03/README.md new file mode 100644 index 0000000000..ebc9ce9ce4 --- /dev/null +++ b/research/six-source-c6-prefix-pair-03/README.md @@ -0,0 +1,137 @@ +# The pair (0, 3) coexists with (0, 9) on the sharp T2 window + +**Exhaustive finite census with explicit words. No new κ and no selected-frontier +change.** In the six-source characteristic-6 floor-word model, the named pair +`(0, 3)` coexists with weight-3 at `(0, 9)` and with every T2 pair joined on +the sharp window `[8, 18]`. + +A floor word calls each source exactly six times. `S(s) = q_s + q_{39-s}` is +weight-3 when every coordinate lies in `{0,1,6,7,12}` and exactly three lie in +`{1,7}`. The same predicate on `q_3` and on `q_9` is weight-3 at `(0,3)` and +at `(0,9)`. The T2 family is the endpoint multiset `(0,6,7,7,7,12)`. The +interface is the merged centre-classification package pinned in +[SOURCES.json](SOURCES.json). The question is open-next item 1 of +[PR #7176](https://github.com/CrocSwap/integer-mult-bounds/pull/7176), restricted +to the single pair `(0,3)`. + +The selected conditional κ remains `363005817/100000000000` in +`certificates/selected-result.json`. + +## Census + +There are exactly **180** weight-3 diagonal states at `s = 8` with one +coordinate at most 1. They are given by a heavy source `H`, a low source `L`, +and which two of the other four sources have prefix count 1: + +- `q_8` is the matching permutation of `(6,1,1,0,0,0)`; +- `S(8)` is the matching permutation of `(1,6,6,7,7,12)`. + +The T2 tuple itself does not occur at `s = 8`: a coordinate equal to 0 would +need six copies in the five-letter suffix. These 180 states are exactly the +states that reach the T2 family on `[8,18]`. They meet the 120 T2 endpoints in +**720** joined pairs, the count proved for this window by #7176. Deleting every +`s = 9` state whose `q_9` is not weight-3 leaves each of those 720 endpoint +sets unchanged. The same holds for the other one-low endpoint family +`(1,6,6,7,7,12)` and its 1,080 pairs; that count is a by-product of the same +masks. + +For each of the 180 states the prefix of length 8 has **56** orders and exactly +**6** of them make `(0,3)` weight-3: the two singleton letters both sit in the +first three positions. Prefix order does not change `q_8`, so it preserves the +diagonal chain and the truth value of `(0,9)`. Every previously joined T2 pair +therefore has a floor word that is weight-3 at `(0,3)`, at `(0,9)`, and at +every `s` in `[8,18]`. + +The proof, including the uniform word that realises all `180 * 6 = 1080` +favorable prefixes, is in [PROOF.md](PROOF.md). + +## Witnesses + +`verify.py` rebuilds all 1,080 words and lifts one filtered path for each of +the 720 joined pairs. Three words are also written here and checked from the +string alone. + +| role | word | +| --- | --- | +| canonical construction `(H,L,A,B,C,D) = (0,1,2,3,4,5)` | `230000004223344555234555443322111111` | +| #7176 word, weight-3 at `(0,9)` and at `(0,3)` | `345555552443322111234111223344000000` | +| #7176 T2 word whose `q_9` has shape `(0,0,0,1,2,6)` | `345555554433222111234111220334400000` | + +The third word is a chain on `[8,18]` with T2 endpoint and with weight-3 +`(0,3)`. Its `q_9` is not weight-3, so a T2 chain need not pass through +`(0,9)`. The filtered graph still reaches the same endpoints by another path. +Replacing the canonical prefix by six heavies followed by the two singletons +keeps the window and `(0,9)` and makes `(0,3)` fail, so the prefix order is +the exact extra datum. + +## Reproduce + +Python 3.12, standard library only, from the repository root: + +```sh +python3.12 -I -W error -B research/six-source-c6-prefix-pair-03/verify.py +python3.12 -I -O -W error -B research/six-source-c6-prefix-pair-03/verify.py +python3.12 -B scripts/research_package.py --package research/six-source-c6-prefix-pair-03 +``` + +Expected marker: + +```text +PASS_SIX_SOURCE_C6_PREFIX_PAIR_03 l1=180 prefixes=56 favorable=6 constructed=1080 lifts=720 joined_t2=720 joined_other=1080 forward=720 layer8=3600 l0=3420 controls=7 inputs=1 +``` + +The verifier enumerates every weight-3 diagonal state for `8 <= s <= 18`, +checks base preservation on every legal edge, compares backward and forward +T2 endpoint sets with and without the `(0,9)` filter, checks all 56 prefixes +of each of the 180 states, and checks every constructed and lifted word from +its letters. Seven controls accept the two cited words, reject a bad prefix +order, a 35-letter string, and a seventh copy of one letter, and reject a +nearby count vector that is outside the census. Failures raise `SystemExit`. + +Layer sizes are fixed at `3600` through `700` as listed in the proof. Each +state has six coordinates and at most 36 successor candidates. Partial column +enumeration uses the ten legal pairs and at most `10^6` partial tuples. No +solver or child process is started. + +Python dicts and arbitrary-precision endpoint masks are a managed-runtime +deviation while the domains above stay fixed. Normal and optimized runs both +exercise the full domains. + +## Scope and limits + +The result fixes six sources, characteristic 6, length 36, the diagonal pairs +`(s, 39-s)` for `8 <= s <= 18`, and the two early pairs `(0,9)` and `(0,3)`. +It is an exhaustive census of that finite set, not a sample and not a proof +of the unrestricted depth-two exclusion. Intermediate multisets may differ +from the endpoint: every word above has `S(8)` of type `(1,6,6,7,7,12)` and +`S(s)` of T2 type for `s >= 9`. Pairs such as `(4,5)`, `(2,7)`, `(3,6)` and +`(1,8)` are untouched. Independent human and formal proof-kernel review are +unclaimed. No supplier, consumer, or selected frontier changes. + +## Open next questions + +1. On these same 180 states, which of the six `(0,3)`-favorable prefixes make + `(4,5)` weight-3? *Why:* `(0,3)` sees only the first three letters and + never obstructs a joined T2 pair, while `(4,5)` still lies inside the free + prefix and reads five letters, so it can reject some of those six orders. + *First step:* evaluate `q_4 + q_5 = 2 q_4 + e_{w_4}` on the six prefixes of + the canonical word, then repeat for every state only if that word is empty. + *Blocked by:* nothing in the present certificate; the checker is hard-coded + for `(0,3)`. + +The structured copy is in [TASK.json](TASK.json). + +## Credit + +The classification, the prefix count, the 1,080-word construction and the +endpoint-set comparison were prepared by unpaidmoon with substantial Cursor +Grok assistance. Nick Petalas's open +[PR #7176](https://github.com/CrocSwap/integer-mult-bounds/pull/7176) supplies +the sharp-window theorem, the figures 180 and 720, the question, and the two +cited words; those words are rechecked here and that package is not replayed. +unpaidmoon's [PR #7099](https://github.com/CrocSwap/integer-mult-bounds/pull/7099), +[PR #7029](https://github.com/CrocSwap/integer-mult-bounds/pull/7029) and +[PR #7042](https://github.com/CrocSwap/integer-mult-bounds/pull/7042) supply +the T2 question, the six families and the `(0,9)` pricing. The mask definition +is the merged `six-source-c6-centre-classification` package. No predecessor +credit is changed. Apache-2.0. diff --git a/research/six-source-c6-prefix-pair-03/SOURCES.json b/research/six-source-c6-prefix-pair-03/SOURCES.json new file mode 100644 index 0000000000..ef9ddc2171 --- /dev/null +++ b/research/six-source-c6-prefix-pair-03/SOURCES.json @@ -0,0 +1,24 @@ +{ + "schema_version": 1, + "base_commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "files": [ + { + "path": "certificates/selected-result.json", + "usage": "provenance", + "git_blob": "75d77b328ea02ded535e7f23aee5b1e55d0bb1a8", + "sha256": "154c3d30455d778fd3343b6b4851f0fa4665f0f7625b0adb3675e2bafbbf6bf1" + }, + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "3404fbdd5e7529a0674eef26114b5071e4586cec", + "sha256": "ead6cdc9d0af6d58e8a49744d8ec8c7c15e13d2ba93c276c434bcf9b51b93a81" + }, + { + "path": "research/six-source-c6-centre-classification/README.md", + "usage": "input", + "git_blob": "3e6b3c225c15b081f2b66dd16c97118e3b8c494b", + "sha256": "0d86c0d2524036b1fe36bc4217a935b97160f8155b810bb0010a3130d97f3dcf" + } + ] +} diff --git a/research/six-source-c6-prefix-pair-03/TASK.json b/research/six-source-c6-prefix-pair-03/TASK.json new file mode 100644 index 0000000000..0dd88407e4 --- /dev/null +++ b/research/six-source-c6-prefix-pair-03/TASK.json @@ -0,0 +1,72 @@ +{ + "schema_version": 1, + "task_id": "connector-alphabet-change", + "priority_revision": 8, + "base_commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "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": "Which prefixes of the 180 extendible states at s=8 make the named weight-3 pair (0,3) coexist with weight-3 at (0,9) and with the sharp T2 window [8,18]?", + "scope_change_reason": "The card asks for one new connector operation. This package keeps the published alphabet and answers open-next question 1 of PR #7176 for the single named pair (0,3), on the 180 states at s=8 of the sharp T2 window. A new operation is not the missing step.", + "bottleneck_link": "Side result on the six-source c=6 diagonal. It shows that the pair (0,3) does not obstruct (0,9) together with the sharp T2 window. It supplies no supplier, consumer, selected-record change or kappa.", + "budget_minutes": 60, + "stop_rule": "Ship the (0,3) census on the 180 states, with explicit words and the endpoint-set comparison. Leave every other early pair open.", + "outcome": "completed", + "evidence": "PROOF.md (classification of the 180 states, the 6/56 prefix count, the uniform word, and the filtered endpoint equality) and verify.py: exhaustive diagonal graph for 8<=s<=18, 1080 constructed words, 720 lifted joined pairs, backward and forward agreement, seven failure controls.", + "author": "unpaidmoon", + "ai_assistance": "Prepared by unpaidmoon with substantial Cursor Grok assistance.", + "open_questions": [ + { + "question": "On these same 180 states, which of the six (0,3)-favorable prefixes make the pair (4,5) weight-3?", + "why_it_matters": "The pair (0,3) coexists with every T2 pair joined on [8,18], so it does not obstruct that window. The pair (4,5) still lies in the free prefix but reads five letters, and may reject some of the six favorable orders.", + "first_step": "Evaluate q_4 + q_5 = 2 q_4 + e_{w_4} on the six favorable prefixes of the canonical word 230000004223344555234555443322111111, and extend the same check to every state only if that word has no favorable prefix left.", + "blocked_by": "Nothing in the present census. The verifier is hard-coded for the pair (0,3); (4,5) was not enumerated." + } + ], + "claim_type": "exhaustive finite census with explicit words", + "predecessor": { + "pr": 7176, + "author": "Nick Petalas", + "head": "af3647d85d6f52956b1423ec8b22646f0deac196", + "question": "README Open next questions 1, restricted to the named pair (0,3)", + "url": "https://github.com/CrocSwap/integer-mult-bounds/pull/7176", + "role": "Source of the sharp T2 window, the figures 180 and 720, the question, and the two cited words. Cited and rechecked on those words; the package is not replayed." + }, + "kappa_unchanged": "363005817/100000000000" +} diff --git a/research/six-source-c6-prefix-pair-03/VERIFY.json b/research/six-source-c6-prefix-pair-03/VERIFY.json new file mode 100644 index 0000000000..f758bc2a40 --- /dev/null +++ b/research/six-source-c6-prefix-pair-03/VERIFY.json @@ -0,0 +1,36 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [ + "research/six-source-c6-centre-classification/README.md" + ], + "commands": [ + { + "argv": [ + "{python}", + "-I", + "-W", + "error", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 180, + "checks": "Exhaustive census of the 180 one-low states at s=8, all 56 prefixes, 1080 constructed words, 720 filtered T2 lifts, backward and forward endpoint sets, and failure controls." + }, + { + "argv": [ + "{python}", + "-I", + "-O", + "-W", + "error", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 180, + "checks": "The same gates under optimized Python. Every gate raises SystemExit; none uses assert." + } + ] +} diff --git a/research/six-source-c6-prefix-pair-03/verify.py b/research/six-source-c6-prefix-pair-03/verify.py new file mode 100755 index 0000000000..ad58721664 --- /dev/null +++ b/research/six-source-c6-prefix-pair-03/verify.py @@ -0,0 +1,527 @@ +#!/usr/bin/env python3 +"""Pair (0, 3) beside (0, 9) on the sharp T2 window [8, 18]. + +Standard library only. Every scientific gate raises SystemExit, so -O cannot +silence a failure. The finite domains are the weight-3 diagonal states at +8 <= s <= 18 (at most 11,280 states in one layer; 10 column pairs; at most +36 successor candidates), the 180 one-low states at s = 8, the 56 prefixes of +each, and the joined T2 endpoint pairs. No recursion and no solver. + +Interface (cited, not re-proved): research/six-source-c6-centre-classification +defines a c=6 six-source floor word and a weight-3 mask. The window question +is the open next question of PR #7176. +""" + +import hashlib +import json +import sys +from pathlib import Path + +C = 6 +K = 6 +LENGTH = 36 +PAIR_SUM = 39 +TOP = 18 +LOW = 8 +MID = 9 +ALLOWED = (0, 1, 6, 7, 12) +T2 = (0, 6, 7, 7, 7, 12) +OTHER_L1 = (1, 6, 6, 7, 7, 12) +START_S = (1, 6, 6, 7, 7, 12) +LAYER_SIZES = { + 8: 3600, 9: 5520, 10: 7740, 11: 9900, 12: 11220, 13: 11280, + 14: 9780, 15: 7240, 16: 4500, 17: 2040, 18: 700, +} +FAMILY_SIZES = { + (0, 1, 7, 7, 12, 12): 180, + (0, 6, 7, 7, 7, 12): 120, + (1, 1, 1, 12, 12, 12): 20, + (1, 1, 6, 7, 12, 12): 180, + (1, 6, 6, 7, 7, 12): 180, + (6, 6, 6, 7, 7, 7): 20, +} +CANONICAL = "230000004223344555234555443322111111" +CITED_09 = "345555552443322111234111223344000000" +CITED_T2 = "345555554433222111234111220334400000" +PKG = Path(__file__).resolve().parent +ROOT = PKG.parents[1] + + +def require(ok, message): + if not ok: + raise SystemExit("FAIL: " + message) + + +def weight3(sv): + """All coordinates in {0,1,6,7,12} and exactly three in {1,7}.""" + ones = 0 + for value in sv: + if value not in ALLOWED: + return False + if value % C == 1: + ones += 1 + return ones == 3 + + +def column_options(): + """Pairs 0 <= q <= t <= 6 with q + t in the allowed set. Ten pairs.""" + return [(q, t) for t in range(C + 1) for q in range(t + 1) if q + t in ALLOWED] + + +def static_states(s): + """Every weight-3 diagonal state (q_s, q_{39-s}). Pruning drops only sums past the target.""" + opts = column_options() + parts = [((), 0, 0, 0)] + for _ in range(K): + grown = [] + for cols, sq, st, ones in parts: + for q, t in opts: + nsq, nst = sq + q, st + t + nones = ones + ((q + t) % C == 1) + if nsq <= s and nst <= PAIR_SUM - s and nones <= 3: + grown.append((cols + ((q, t),), nsq, nst, nones)) + parts = grown + out = [] + for cols, sq, st, ones in parts: + if sq == s and st == PAIR_SUM - s and ones == 3: + out.append((tuple(c[0] for c in cols), tuple(c[1] for c in cols))) + return out + + +def diag_sum(state): + return tuple(a + b for a, b in zip(state[0], state[1])) + + +def lows(state): + return sum(1 for value in diag_sum(state) if value <= 1) + + +def base_vector(state): + return tuple(C * (value // C) for value in diag_sum(state)) + + +def successors(state, nxt): + """States at s+1 from an early letter a and a late letter b.""" + q, t = state + found = [] + for a in range(K): + qa = q[:a] + (q[a] + 1,) + q[a + 1:] + for b in range(K): + if t[b] == 0: + continue + tb = t[:b] + (t[b] - 1,) + t[b + 1:] + if (qa, tb) in nxt: + found.append((qa, tb)) + return found + + +def parameters(): + """(H, L, A, B, C, D): heavy, low, two prefix-count-1 mids, two prefix-count-0 mids.""" + rows = [] + for heavy in range(K): + for low in range(K): + if low == heavy: + continue + mids = [j for j in range(K) if j != heavy and j != low] + for i in range(4): + for j in range(i + 1, 4): + first, second = mids[i], mids[j] + rest = [x for x in mids if x != first and x != second] + rows.append((heavy, low, first, second, rest[0], rest[1])) + return rows + + +def state_of(heavy, low, first, second): + """Diagonal state at s=8 for this parameter tuple. C and D do not appear in the counts.""" + q = [0] * K + t = [C] * K + q[heavy] = C + q[first] = 1 + q[second] = 1 + t[low] = 1 + return (tuple(q), tuple(t)) + + +def three_orders(a, b, h): + """The six permutations of three distinct letters, as the first three prefix letters.""" + raw = (a, b, h) + orders = [] + for i in range(3): + for j in range(3): + if i == j: + continue + k = 3 - i - j + orders.append((raw[i], raw[j], raw[k])) + return orders + + +def build_word(heavy, low, first, second, third, fourth, first3): + """Floor word with the given roles. first3 is a permutation of (first, second, heavy).""" + word = [heavy] * LENGTH + word[0], word[1], word[2] = first3 + word[8] = third + pairs = [first, first, second, second, third, third, fourth, fourth, fourth] + for offset, letter in enumerate(pairs): + s = 9 + offset + word[s] = letter + word[38 - s] = letter + word[18], word[19], word[20] = first, second, third + word[30] = low + for pos in range(31, LENGTH): + word[pos] = low + return word + + +def as_text(word): + return "".join(str(letter) for letter in word) + + +def counts(letters, n): + return tuple(letters[:n].count(j) for j in range(K)) + + +def diagonal(letters, s): + return tuple(counts(letters, s)[j] + counts(letters, PAIR_SUM - s)[j] for j in range(K)) + + +def check_floor(letters): + require(len(letters) == LENGTH, "length") + require(all(0 <= x < K for x in letters), "alphabet") + require(all(letters.count(j) == C for j in range(K)), "not a floor word") + + +def check_window(letters, want_03, want_09): + """Weight-3 on [8, 18], endpoint family T2, and the requested early pairs.""" + check_floor(letters) + for s in range(LOW, TOP + 1): + require(weight3(diagonal(letters, s)), "window failed at s=%d" % s) + require(tuple(sorted(diagonal(letters, TOP))) == T2, "endpoint family") + if want_03: + require(weight3(counts(letters, 3)), "(0,3) failed") + if want_09: + require(weight3(counts(letters, MID)), "(0,9) failed") + + +def rejects(text): + try: + letters = [int(ch) for ch in text] + check_floor(letters) + except (SystemExit, ValueError): + return True + return False + + +def prefix_census(states): + """Every one-low state has 56 prefixes and exactly 6 make (0, 3) weight-3.""" + for state in states: + q = state[0] + heavy = [i for i, value in enumerate(q) if value == C] + singles = [i for i, value in enumerate(q) if value == 1] + require(len(heavy) == 1 and len(singles) == 2, "q shape %r" % (q,)) + h, a, b = heavy[0], singles[0], singles[1] + seen = 0 + good = 0 + favorable = [] + for i in range(LOW): + for j in range(LOW): + if i == j: + continue + word = [h] * LOW + word[i] = a + word[j] = b + seen += 1 + q3 = tuple(word[:3].count(letter) for letter in range(K)) + both_early = i < 3 and j < 3 + require(weight3(q3) == both_early, "prefix test %r" % (word,)) + if both_early: + good += 1 + favorable.append(tuple(word)) + require(seen == 56 and good == 6, "prefix counts %d %d" % (seen, good)) + expect = [] + for first3 in three_orders(a, b, h): + expect.append(first3 + (h, h, h, h, h)) + require(set(favorable) == set(expect), "favorable prefixes") + return 56, 6 + + +def check_construction(rows): + """Every parameter tuple and each of its six (0, 3) prefixes is a T2 word through (0, 9).""" + texts = [] + for heavy, low, first, second, third, fourth in rows: + state = state_of(heavy, low, first, second) + for first3 in three_orders(first, second, heavy): + word = build_word(heavy, low, first, second, third, fourth, first3) + letters = word + check_window(letters, True, True) + require(counts(letters, LOW) == state[0], "constructed q8") + require(counts(letters, PAIR_SUM - LOW) == state[1], "constructed q31") + require(tuple(sorted(diagonal(letters, LOW))) == START_S, "S(8)") + s9 = diagonal(letters, MID) + require(tuple(sorted(s9)) == T2, "S(9)") + for s in range(MID + 1, TOP + 1): + require(diagonal(letters, s) == s9, "S moved at s=%d" % s) + require(weight3(counts(letters, 3)) and weight3(counts(letters, MID)), "early pairs") + texts.append(as_text(letters)) + require(len(texts) == 180 * 6 and len(set(texts)) == 180 * 6, "constructed words") + require(CANONICAL in texts, "canonical word missing") + return len(texts) + + +def build_graph(): + layers = {s: static_states(s) for s in range(LOW, TOP + 1)} + for s, size in LAYER_SIZES.items(): + require(len(layers[s]) == size, "layer %d has %d states" % (s, len(layers[s]))) + sets = {s: set(v) for s, v in layers.items()} + succ = {} + steps = 0 + for s in range(LOW, TOP): + succ[s] = {} + for state in layers[s]: + nxt = successors(state, sets[s + 1]) + succ[s][state] = nxt + steps += len(nxt) + for other in nxt: + require(base_vector(state) == base_vector(other), "base changed at s=%d" % s) + require(steps == 592020, "edge count %d" % steps) + return layers, succ, steps + + +def family_data(layers): + groups = {} + for index, state in enumerate(layers[TOP]): + groups.setdefault(tuple(sorted(diag_sum(state))), []).append(index) + sizes = {fam: len(idx) for fam, idx in groups.items()} + require(sizes == FAMILY_SIZES, "family sizes %r" % (sizes,)) + masks = {} + for fam, idx in groups.items(): + mask = 0 + for bit in idx: + mask |= 1 << bit + masks[fam] = mask + return masks + + +def backward(layers, succ, filter_09): + reach = {TOP: {state: 1 << i for i, state in enumerate(layers[TOP])}} + for s in range(TOP - 1, LOW - 1, -1): + layer = {} + for state in layers[s]: + mask = 0 + for nxt in succ[s][state]: + mask |= reach[s + 1][nxt] + if filter_09 and s == MID and not weight3(state[0]): + mask = 0 + layer[state] = mask + reach[s] = layer + return reach + + +def popcount(n): + count = 0 + while n: + n &= n - 1 + count += 1 + return count + + +def endpoint_relation(layers, succ, states, masks): + """Filtered and unfiltered T2 endpoint sets agree, and forward recomputes them.""" + plain = backward(layers, succ, False) + filtered = backward(layers, succ, True) + t2_mask = masks[T2] + other_mask = masks[OTHER_L1] + reachers = [state for state in layers[LOW] if plain[LOW][state] & t2_mask] + require(set(reachers) == set(states), "T2 starts are not the 180 one-low states") + joined_t2 = 0 + joined_other = 0 + for state in states: + require((plain[LOW][state] & t2_mask) == (filtered[LOW][state] & t2_mask), "T2 mask changed") + require((plain[LOW][state] & other_mask) == (filtered[LOW][state] & other_mask), "other mask changed") + require(popcount(filtered[LOW][state] & t2_mask) > 0, "state misses T2") + joined_t2 += popcount(filtered[LOW][state] & t2_mask) + joined_other += popcount(filtered[LOW][state] & other_mask) + require(joined_t2 == 720 and joined_other == 1080, "joined counts %d %d" % (joined_t2, joined_other)) + nonzero9 = sum(1 for mask in filtered[MID].values() if mask) + require(nonzero9 == 480, "filtered s=9 count %d" % nonzero9) + for state, mask in filtered[MID].items(): + if mask: + require(weight3(state[0]), "filtered s=9 state has a non-weight-3 q9") + forward = forward_counts(layers, succ, states, t2_mask) + for state in states: + require(forward[state] == popcount(filtered[LOW][state] & t2_mask), "forward mismatch") + return filtered, joined_t2, joined_other, sum(forward.values()) + + +def forward_counts(layers, succ, states, t2_mask): + """Popcount of T2 endpoints reachable from each start through a weight-3 q9.""" + index = {state: i for i, state in enumerate(states)} + current = {state: 1 << index[state] for state in states} + for s in range(LOW, TOP): + nxt = {} + for state, mask in current.items(): + for other in succ[s][state]: + if s == LOW and not weight3(other[0]): + continue + nxt[other] = nxt.get(other, 0) | mask + current = nxt + counts = {state: 0 for state in states} + end_index = {state: i for i, state in enumerate(layers[TOP])} + for end, mask in current.items(): + if (t2_mask >> end_index[end]) & 1 == 0: + continue + bit = 0 + left = mask + while left: + if left & 1: + counts[states[bit]] += 1 + left >>= 1 + bit += 1 + return counts + + +def lift_pairs(layers, succ, filtered, states): + """One explicit word for every filtered T2 joined pair, with a (0, 3) prefix.""" + t2_bits = [] + for index, state in enumerate(layers[TOP]): + if tuple(sorted(diag_sum(state))) == T2: + t2_bits.append(index) + lifts = 0 + for start in states: + mask = filtered[LOW][start] + q = start[0] + heavy = q.index(C) + singles = [i for i, value in enumerate(q) if value == 1] + prefix = (singles[0], singles[1], heavy, heavy, heavy, heavy, heavy, heavy) + for bit in t2_bits: + if (mask >> bit) & 1 == 0: + continue + chain = [start] + state = start + for s in range(LOW, TOP): + nxt = [y for y in succ[s][state] if filtered[s + 1][y] & (1 << bit)] + require(nxt, "path stuck at s=%d" % s) + state = nxt[0] + chain.append(state) + word = chain_to_word(chain, prefix) + check_window(word, True, True) + require(counts(word, LOW) == chain[0][0], "lift q8") + require(counts(word, PAIR_SUM - LOW) == chain[0][1], "lift q31") + require(counts(word, TOP) == chain[-1][0], "lift q18") + require(counts(word, PAIR_SUM - TOP) == chain[-1][1], "lift q21") + lifts += 1 + require(lifts == 720, "lifts %d" % lifts) + return lifts + + +def chain_to_word(chain, prefix): + """Lift a state path. Prefix order is the only free data inside q_8.""" + word = [None] * LENGTH + for pos, letter in enumerate(prefix): + word[pos] = letter + for offset in range(TOP - LOW): + s = LOW + offset + q, t = chain[offset] + q2, t2 = chain[offset + 1] + early = [j for j in range(K) if q2[j] != q[j]] + late = [j for j in range(K) if t2[j] != t[j]] + require(len(early) == 1 and len(late) == 1, "step letters") + word[s] = early[0] + word[38 - s] = late[0] + qf, tf = chain[-1] + pos = TOP + for letter in range(K): + for _ in range(tf[letter] - qf[letter]): + word[pos] = letter + pos += 1 + require(pos == 21, "middle fill %d" % pos) + _q0, t0 = chain[0] + pos = PAIR_SUM - LOW + for letter in range(K): + for _ in range(C - t0[letter]): + word[pos] = letter + pos += 1 + require(pos == LENGTH and all(x is not None for x in word), "word has holes") + return word + + +def check_sources(): + sources = json.loads((PKG / "SOURCES.json").read_text(encoding="utf-8")) + checked = 0 + for row in sources["files"]: + if row["usage"] != "input": + continue + data = (ROOT / row["path"]).read_bytes() + require(hashlib.sha256(data).hexdigest() == row["sha256"], "pin " + row["path"]) + text = data.decode("utf-8") + for anchor in ("{0,1,6,7,12}", "weight-3 mask", "333333012000001111122222444444555555"): + require(anchor in text, "anchor missing in " + row["path"]) + checked += 1 + require(checked == 1, "expected one live input") + return checked + + +def check_controls(layers, states): + """Meaningful failures: order, a chain that misses (0, 9), and malformed words.""" + heavy, low, first, second, third, fourth = 0, 1, 2, 3, 4, 5 + bad_prefix = (heavy, heavy, heavy, heavy, heavy, heavy, first, second) + bad = build_word(heavy, low, first, second, third, fourth, (first, second, heavy)) + for pos, letter in enumerate(bad_prefix): + bad[pos] = letter + check_window(bad, False, True) + require(not weight3(counts(bad, 3)), "bad prefix became weight-3 at (0,3)") + require(tuple(bad[:LOW]).count(heavy) == C, "bad prefix changed the counts") + + cited_09 = [int(ch) for ch in CITED_09] + check_window(cited_09, True, True) + cited_t2 = [int(ch) for ch in CITED_T2] + check_window(cited_t2, True, False) + require(not weight3(counts(cited_t2, MID)), "cited T2 word became weight-3 at (0,9)") + require(tuple(sorted(counts(cited_t2, MID))) == (0, 0, 0, 1, 2, 6), "cited q9 shape") + q8 = counts(cited_t2, LOW) + q31 = counts(cited_t2, PAIR_SUM - LOW) + require((q8, q31) in set(states), "cited T2 word leaves the 180 states") + + require(rejects(CANONICAL[:-1]), "35 letters accepted") + require(rejects(CANONICAL[:-1] + CANONICAL[0]), "a seventh copy accepted") + stray = (6, 2, 0, 0, 0, 0), (6, 6, 6, 6, 6, 1) + require(stray not in set(layers[LOW]), "a q-shape outside the census was enumerated") + readme = (PKG / "README.md").read_text(encoding="utf-8") + for text in (CANONICAL, CITED_09, CITED_T2): + require(text in readme, "README lacks a witness") + l0 = sum(1 for state in layers[LOW] if lows(state) == 0) + l_high = sum(1 for state in layers[LOW] if lows(state) > 1) + require(l0 == 3420 and l_high == 0, "s=8 low profile %d %d" % (l0, l_high)) + return 7, l0 + + +def run(): + inputs = check_sources() + require(len(column_options()) == 10, "column options") + rows = parameters() + states = [state_of(h, low, a, b) for h, low, a, b, _c, _d in rows] + require(len(rows) == 180 and len(set(states)) == 180, "parameter count") + for state in states: + require(weight3(diag_sum(state)) and lows(state) == 1, "formula state") + require(tuple(sorted(state[0])) == (0, 0, 0, 1, 1, 6), "formula q") + require(tuple(sorted(diag_sum(state))) == START_S, "formula S") + prefixes, favorable = prefix_census(states) + constructed = check_construction(rows) + layers, succ, _steps = build_graph() + require(set(states) == {s for s in layers[LOW] if lows(s) == 1}, "formula misses a one-low state") + no_t2_at_8 = [s for s in layers[LOW] if tuple(sorted(diag_sum(s))) == T2] + require(no_t2_at_8 == [], "T2 multiset occurs at s=8") + masks = family_data(layers) + filtered, joined_t2, joined_other, forward = endpoint_relation(layers, succ, states, masks) + lifts = lift_pairs(layers, succ, filtered, states) + controls, l0 = check_controls(layers, states) + print( + "PASS_SIX_SOURCE_C6_PREFIX_PAIR_03 l1=%d prefixes=%d favorable=%d constructed=%d " + "lifts=%d joined_t2=%d joined_other=%d forward=%d layer8=%d l0=%d controls=%d inputs=%d" + % (len(states), prefixes, favorable, constructed, lifts, joined_t2, joined_other, + forward, len(layers[LOW]), l0, controls, inputs) + ) + return 0 + + +if __name__ == "__main__": + sys.exit(run())