diff --git a/research/clean-connector-per-mask-seede54e/README.md b/research/clean-connector-per-mask-seede54e/README.md new file mode 100644 index 0000000000..ccd3464d8b --- /dev/null +++ b/research/clean-connector-per-mask-seede54e/README.md @@ -0,0 +1,86 @@ +# One clean connector for distinct five-source outputs + +**New root mechanism and local charged cost reduction; no new κ.** A fresh, explicitly zeroed length-16 row lets each of the 31 nonzero five-source masks use one output-map call. It trades many extra source updates for fewer expensive output updates while retaining pairwise-distinct output maps. + +## Contract and construction + +Let `x_0,...,x_4`, the original connector `z`, and targets `y_m` be distinct length-`L` rows over F2. Their initial contents are arbitrary. The maps `B_j` and `A_m` are exact linear maps and stay read-only. The requested result is + +```text +y_m += A_m(sum_{j in m} B_j x_j) for every nonzero 5-bit mask m. +``` + +Admit one extra row `c`. It is not presumed clean: allocate/host it, clear all `L` coordinates, and charge those writes. For each mask in order, do: + +```text +for each j in m: c += B_j x_j + y_m += A_m c +for each j in reverse order: c += B_j x_j +``` + +In characteristic two, the reverse source updates return `c` to zero. The next mask starts clean. The original dirty `z`, all sources, and all other targets are untouched. Each target receives exactly its requested additive update. This identity holds for arbitrary linear maps; it needs no commutation, invertibility, or relations among the maps. + +For all 31 masks, `sum popcount(m)=5*16=80`. The new schedule therefore uses 160 source updates and 31 output updates. As its named competitor, use the pinned five-source `five_extra_output` schedule in the universal connector certificate: 10 source updates and 64 output updates, with output 21 read four times and every other output twice. That schedule supports arbitrary distinct `A_m` and `B_j` in the unchanged dirty-connector alphabet. + +## Exact fixture and complete root bill + +Use `L=16`. Let each `B_j` be a distinct cyclic coordinate permutation. Define + +```text +A(v)[i] = sum_{k=0}^{12} v[(i+k) mod 16] over F2 +A_m = A Q_m +``` + +Choose 31 distinct coordinate permutations `Q_m` from `Q_(a,b)(v)[i] = v[(a*i+b) mod 16]`, with odd `a`. These are permutations. `A` is invertible: its polynomial has value 1 at `x=1`, and `x^16-1=(x+1)^16` over F2. Thus the `A_m` are pairwise distinct. Each output row of each `A_m` has exactly 13 taps. The verifier checks the rank and distinctness directly as well. + +The comparison uses one declared additive tariff. One unit is charged for each XOR update, stored table bit, hosted row coordinate, zero write, and scheduler descriptor. This is a transparent local model, not a physical hardware price. Let `a=208` XOR updates per `A_m` call, `b=16` per `B_j` call, and `d=13` per action/control descriptor. Source and target reads/writes and coefficient-index reads are included in the XOR-update units. Static map tables are charged separately. + +| Charge | Direct dirty-connector schedule | Fresh-row schedule | +|---|---:|---:| +| `B` updates | 10 | 160 | +| `A` updates | 64 | 31 | +| Per-action descriptors | `74d` | `191d` | +| Mask-block control descriptors | 0 | `31d` | +| Allocation/release descriptors | 0 | `2d` | +| Extra row hosting | 0 | `L` | +| Zero-initialization writes | 0 | `L` | + +Both schedules share 31 output-map tables, five source-map tables, and the existing data rows. The tables contain `31*16*13*4 + 5*16*4 = 26,112` address bits. The five sources, original connector and 31 targets use `37*16 = 592` row cells. Their shared charge is 26,704 units. The fresh-row schedule's 31 block descriptors are an additional conservative charge; each operation descriptor is also charged separately. + +The direct and candidate totals are therefore + +```text +direct = 26704 + 10*(b+d) + 64*(a+d) = 41138 +fresh row = 26704 + 160*(b+d) + 31*(a+d) + 31*d + 2*d + 2*L = 38656 +saving = 33*a - 150*b - 150*d - 2*L = 2482 +``` + +At this fixture, the saving is positive for integer `d <= 29`. The result is conditional on this explicit tariff and on the listed maps. If the output maps are cheap relative to source updates, the construction loses. The calculation is a root-interface comparison; it does not include a recursive supplier, child restoration, frame changes, precision conversion, or a κ integration. No universal optimality claim is made. + +## Reproduce and evidence + +From the repository root: + +```sh +python3 -B research/clean-connector-per-mask-seede54e/verify.py +python3 scripts/research_package.py --package research/clean-connector-per-mask-seede54e --check-only +python3 scripts/research_package.py --package research/clean-connector-per-mask-seede54e +``` + +Expected verifier line: + +```text +PASS_CLEAN_CONNECTOR_PER_MASK basis_columns=608 controls=13 masks=31 candidate_B=160 candidate_A=31 direct_B=10 direct_A=64 common=26704 direct_cost=41138 candidate_cost=38656 saving=2482 +``` + +The exact F2 replay checks all 592 data-bit basis columns across the five sources, original connector, and 31 targets; linearity establishes the data identity for every such state. It also checks each of the extra row's 16 pre-clear bit columns; the explicit reset clears the whole row regardless of its prior contents. A mixed nonbasis state is replayed as well. Four construction controls detect omitted initialization, omitted reverse updates, an omitted source update, and a misrouted target. Nine invoice controls remove each charged line in turn and ensure the exact invoice check rejects the undercharge. The verifier reads the exact direct schedule from the pinned certificate and checks its call multiplicities. Local replay used Python 3.14.7; registered CI is configured for Python 3.12. + +## Overlap and attribution + +The initial common-map variant was released after the refreshed scan found the stronger common-`A` broadcast in [PR #1707](https://github.com/CrocSwap/integer-mult-bounds/pull/1707), head `3d2e634e046ac4fbf07ddbfb0e59da4cf9907f4e`. This result keeps pairwise-distinct `A_m` and pays for a fresh row cleared separately for each batch. The broader neighborhood includes the atomic triple-sum construction in PR #1518, two-source DUO schedule in PR #1531, fixed-alphabet parity schedules in PR #1811, and paid invertible-frame analysis in PR #1915; none uses this clean-row tradeoff. The overlap scan is not a novelty certificate. Exact base, selected record, catalogue and predecessor source pins are in [SOURCES.json](SOURCES.json). + +Ross Richardson's universal connector interface and five-source schedule supply the direct comparator. No predecessor code is copied. Prepared by Cinna Davis with substantial OpenAI Codex assistance; Apache-2.0. + +## Open next questions + +The structured next question in [TASK.json](TASK.json) is whether this root saving survives nested composition when every child, restoration step, frame transition, and per-level descriptor is charged. The first step is to bind the row and map tariffs to one concrete recursive supplier and evaluate its full recurrence. That integration is currently blocked because this synthetic length-16 fixture has no compatible supplier implementation or recursive cost profile. diff --git a/research/clean-connector-per-mask-seede54e/SOURCES.json b/research/clean-connector-per-mask-seede54e/SOURCES.json new file mode 100644 index 0000000000..d0bad8f0d0 --- /dev/null +++ b/research/clean-connector-per-mask-seede54e/SOURCES.json @@ -0,0 +1,30 @@ +{ + "schema_version": 1, + "base_commit": "0b1cccf86e2f5132ed286a26ef0a681a495740ea", + "files": [ + { + "path": "certificates/selected-result.json", + "usage": "input", + "git_blob": "ae6a99f28aa468649eb66a361e764d769363bf11", + "sha256": "10b9e340fd8e354a37a0c4813c90e5de1dd42044b5f6aca4a3fc5a42b685fa32" + }, + { + "path": "docs/research/agent-task-catalog.json", + "usage": "provenance", + "git_blob": "06c96f5579bb67ed1b86d334e78fbed7da6945f1", + "sha256": "6686ad58f1fbdbc87134a78901b60fd53a20d3984355e91defbbebc9e9fa8075" + }, + { + "path": "research/universal-connector-boundary/CERTIFICATE.json", + "usage": "input", + "git_blob": "079e3e1441dc07c2f0536e9527acf290e51ea9c0", + "sha256": "e733746ba3e5151c829b4e8728bfff5ae3ed24d8d203eb77c735d20758e8266a" + }, + { + "path": "research/universal-connector-boundary/README.md", + "usage": "input", + "git_blob": "d277f7c5830b1f2bc42e1ff41ab86e7d7564929f", + "sha256": "23415f7829ab8d80a783142f10f7d31abbce84579362769984680af3df954476" + } + ] +} diff --git a/research/clean-connector-per-mask-seede54e/TASK.json b/research/clean-connector-per-mask-seede54e/TASK.json new file mode 100644 index 0000000000..7d0a7e74f4 --- /dev/null +++ b/research/clean-connector-per-mask-seede54e/TASK.json @@ -0,0 +1,60 @@ +{ + "schema_version": 1, + "task_id": "connector-alphabet-change", + "priority_revision": 3, + "base_commit": "0b1cccf86e2f5132ed286a26ef0a681a495740ea", + "original_card": { + "id": "connector-alphabet-change", + "question": "Does one explicit extension of the connector alphabet offer a favorable completed budget?", + "starting_points": [ + "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.", + "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." + ], + "overlap_terms": [ + "universal connector", + "source-toggle", + "connector alphabet" + ] + }, + "scope_status": "changed", + "actual_scope": "For the complete five-source, 31-mask batch with pairwise-distinct output maps, does admitting one length-16 connector that is explicitly zeroed and fully charged let per-mask source rebuilding lower the pinned 10-B/64-A dirty-connector schedule?", + "scope_change_reason": "The first refined common-map broadcast scope was already covered by the stronger charged common-A construction in open PR #1707. This changed scope retains distinct output maps and changes the connector contract by admitting exactly one fresh row whose initialization, hosting, scheduler controls, allocation, and release are charged.", + "bottleneck_link": "This tests whether a paid extra connector can exchange source-side work for fewer expensive output-map updates at the recursive interface. The result is a root tariff comparison only and does not establish a new supplier or kappa.", + "budget_minutes": 60, + "stop_rule": "Fix L=16, five cyclic-permutation source maps, 31 affine-permutation output maps, and the declared per-update/per-descriptor tariff. Stop after exact basis replay, four mutation controls, and the complete comparison with the pinned direct schedule; do not expand to other dimensions or tariffs in this cycle.", + "outcome": "completed", + "evidence": "python3 -B research/clean-connector-per-mask-seede54e/verify.py passes all 608 F2 bit-column checks, four construction controls, and nine invoice undercharge controls. It verifies pairwise-distinct output maps, the pinned 10-B/64-A comparator, and the complete scalar bill: 41,138 direct versus 38,656 with a fresh row, a 2,482-unit local saving. No kappa or recursive integration is claimed.", + "author": "Cinna Davis", + "ai_assistance": "OpenAI Codex provided substantial assistance with the construction analysis, cost derivation, verifier implementation, and package preparation.", + "open_questions": [ + { + "question": "Does the fresh-row source-rebuild schedule remain cheaper after nested composition, child restoration, frame changes, and per-level scheduling are charged?", + "why_it_matters": "The current 2,482-unit reduction is only a root comparison; recursive overhead may consume it before it changes a supplier moment or kappa.", + "first_step": "Choose one concrete recursive supplier whose source and output map costs match the fixture, then write and evaluate its complete recurrence including hosted rows and every reverse child.", + "blocked_by": "No compatible supplier implementation or recursive cost profile is currently bound to this synthetic length-16 map family." + } + ] +} diff --git a/research/clean-connector-per-mask-seede54e/VERIFY.json b/research/clean-connector-per-mask-seede54e/VERIFY.json new file mode 100644 index 0000000000..60b62859cb --- /dev/null +++ b/research/clean-connector-per-mask-seede54e/VERIFY.json @@ -0,0 +1,22 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [ + "certificates/selected-result.json", + "research/universal-connector-boundary/CERTIFICATE.json", + "research/universal-connector-boundary/README.md" + ], + "commands": [ + { + "argv": [ + "{python}", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 120, + "checks": "Exact F2 basis replay of all 608 source, dirty-row, target, and pre-clear scratch coordinates; four mutation controls; pairwise-distinct fixture maps; pinned direct schedule multiplicities; complete shared and incremental cost arithmetic." + } + ] +} diff --git a/research/clean-connector-per-mask-seede54e/verify.py b/research/clean-connector-per-mask-seede54e/verify.py new file mode 100644 index 0000000000..bc1a3a0982 --- /dev/null +++ b/research/clean-connector-per-mask-seede54e/verify.py @@ -0,0 +1,254 @@ +"""Exact F2 replay and fully charged local budget for one clean connector.""" + +from collections import Counter +import json +from pathlib import Path + +L = 16 +MASKS = tuple(range(1, 1 << 5)) + + +def require(ok, message): + if not ok: + raise RuntimeError(message) + + +def permute(word, row_to_input): + out = 0 + for row, col in enumerate(row_to_input): + out |= ((word >> col) & 1) << row + return out + + +def apply_a(word): + out = 0 + for row in range(L): + bit = 0 + for shift in range(13): + bit ^= (word >> ((row + shift) % L)) & 1 + out |= bit << row + return out + + +def gf2_rank(rows, width): + pivots = {} + for original in rows: + row = original + while row: + pivot = row.bit_length() - 1 + if pivot in pivots: + row ^= pivots[pivot] + else: + pivots[pivot] = row + break + return len(pivots) + + +def a_rows(): + return [sum(1 << ((row + shift) % L) for shift in range(13)) for row in range(L)] + + +def make_maps(): + b_maps = [tuple((i + shift) % L for i in range(L)) for shift in range(5)] + affine = [(a, b) for a in range(1, L, 2) for b in range(L)][:31] + q_maps = [tuple((a * i + b) % L for i in range(L)) for a, b in affine] + return b_maps, q_maps + + +B_MAPS, Q_MAPS = make_maps() + +EXPECTED_INVOICE = { + "shared_map_table_bits": 26112, + "shared_row_cells": 592, + "source_updates": 2560, + "output_updates": 6448, + "action_descriptors": 2483, + "mask_control_descriptors": 403, + "allocation_release_descriptors": 26, + "fresh_row_cells": 16, + "zero_writes": 16, +} + + +def invoice_valid(invoice): + return invoice == EXPECTED_INVOICE + + +def apply_output_map(word, output_index): + return apply_a(permute(word, Q_MAPS[output_index])) + + +def expected_deltas(sources): + deltas = [] + for mask in MASKS: + total = 0 + for j in range(5): + if (mask >> j) & 1: + total ^= permute(sources[j], B_MAPS[j]) + deltas.append(apply_output_map(total, mask - 1)) + return deltas + + +def execute(sources, dirty_connector, targets, fresh_connector, fault=None): + """Execute the candidate; fault values are verifier negative controls.""" + connector = fresh_connector + if fault != "omit-zeroing": + connector = 0 + out = list(targets) + for mask in MASKS: + selected = [j for j in range(5) if (mask >> j) & 1] + for j in selected: + if fault == "omit-first-source" and mask == 1 and j == 0: + continue + connector ^= permute(sources[j], B_MAPS[j]) + target_index = mask - 1 + if fault == "wrong-target" and mask == 1: + target_index = 1 + out[target_index] ^= apply_output_map(connector, mask - 1) + if fault != "omit-reverse": + for j in reversed(selected): + connector ^= permute(sources[j], B_MAPS[j]) + return list(sources), dirty_connector, out, connector + + +def verify_basis(): + checked = 0 + # 80 source bits, 16 original-connector bits, 496 target bits, 16 + # arbitrary pre-allocation scratch bits (cleared by the paid zeroing pass). + for column in range(38 * L): + sources = [0] * 5 + dirty_connector = 0 + targets = [0] * 31 + fresh_connector = 0 + if column < 5 * L: + row, bit = divmod(column, L) + sources[row] = 1 << bit + elif column < 6 * L: + dirty_connector = 1 << (column - 5 * L) + elif column < 37 * L: + row, bit = divmod(column - 6 * L, L) + targets[row] = 1 << bit + else: + fresh_connector = 1 << (column - 37 * L) + result = execute(sources, dirty_connector, targets, fresh_connector) + expected = [targets[i] ^ d for i, d in enumerate(expected_deltas(sources))] + require(result[0] == sources, "source row changed on basis column %d" % column) + require(result[1] == dirty_connector, "original dirty connector changed on basis column %d" % column) + require(result[2] == expected, "target delta mismatch on basis column %d" % column) + require(result[3] == 0, "fresh connector not restored on basis column %d" % column) + checked += 1 + return checked + + +def mixed_word(seed): + state = seed & 0xFFFFFFFF + + def next_word(): + nonlocal state + state = (1664525 * state + 1013904223) & 0xFFFFFFFF + return (state ^ (state >> 13)) & 0xFFFF + + sources = [next_word() for _ in range(5)] + dirty_connector = next_word() + targets = [next_word() for _ in MASKS] + fresh_connector = next_word() + return sources, dirty_connector, targets, fresh_connector + + +def valid_result(inputs, result): + sources, dirty_connector, targets, _fresh = inputs + expected = [targets[i] ^ d for i, d in enumerate(expected_deltas(sources))] + return result == (sources, dirty_connector, expected, 0) + + +def verify_controls(): + inputs = mixed_word(0xC1EA_5EED) + clean_inputs = (inputs[0], inputs[1], inputs[2], 0) + positive = execute(*clean_inputs) + require(valid_result(clean_inputs, positive), "mixed-state positive fixture failed") + controls = [ + execute(*inputs, fault="omit-zeroing"), + execute(*clean_inputs, fault="omit-reverse"), + execute(*clean_inputs, fault="omit-first-source"), + execute(*clean_inputs, fault="wrong-target"), + ] + require(all(not valid_result(inputs if i == 0 else clean_inputs, result) + for i, result in enumerate(controls)), "a mutation control escaped") + return len(controls) + + +def direct_schedule_counts(): + root = Path(__file__).resolve().parents[2] + certificate = json.loads( + (root / "research/universal-connector-boundary/CERTIFICATE.json").read_text() + ) + word = certificate["schedules"]["five_extra_output"]["word"] + counts = Counter(op for op, _index in word) + outputs = Counter(index for op, index in word if op == "A") + require(counts == Counter({"A": 64, "B": 10}), "pinned direct schedule call counts changed") + require(outputs == Counter({i: (4 if i == 20 else 2) for i in range(31)}), + "pinned direct schedule no longer has its single four-read output") + return counts["B"], counts["A"] + + +def budget(direct_b, direct_a, candidate_b, candidate_a): + a, b, d = 208, 16, 13 + map_table_bits = 31 * L * 13 * 4 + 5 * L * 4 + common_row_cells = 37 * L # 5 sources, 1 original connector, 31 targets. + common = map_table_bits + common_row_cells + direct = common + direct_b * (b + d) + direct_a * (a + d) + invoice = { + "shared_map_table_bits": map_table_bits, + "shared_row_cells": common_row_cells, + "source_updates": candidate_b * b, + "output_updates": candidate_a * a, + "action_descriptors": (candidate_b + candidate_a) * d, + "mask_control_descriptors": 31 * d, + "allocation_release_descriptors": 2 * d, + "fresh_row_cells": L, + "zero_writes": L, + } + require(invoice_valid(invoice), "a candidate invoice line changed: %r" % invoice) + candidate = sum(invoice.values()) + return common, direct, candidate, direct - candidate, invoice + + +def verify_bill_and_fixture(): + rows = a_rows() + require(gf2_rank(rows, L) == L, "13-term cyclic convolution is not invertible") + require(all(len(set(p)) == L for p in B_MAPS + Q_MAPS), "a fixture map is not a permutation") + signatures = [tuple(apply_output_map(1 << i, q) for i in range(L)) for q in range(31)] + require(len(set(signatures)) == 31, "output maps are not pairwise distinct") + for q_map in Q_MAPS: + for row in range(L): + indices = [q_map[(row + shift) % L] for shift in range(13)] + require(len(set(indices)) == 13, "an output-map row does not have 13 taps") + direct_b, direct_a = direct_schedule_counts() + candidate_b = 2 * sum(mask.bit_count() for mask in MASKS) + candidate_a = len(MASKS) + require((candidate_b, candidate_a) == (160, 31), "candidate action count changed") + common, direct, candidate, saving, invoice = budget(direct_b, direct_a, candidate_b, candidate_a) + require((common, direct, candidate, saving) == (26704, 41138, 38656, 2482), + "complete bill changed: %r" % ((common, direct, candidate, saving),)) + require(33 * 208 - 150 * 16 - 150 * 13 - 2 * L == saving, + "symbolic break-even difference mismatch") + controls = 0 + for key in invoice: + undercharged = dict(invoice) + undercharged[key] = 0 + require(undercharged != invoice, "undercharge mutation did not change invoice") + require(not invoice_valid(undercharged), "undercharge mutation escaped: " + key) + controls += 1 + return common, direct, candidate, saving, controls + + +def main(): + basis = verify_basis() + controls = verify_controls() + common, direct, candidate, saving, invoice_controls = verify_bill_and_fixture() + print("PASS_CLEAN_CONNECTOR_PER_MASK basis_columns=%d controls=%d masks=31 candidate_B=160 candidate_A=31 direct_B=10 direct_A=64 common=%d direct_cost=%d candidate_cost=%d saving=%d" % + (basis, controls + invoice_controls, common, direct, candidate, saving)) + + +if __name__ == "__main__": + main()