From 9e7420c31a298de2bd2273a21434836ab9dfbc18 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 10 Nov 2026 09:53:43 +0000 Subject: [PATCH 1/2] Record that the intersection-counter engine returns the D6 16-word set. At batch size 16 the opt-in engine matches the weight-at-most-2 words of the pinned 20-generator D6 frame code. The support hash is unchanged and the selected conditional exponent is not. Co-authored-by: unpaidmoon --- .../d6-intersection-counter-support/README.md | 212 ++++++++ .../SOURCES.json | 36 ++ .../d6-intersection-counter-support/TASK.json | 67 +++ .../VERIFY.json | 34 ++ .../d6-intersection-counter-support/verify.py | 479 ++++++++++++++++++ 5 files changed, 828 insertions(+) create mode 100644 research/d6-intersection-counter-support/README.md create mode 100644 research/d6-intersection-counter-support/SOURCES.json create mode 100644 research/d6-intersection-counter-support/TASK.json create mode 100644 research/d6-intersection-counter-support/VERIFY.json create mode 100644 research/d6-intersection-counter-support/verify.py diff --git a/research/d6-intersection-counter-support/README.md b/research/d6-intersection-counter-support/README.md new file mode 100644 index 0000000000..30ececeaf2 --- /dev/null +++ b/research/d6-intersection-counter-support/README.md @@ -0,0 +1,212 @@ +# The intersection-counter engine returns the D6 16-word set + +**Exhaustive finite comparison on one basis, at one batch size. No new κ.** +The selected conditional exponent stays `781451/250000000`. On the pinned +20-generator kernel of the D6 6-frame incidence code, +`research/e7-intersection-counters/engine.py` at batch size 16 returns the +same 16 words as the literal span. The SHA256 of the 15 positive words is +`23a7b374a6bc62bc2aca47843d52a01fa8e791ed3a98085133829d816c5094e8`. + +## Result + +The lines and the two anchors are the D6 unit in +`research/d6-punctured-frame-code/ROOTS.json`. The anchors are the orthogonal +E8 lines `(2, 2, 0, 0, 0, 0, 0, 0)` and `(2, -2, 0, 0, 0, 0, 0, 0)`. The +stored lines are exactly the E8 lines orthogonal to both anchors, and they +equal the coordinate lines `±2e_i ± 2e_j` on axes `2, 3, 4, 5, 6, 7`. The +line-list SHA256, of the JSON array with no extra spaces, is +`bd3d7efd8a94a7d0a6a7339cfd95805bb6907f3951ff67e9669b317655869538`. + +An orthogonal 6-frame is the both-sign lift of a perfect matching of those +six axes. There are 15 such frames. The F2 incidence matrix has rank 10. A +kernel basis with an identity on the free coordinates + +```text +(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 12, 13, 14, 15, 16, 20, 21, 22, 23, 24) +``` + +is orthogonal to every frame row. That basis is these twenty integers, in +free-coordinate order: + +```text +101451777 +101451778 +1007553540 +168428552 +168428560 +1007553568 +2112 +1152 +772279552 +772279808 +528384 +270336 +147456 +504266752 +504299520 +537919488 +270532608 +138412032 +75497472 +50331648 +``` + +Ten of these generators have weight 2, so they already lie in the +weight-at-most-2 set. The other ten generators are heavier and lie in the +span outside that set. A binary-reflected Gray walk visits each of the +`2^20 = 1048576` codewords once. At step `index` the flipped generator is +the lowest set bit of `index`, and the coefficient vector is +`index XOR (index >> 1)`. The free coordinates of the running word are +checked against that coefficient at every index. Because those coordinates +are an identity basis, the coefficient is the unique preimage of the word, +the Gray map is bijective, and the walk is a complete enumeration of the +span. The words of weight at most 2 are zero and exactly these 15 supports, +and no nonzero word in that subset is lighter: + +```text +3, 24, 36, 768, 1152, 2112, 98304, 147456, 270336, 528384, +50331648, 75497472, 138412032, 270532608, 537919488 +``` + +Five of those supports are proper sums: they are not among the twenty +generators. The support hash is SHA256 of the UTF-8 bytes of +`json.dumps(sorted(positive_words))`, with the default separators. Both the +literal census and the engine stream produce +`23a7b374a6bc62bc2aca47843d52a01fa8e791ed3a98085133829d816c5094e8`. + +The engine call is `low_weight_words` from +`research/e7-intersection-counters/engine.py`, with `population_planes` and +`at_most` injected from `research/e7-bitsliced-exhaustion/binary.py`. Those +two helpers are the engine's required weight routines. The comparison does +not call that file's `low_weight_words`; a direct call with the injected +keywords raises `TypeError`. The stream below is one call at batch size 16, +width 30, and weight bound 2. + +| Quantity | Value | +|---|---:| +| Lines | 30 | +| Orthogonal 6-frames | 15 | +| Incidence rank | 10 | +| Kernel dimension | 20 | +| Distinct codewords | 1048576 | +| Batch size | 16 | +| Lane generators | 16 | +| High-offset batches | 16 | +| High generators outside the lane span | 4 | +| Engine stream | 16 distinct words | +| Words of weight 2 | 15 | +| Words of weight at most 2 | 16 | +| Weight-2 generators | 10 | +| Supports that are proper sums | 5 | +| Set equality | yes | +| Positive-word SHA256 | `23a7b374…6c5094e8` | + +Batch size 16 puts the first 16 generators in one lane block. The pinned +engine then walks every offset in the span of the remaining 4 generators: +its loop bound is `1 << (len(rows) - count)`, which is 16 on this input. +Those four generators each have weight 2, and each lies outside the +65536-word span of the first 16, so each is a target word that a lane-only +pass cannot emit. The literal Gray walk already lists every codeword. The +engine stream equals that weight-filtered set, with no repeated yield. The +Gray walk is an exhaustive finite census of this 1048576-word span. The +engine result is equality of its 16 yielded words with the weight-at-most-2 +subset, at batch size 16. It is a comparison of one finite input. It does +not decide another batch size or another code. + +Removing the least positive word makes the sets unequal and changes the +hash. Passing the first generator twice raises `ValueError` with the +engine's message `dependent generators`. Batch size 3 leaves 17 high +generators. The engine raises `ValueError` with the message +`batch count exceeds 65536` before yielding a word. That is one refusal +control. The legal batch sizes other than 16 were not compared. + +## Scope + +Task card `replay-runtime`, priority revision 8, base +`17469fff78c22941280f04d39dc5a1faee09c840`. Scope status is **refined**. + +The card asks for a measured speedup that keeps coverage. The revision-8 +verification row requires the sets to be compared before a faster replay +counts as the same coverage. The merged package +`research/e7-intersection-counters` times the complete E7 consumer and +states that other codes are outside its claim. The predecessor comparison +on this D6 code binds `low_weight_words` from +`research/e7-bitsliced-exhaustion/binary.py` and leaves this engine unrun. +This package runs that engine on the twenty generators above. + +The selected record at this base is `781451/250000000`. The priorities page +on the same base still prints the older PR #5599 decimal. This package uses +the selected record and does not change it. No timing is recorded, and the +comparison is not a speedup claim. The 27-dimensional E7 census is not +replayed. The bit-lane D6 census, the E6 64-word hash +`ad4a1d101774e6c2da40cde3d097d39aa56ee5668dcdca858513c5fec3578215`, and the +P112 8-word set are different comparisons and are outside this one. + +Ordered overlap check on 2026-11-10, after fetching canonical `main` at +`17469fff78c22941280f04d39dc5a1faee09c840`. GitHub search of open pull +requests for the support hash and for a 20-generator intersection-counter +comparison returned no D6 engine comparison. Open PR #7034 records that the +same engine refuses the P112 36-generator basis, because that dimension +exceeds 27. This basis has dimension 20, the engine accepts it, and the +yielded set is the 16-word set above. Merged #6959 is the bit-lane +comparison that states this hash and leaves the engine unrun. Merged #6960 +is the E6 64-word engine comparison. The last 25 top-level comments on +discussion #1166, through 2026-11-09, do not mention this hash. A repository +code search was rate-limited and was not used. No fork `cursor/*` branch +named this D6 engine comparison before this one. The predecessor D6 branch, +the E6 engine branch, and the P112 engine branch are different questions. + +## Reproduce + +Python 3.12 and the standard library, from the repository root. The census +is 1048576 codewords and finishes in well under a second. + +```sh +python3 -B scripts/research_package.py --package research/d6-intersection-counter-support --check-only +python3 -I -B research/d6-intersection-counter-support/verify.py +python3 -I -O -B research/d6-intersection-counter-support/verify.py +python3 -B scripts/research_package.py --package research/d6-intersection-counter-support +``` + +The direct verifier prints + +```text +PASS_D6_INTERSECTION_COUNTER_SUPPORT batch=16 words=16 supports=15 hash=23a7b374a6bc62bc2aca47843d52a01fa8e791ed3a98085133829d816c5094e8 equal=True e7_census=false bit_lane_census=false timed=false no_new_kappa=true +``` + +Checked here: normal and optimized direct runs, metadata check, and the +registered package runner. The selected-baseline script, the E7 census, the +bit-lane D6 census, Lean, Docker, and any timing harness were not run. + +## Open next questions + +1. Does the same set equality hold at another legal batch size on this + 20-generator basis, for example 8 or 20? Batch size changes the lane + split, so batch size 16 does not decide it. First rerun this comparison + with `batch_bits` 8, or 20, and the same twenty generators, weight bound, + and support hash. Nothing mathematical blocks that rerun. This package + stops after batch size 16. Batch size 3 is refused before any yield, so + it is not a second comparison. + +2. Can this opt-in engine be installed at a caller that consumes the D6 + 6-frame code, with regenerated source pins? Set equality on one code + leaves that replacement untouched. The first step is the installation + and source-bound compatibility check already stated by + `research/e7-intersection-counters`. This comparison does not regenerate + consumer pins. Other codes are outside that package's claim. + +## Credit + +The D6 lines, the orthogonal anchors, and the 15-word support hash are the +predecessor comparison in `research/d6-punctured-frame-code`, merged as PR +#6959. The intersection-counter engine is Nick Petalas's +`research/e7-intersection-counters/engine.py`. The injected population and +threshold routines are Ali Romman's PR #5729, +`research/e7-bitsliced-exhaustion/binary.py`. The request to run this engine +on the 20-generator basis is open question 3 of that D6 package. The E6 +engine comparison in merged PR #6960 is the pattern for this check and is a +different code. Open PR #7034 records the engine's refusal of the P112 +36-generator basis and is not rerun here. + +Prepared by unpaidmoon with substantial Cursor Grok assistance. Apache-2.0. +No independent human review and no formal-kernel acceptance are claimed. diff --git a/research/d6-intersection-counter-support/SOURCES.json b/research/d6-intersection-counter-support/SOURCES.json new file mode 100644 index 0000000000..30a3e20ca3 --- /dev/null +++ b/research/d6-intersection-counter-support/SOURCES.json @@ -0,0 +1,36 @@ +{ + "schema_version": 1, + "base_commit": "17469fff78c22941280f04d39dc5a1faee09c840", + "files": [ + { + "path": "certificates/selected-result.json", + "usage": "provenance", + "git_blob": "d59b5035e7b4cbaa9d688a1d32dd0d6eb79c466a", + "sha256": "9b8d0eea95b3bf0dfcb7938a732a6439b87a2685dec2a5ab9e525b3b34debbfa" + }, + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "3404fbdd5e7529a0674eef26114b5071e4586cec", + "sha256": "ead6cdc9d0af6d58e8a49744d8ec8c7c15e13d2ba93c276c434bcf9b51b93a81" + }, + { + "path": "research/d6-punctured-frame-code/ROOTS.json", + "usage": "input", + "git_blob": "fbc83ffee8ed6092001bb0f4c2bbde4158340a08", + "sha256": "8c2722cefafd7d12a8baf969b7c05ce991b3d3b5a35ca5a78a521da11082059d" + }, + { + "path": "research/e7-bitsliced-exhaustion/binary.py", + "usage": "input", + "git_blob": "cad9fc43ec0244bce415a76bc61b6445ffbd7519", + "sha256": "e79ad4d1d4be1748cf09aacc4274a316000d4b5922f13495778892b9309dc56e" + }, + { + "path": "research/e7-intersection-counters/engine.py", + "usage": "input", + "git_blob": "0283d450aee499682b0fd0ed0585e6d98085ef8a", + "sha256": "882d0177e990b0534bb16ec188a622b6167051505bdb5a7b19b4462499a72e47" + } + ] +} diff --git a/research/d6-intersection-counter-support/TASK.json b/research/d6-intersection-counter-support/TASK.json new file mode 100644 index 0000000000..d1d604eea3 --- /dev/null +++ b/research/d6-intersection-counter-support/TASK.json @@ -0,0 +1,67 @@ +{ + "schema_version": 1, + "task_id": "replay-runtime", + "priority_revision": 8, + "base_commit": "17469fff78c22941280f04d39dc5a1faee09c840", + "original_card": { + "id": "replay-runtime", + "question": "Can one measured replay bottleneck be sped up without dropping coverage?", + "starting_points": [ + "scripts/run_isolated_tests.py", + "scripts/verify_replay_coverage.py", + "certificates/selected-result.json" + ], + "methods": [ + "Profile one isolated replay and optimize the measured bottleneck.", + "Design source-bound reuse with explicit dependency invalidation and negative controls." + ], + "acceptance_gate": "Report before/after wall time on the same fixture, retained checks and invalidation behavior.", + "first_step": { + "command": [ + "python3", + "-B", + "scripts/research_selected_baseline.py" + ], + "expected": "PASS_RESEARCH_BASELINE_BINDINGS_ONLY", + "inspect": "Resolve the current selected review, separate complex/ordinary BIT/admitted BIT/outer budgets, and compare the card against live handoffs before starting. Historical ceilings require exact source/model equivalence.", + "scope": "Source-binding orientation only; not a scientific replay or all-size proof. Materialize selected inputs if this checkout is sparse." + }, + "first_experiment": "Measure one unchanged fixture, preserve check coverage, and test one optimization with invalidation controls.", + "bottleneck_link": "Faster trustworthy replays increase review throughput and let mechanism candidates be checked sooner.", + "allowed_variations": [ + "Profile one stage or design one source-bound cache boundary." + ], + "scope_change_triggers": [ + "Skipping coverage or comparing different fixtures to claim speedup." + ], + "overlap_terms": [ + "replay runtime", + "cache invalidation", + "isolated tests" + ] + }, + "scope_status": "refined", + "actual_scope": "Does research/e7-intersection-counters/engine.py, at batch size 16, return the same 16-word set as the weight-at-most-2 words of this D6 20-generator basis, with support hash 23a7b374a6bc62bc2aca47843d52a01fa8e791ed3a98085133829d816c5094e8?", + "scope_change_reason": "The replay-runtime card asks for a measured speedup that keeps coverage. Priority revision 8 says faster output is equivalent coverage only after the sets are compared. The merged D6 package binds the bit-lane enumerator on this 20-generator basis and leaves the intersection-counter engine unrun. The merged E6 package runs that engine on a different 7-generator basis and a different hash. This package answers the set question on the pinned D6 basis at batch size 16. It records no timing and leaves the selected conditional exponent unchanged.", + "bottleneck_link": "Decoder and deletion certificates can reuse a faster iterator only when that iterator still returns every low-weight word of the code being certified. This comparison binds the opt-in intersection-counter engine to the D6 16-word support set. It does not change a supplier bill or the selected conditional exponent.", + "budget_minutes": 60, + "stop_rule": "Stop after one set comparison of engine.py at batch size 16 against the literal span of this 20-generator kernel. Do not time the engine, rerun the bit-lane D6 census, rerun the E6 64-word comparison, or call the engine on a P112 basis.", + "outcome": "completed", + "evidence": "On the 30 D6 lines stored as the complement of the pinned orthogonal E8 pair, the 15 orthogonal 6-frames have F2 incidence rank 10. The kernel basis with identity on the free coordinates (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 12, 13, 14, 15, 16, 20, 21, 22, 23, 24) is the twenty integers listed in verify.py. A binary-reflected Gray walk visits all 1048576 codewords, checking that free-coordinate identity at every index. The words of weight at most 2 are zero and the 15 pinned supports. The SHA256 of those 15 words, as a default JSON list, is 23a7b374a6bc62bc2aca47843d52a01fa8e791ed3a98085133829d816c5094e8. At batch size 16 the intersection-counter stream is those 16 words with no duplicate yield. Ten generators already have weight 2; the other five supports are proper sums. The last four generators lie outside the span of the first sixteen and are themselves supports, so the sixteen high offsets are part of this batch. Removing the least positive word changes the set and the hash. A repeated generator is rejected with the engine message dependent generators. Batch size 3 is rejected with the engine message batch count exceeds 65536.", + "author": "unpaidmoon", + "ai_assistance": "Substantial Cursor Grok assistance.", + "open_questions": [ + { + "question": "Does the same set equality hold at another legal batch size on this 20-generator basis, for example 8 or 20?", + "why_it_matters": "Batch size changes the engine's lane split. Equality at batch size 16, with 16 lane generators and 16 high-offset batches, does not by itself decide batch size 8 or batch size 20.", + "first_step": "Rerun this comparison with batch_bits set to 8, or to 20, and the same twenty generators, weight bound 2, and support hash.", + "blocked_by": "Nothing mathematical blocks that rerun. This package stops after batch size 16. Batch size 3 is refused by the engine before any yield, so it is not a second comparison." + }, + { + "question": "Can this opt-in engine be installed at a caller that consumes the D6 6-frame code, with regenerated source pins?", + "why_it_matters": "Set equality on one code leaves production replacement and its dependent pins untouched.", + "first_step": "Name one caller boundary and perform the installation and source-bound compatibility check already stated by research/e7-intersection-counters.", + "blocked_by": "That package records production installation as a separate step, and other codes are outside its claim. This comparison does not regenerate consumer pins." + } + ] +} diff --git a/research/d6-intersection-counter-support/VERIFY.json b/research/d6-intersection-counter-support/VERIFY.json new file mode 100644 index 0000000000..368ec27b7c --- /dev/null +++ b/research/d6-intersection-counter-support/VERIFY.json @@ -0,0 +1,34 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [ + "research/d6-punctured-frame-code/ROOTS.json", + "research/e7-bitsliced-exhaustion/binary.py", + "research/e7-intersection-counters/engine.py" + ], + "commands": [ + { + "argv": [ + "{python}", + "-I", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 60, + "checks": "Rebuild the D6 6-frame kernel on the pinned 30 lines, require the twenty generator integers and support hash 23a7b374a6bc62bc2aca47843d52a01fa8e791ed3a98085133829d816c5094e8, and compare one intersection-counter stream at batch size 16 with that 16-word set. Reject a dropped support, a repeated generator, and batch size 3." + }, + { + "argv": [ + "{python}", + "-I", + "-O", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 60, + "checks": "Repeat the same batch-size-16 set comparison under optimized bytecode. The checks are ValueError guards, so optimization does not disable them." + } + ] +} diff --git a/research/d6-intersection-counter-support/verify.py b/research/d6-intersection-counter-support/verify.py new file mode 100644 index 0000000000..e3c1e3f521 --- /dev/null +++ b/research/d6-intersection-counter-support/verify.py @@ -0,0 +1,479 @@ +#!/usr/bin/env python3 +"""Compare the opt-in intersection-counter engine with one D6 support set. + +The 20-generator basis is the F2 kernel of the 15 orthogonal 6-frames on the +30 stored D6 lines from research/d6-punctured-frame-code. A binary-reflected +Gray walk lists every codeword of that span. The engine is then called once, +at batch size 16, and its yielded words are compared with the weight-at-most-2 +subset. The bit-lane enumerator is not called. No timing and no E7 census. +""" + +import inspect +import json +from functools import partial +from hashlib import sha256 +from itertools import combinations, product +from pathlib import Path +from runpy import run_path + +HERE = Path(__file__).resolve().parent +ROOT = HERE.parents[1] +WIDTH = 30 +FRAME_SIZE = 6 +DIMENSION = 20 +RANK = 10 +FRAME_COUNT = 15 +WEIGHT_BOUND = 2 +SUPPORT_COUNT = 15 +WORD_COUNT = 16 +BATCH_BITS = 16 +LANE_GENERATORS = 16 +HIGH_OFFSET_BATCHES = 16 +AXES = (2, 3, 4, 5, 6, 7) +ANCHORS = ((2, 2, 0, 0, 0, 0, 0, 0), (2, -2, 0, 0, 0, 0, 0, 0)) +FREE_COORDINATES = ( + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 12, 13, 14, 15, 16, 20, 21, 22, 23, 24, +) +GENERATORS = ( + 101451777, + 101451778, + 1007553540, + 168428552, + 168428560, + 1007553568, + 2112, + 1152, + 772279552, + 772279808, + 528384, + 270336, + 147456, + 504266752, + 504299520, + 537919488, + 270532608, + 138412032, + 75497472, + 50331648, +) +SUPPORTS = ( + 3, + 24, + 36, + 768, + 1152, + 2112, + 98304, + 147456, + 270336, + 528384, + 50331648, + 75497472, + 138412032, + 270532608, + 537919488, +) +LINES_SHA256 = "bd3d7efd8a94a7d0a6a7339cfd95805bb6907f3951ff67e9669b317655869538" +SUPPORT_SHA256 = ( + "23a7b374a6bc62bc2aca47843d52a01fa8e791ed3a98085133829d816c5094e8" +) +JSON_LIST_SHA256 = ( + "3a316d6d3226f84c1e46e4447fa8d5fd800bff4a1bc6498152523cd4a602b69b" +) + + +def need(condition, message): + if not condition: + raise ValueError(message) + + +def authenticate(): + sources = json.loads((HERE / "SOURCES.json").read_text(encoding="utf-8")) + checked = 0 + for row in sources["files"]: + if row["usage"] != "input": + continue + path = ROOT / row["path"] + digest = sha256(path.read_bytes()).hexdigest() + need(digest == row["sha256"], "input hash mismatch: " + row["path"]) + checked += 1 + need(checked == 3, "three live inputs") + return checked + + +def support_hash(words): + """SHA256 of the sorted positive words, as a default JSON list.""" + positive = sorted(word for word in words if word) + payload = json.dumps(positive).encode() + return sha256(payload).hexdigest(), positive + + +def dot(left, right): + return sum(a * b for a, b in zip(left, right)) + + +def canon(vector): + first = next(value for value in vector if value) + return tuple(vector) if first > 0 else tuple(-value for value in vector) + + +def e8_lines(): + roots = [] + for i, j in combinations(range(8), 2): + for sign in (2, -2): + root = [0] * 8 + root[i], root[j] = 2, sign + roots.append(canon(root)) + for tail in product((1, -1), repeat=7): + root = (1,) + tail + if root.count(-1) % 2 == 0: + roots.append(root) + need(len(roots) == len(set(roots)) == 120, "E8 line count") + need(all(dot(root, root) == 8 for root in roots), "E8 norms") + return set(roots) + + +def coordinate_lines(axes): + lines = [] + for i, j in combinations(axes, 2): + for sign in (2, -2): + root = [0] * 8 + root[i], root[j] = 2, sign + lines.append(canon(root)) + lines = tuple(sorted(set(lines))) + need(len(lines) == WIDTH, "coordinate D6 line count") + return lines + + +def load_lines(): + payload = json.loads( + (ROOT / "research/d6-punctured-frame-code/ROOTS.json").read_text( + encoding="utf-8" + ) + ) + anchors = tuple(tuple(anchor) for anchor in payload["anchors"]) + axes = tuple(payload["axes"]) + stored = tuple(tuple(line) for line in payload["lines"]) + need(anchors == ANCHORS, "pinned anchors changed") + need(axes == AXES, "pinned axes changed") + need(len(stored) == len(set(stored)) == WIDTH, "pinned line count") + digest = sha256( + json.dumps( + [list(line) for line in stored], separators=(",", ":") + ).encode() + ).hexdigest() + need(digest == LINES_SHA256, "pinned line hash changed") + roots = e8_lines() + need(all(anchor in roots for anchor in anchors), "anchor is not an E8 line") + need(dot(*anchors) == 0, "anchors are not orthogonal") + complement = tuple( + sorted( + root + for root in roots + if all(dot(root, anchor) == 0 for anchor in anchors) + ) + ) + coordinate = coordinate_lines(axes) + need(stored == complement == coordinate, "pinned lines are not this D6 slice") + return stored + + +def perfect_matchings(vertices): + vertices = tuple(vertices) + if not vertices: + yield () + return + first, rest = vertices[0], vertices[1:] + for index, partner in enumerate(rest): + remaining = rest[:index] + rest[index + 1 :] + for tail in perfect_matchings(remaining): + yield ((first, partner),) + tail + + +def support_of(line): + return tuple(index for index, value in enumerate(line) if value) + + +def combinatorial_frames(lines): + lookup = {line: index for index, line in enumerate(lines)} + frames = [] + for matching in perfect_matchings(AXES): + chosen = [] + for i, j in matching: + for sign in (2, -2): + root = [0] * 8 + root[i], root[j] = 2, sign + chosen.append(lookup[canon(root)]) + frames.append(tuple(sorted(chosen))) + frames = tuple(sorted(set(frames))) + need(len(frames) == FRAME_COUNT, "perfect-matching frame count") + for frame in frames: + need(len(frame) == FRAME_SIZE, "frame length") + need( + all(dot(lines[i], lines[j]) == 0 for i, j in combinations(frame, 2)), + "matching frame is not orthogonal", + ) + covered = [] + for index in frame: + covered.extend(support_of(lines[index])) + need( + sorted(covered) == sorted(AXES + AXES), + "a frame does not use both signs on three edges", + ) + return frames + + +def kernel(rows): + echelon = {} + for row in rows: + for pivot in range(WIDTH - 1, -1, -1): + if row >> pivot & 1: + if pivot in echelon: + row ^= echelon[pivot] + else: + echelon[pivot] = row + break + free = tuple(j for j in range(WIDTH) if j not in echelon) + need(len(echelon) == RANK and free == FREE_COORDINATES, "D6 frame-code rank") + basis = [] + for index, coordinate in enumerate(free): + vector = 1 << coordinate + for pivot in sorted(echelon): + if (echelon[pivot] & vector).bit_count() % 2: + vector |= 1 << pivot + need(0 < vector < 1 << WIDTH, "kernel vector outside F_2^30") + pattern = tuple((vector >> place) & 1 for place in free) + identity = tuple(int(place == index) for place in range(DIMENSION)) + need(pattern == identity, "free coordinates are not a basis identity") + need( + all((vector & row).bit_count() % 2 == 0 for row in rows), + "a frame parity survives", + ) + basis.append(vector) + return tuple(basis) + + +def span(generators): + words = [0] + for generator in generators: + # Snapshot the current list. A live generator would follow new words. + words.extend([word ^ generator for word in words]) + need(len(set(words)) == len(words) == 1 << len(generators), "span repeats a word") + return set(words) + + +def literal_low_weight(basis): + """Visit every span word once and keep those of weight at most 2. + + The bit flipped at step index is the lowest set bit of index. The + coefficient vector at that step is index XOR (index >> 1). The free + coordinates of the running word are checked against that Gray code at + every index. Those coordinates are an identity basis, so each of the + 2^20 coefficients occurs once. + """ + found = set() + word = 0 + limit = 1 << DIMENSION + for index in range(limit): + if index: + word ^= basis[(index & -index).bit_length() - 1] + gray = index ^ (index >> 1) + for place, coordinate in enumerate(FREE_COORDINATES): + need( + ((word >> coordinate) & 1) == ((gray >> place) & 1), + "Gray step left the free-coordinate identity", + ) + if word.bit_count() <= WEIGHT_BOUND: + found.add(word) + need(0 in found and len(found) == WORD_COUNT, "literal census is not 16 words") + positive = tuple(sorted(item for item in found if item)) + need(positive == SUPPORTS, "literal supports are not the pinned 15 words") + need( + all(item.bit_count() == WEIGHT_BOUND for item in positive), + "a lighter nonzero literal word", + ) + return found + + +def incidence_basis(): + lines = load_lines() + frames = combinatorial_frames(lines) + rows = tuple(sum(1 << index for index in frame) for frame in frames) + return kernel(rows) + + +def bind_engine(): + binary = run_path( + str(ROOT / "research/e7-bitsliced-exhaustion/binary.py"), + run_name="d6_population_helpers", + ) + engine_ns = run_path( + str(ROOT / "research/e7-intersection-counters/engine.py"), + run_name="d6_intersection_engine", + ) + engine = engine_ns["low_weight_words"] + signature = inspect.signature(engine) + for name in ("population_planes", "at_most"): + need( + signature.parameters[name].kind is inspect.Parameter.KEYWORD_ONLY, + name + " is not keyword-only on the intersection engine", + ) + try: + binary["low_weight_words"]( + (1,), + 1, + 0, + 1, + population_planes=binary["population_planes"], + at_most=binary["at_most"], + ) + except TypeError: + separated = True + else: + separated = False + need(separated, "the bit-lane enumerator accepted the intersection keywords") + return partial( + engine, + population_planes=binary["population_planes"], + at_most=binary["at_most"], + ) + + +def engine_words(engine, basis): + listed = list(engine(basis, WIDTH, WEIGHT_BOUND, BATCH_BITS)) + need( + len(listed) == len(set(listed)) == WORD_COUNT, + "engine stream is not 16 distinct words", + ) + produced = set(listed) + positive = tuple(sorted(word for word in produced if word)) + need(0 in produced and positive == SUPPORTS, "engine support list") + need( + all(word.bit_count() == WEIGHT_BOUND for word in positive), + "engine emitted a word whose weight is not 2", + ) + return produced + + +def reject_duplicate(engine, basis): + try: + list(engine((basis[0], basis[0]), WIDTH, WEIGHT_BOUND, BATCH_BITS)) + except ValueError as exc: + need(str(exc) == "dependent generators", "unexpected rejection: " + str(exc)) + return True + return False + + +def reject_small_batch(engine, basis): + """Batch size 3 leaves 17 high generators, past the engine's 16-offset cap. + + This is one refusal control. It does not survey the other batch sizes. + """ + try: + list(engine(basis, WIDTH, WEIGHT_BOUND, 3)) + except ValueError as exc: + need( + str(exc) == "batch count exceeds 65536", + "unexpected small-batch rejection: " + str(exc), + ) + return True + return False + + +def check(): + need( + sha256(json.dumps([1, 2]).encode()).hexdigest() == JSON_LIST_SHA256, + "JSON list encoding changed", + ) + authenticate() + basis = incidence_basis() + need(basis == GENERATORS, "kernel basis integers changed") + need(len(basis) == DIMENSION, "basis length") + weight_two = tuple(word for word in basis if word.bit_count() == WEIGHT_BOUND) + need(len(weight_two) == 10, "weight-2 generator count") + high = basis[LANE_GENERATORS:] + need(len(high) == DIMENSION - LANE_GENERATORS, "high-generator count") + lane_span = span(basis[:LANE_GENERATORS]) + need( + all(word.bit_count() == WEIGHT_BOUND and word not in lane_span for word in high), + "a high generator lies in the lane span or does not have weight 2", + ) + found = literal_low_weight(basis) + need(set(high) <= found, "a high generator is outside the low-weight set") + proper_sums = tuple(sorted(set(SUPPORTS) - set(basis))) + need(len(proper_sums) == 5, "the support set is only the weight-2 generators") + need(set(weight_two) <= set(SUPPORTS), "a weight-2 generator leaves the support set") + literal_hash, literal_positive = support_hash(found) + need(tuple(literal_positive) == SUPPORTS, "sorted literal supports moved") + need(literal_hash == SUPPORT_SHA256, "rebuilt support hash " + literal_hash) + lane_count = min(BATCH_BITS, DIMENSION) + high_batches = 1 << (DIMENSION - lane_count) + need( + lane_count == LANE_GENERATORS and high_batches == HIGH_OFFSET_BATCHES, + "batch 16 does not split this basis into 16 lanes and 16 high offsets", + ) + engine = bind_engine() + produced = engine_words(engine, basis) + engine_hash, _ = support_hash(produced) + missing = found - produced + extra = produced - found + need( + not missing and not extra, + "set mismatch missing={0} extra={1}".format(len(missing), len(extra)), + ) + need(engine_hash == SUPPORT_SHA256, "engine support hash " + engine_hash) + witness = min(word for word in produced if word) + dropped = produced - {witness} + dropped_hash, _ = support_hash(dropped) + need(dropped != found, "dropping one support still compared equal") + need(dropped_hash != SUPPORT_SHA256, "dropping one support kept the hash") + rejected = reject_duplicate(engine, basis) + need(rejected, "a repeated generator was accepted") + small_batch = reject_small_batch(engine, basis) + need(small_batch, "batch size 3 was accepted") + return { + "status": "PASS_D6_INTERSECTION_COUNTER_SUPPORT", + "width": WIDTH, + "frames": FRAME_COUNT, + "rank": RANK, + "dimension": DIMENSION, + "free_coordinates": list(FREE_COORDINATES), + "generators": list(basis), + "batch_bits": BATCH_BITS, + "lane_generators": lane_count, + "high_offset_batches": high_batches, + "literal_codewords": 1 << DIMENSION, + "weight_at_most_2": len(found), + "positive_supports": SUPPORT_COUNT, + "weight_2_generators": len(weight_two), + "high_generators_outside_lane_span": len(high), + "proper_sums": len(proper_sums), + "engine_stream_words": WORD_COUNT, + "sets_equal": produced == found, + "literal_supports_sha256": literal_hash, + "engine_supports_sha256": engine_hash, + "duplicate_generator_rejected": rejected, + "batch_3_rejected": small_batch, + "bit_lane_census_replayed": False, + "e7_census_replayed": False, + "p112_basis_checked": False, + "timing_measured": False, + "no_new_kappa": True, + } + + +if __name__ == "__main__": + result = check() + print( + "PASS_D6_INTERSECTION_COUNTER_SUPPORT" + " batch={batch_bits}" + " words={weight_at_most_2}" + " supports={positive_supports}" + " hash={engine_supports_sha256}" + " equal={sets_equal}" + " e7_census=false" + " bit_lane_census=false" + " timed=false" + " no_new_kappa=true".format(**result) + ) + print(json.dumps(result, indent=2, sort_keys=True)) From a8d3fd99d171503c1c39cd969aaeba1c2d4e41cf Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 10 Nov 2026 09:54:13 +0000 Subject: [PATCH 2/2] Record the source-history preflight in the D6 engine comparison. The committed-byte check passed on the package commit and belongs with the reproduction commands. Co-authored-by: unpaidmoon --- research/d6-intersection-counter-support/README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/research/d6-intersection-counter-support/README.md b/research/d6-intersection-counter-support/README.md index 30ececeaf2..ca9774e83a 100644 --- a/research/d6-intersection-counter-support/README.md +++ b/research/d6-intersection-counter-support/README.md @@ -166,6 +166,7 @@ python3 -B scripts/research_package.py --package research/d6-intersection-counte python3 -I -B research/d6-intersection-counter-support/verify.py python3 -I -O -B research/d6-intersection-counter-support/verify.py python3 -B scripts/research_package.py --package research/d6-intersection-counter-support +python3 -B scripts/check_research_commit.py --package research/d6-intersection-counter-support --check-source-history ``` The direct verifier prints @@ -174,9 +175,10 @@ The direct verifier prints PASS_D6_INTERSECTION_COUNTER_SUPPORT batch=16 words=16 supports=15 hash=23a7b374a6bc62bc2aca47843d52a01fa8e791ed3a98085133829d816c5094e8 equal=True e7_census=false bit_lane_census=false timed=false no_new_kappa=true ``` -Checked here: normal and optimized direct runs, metadata check, and the -registered package runner. The selected-baseline script, the E7 census, the -bit-lane D6 census, Lean, Docker, and any timing harness were not run. +Checked here: normal and optimized direct runs, metadata check, the +registered package runner, and the committed-byte source-history preflight. +The selected-baseline script, the E7 census, the bit-lane D6 census, Lean, +Docker, and any timing harness were not run. ## Open next questions