diff --git a/research/two-epoch-dirty-fanout/PROOF.md b/research/two-epoch-dirty-fanout/PROOF.md new file mode 100644 index 0000000000..1e5df4a564 --- /dev/null +++ b/research/two-epoch-dirty-fanout/PROOF.md @@ -0,0 +1,169 @@ +# A forest echo can lose under two-epoch tariffs + +## Contract + +There are exactly three required rows, initially independent arbitrary +`a0,a1,a2` in `F2^w`, for any finite `w >= 1`. A fixed straight-line program +uses only `ADD(i,j): Ai ^= Aj`, with distinct `i,j` in `{0,1,2}`, and exactly +one complete call `P0: A0 ^= p`. The arbitrary value `p` comes from preserved +read-only sources disjoint from all three rows. The call separates the two +epochs. The endpoint must be `Ai = ai ^ p` for every row and every input. +There is no helper, free basis change, observation, COPY, CLEAR or adaptation. + +The common call has declared complete price one. Fix a real `M >= 3`. +Before the call, ADD(1,0) and ADD(2,1) cost one. After the call, ADD(2,0) +and ADD(1,2) cost one. Every other ADD costs M in its respective epoch. +These are hypotheses about complete stationary prices within each epoch. +No actual physical tariff matrix is supplied. + +A *same-tree echo* chooses an outward spanning tree rooted at row zero, +executes each tree ADD once in children-before-parents order before P0, +then executes the literal reverse after P0. This is the single-root +construction in Ross Richardson's PR3121 with its prices changed across +the call. The word, target and dirty-output contract retain their meanings. + +## Theorem + +For every finite `w >= 1` and real `M >= 3`, the unrestricted optimum is +exactly **7**, including P0. Every same-tree echo costs exactly **2M+3**. +At M=3 the sharp comparison is 7 versus 9. In this changed price contract, +the ratio of the best same-tree echo to the unrestricted optimum is +unbounded as M grows. + +This is a scoped written proof. It is not a counterexample to PR3121, +whose prices are stationary across the entire word. + +## Attainment + +The chronological program is + +```text +ADD(2,1), ADD(1,0), ADD(2,1), +P0, +ADD(1,2), ADD(2,0), ADD(1,2). +``` + +Preparation maps `(a0,a1,a2)` to `(a0,a1+a0,a2+a0)`. +After P0 the rows are `(a0+p,a1+a0,a2+a0)`. The last three ADDs give +`(a0+p,a1+p,a2+p)` exactly. All six ADDs have price one, so the total is +seven. The read-only sources are preserved by the complete P0 contract. +There is no hidden scratch or uncompute. The proof applies componentwise +at every positive row width. + +Both three-ADD words realize the same involution + +```text +S = [1 0 0] + [1 1 0] + [1 0 1]. +``` + +They are different spellings of S. Using the literal reverse of the +preparation would also be algebraically correct, but its three post-call +ADDs would each cost M. The alternative spelling is what changes the bill. +The elementary three-ADD identity itself is classical and is not claimed +as new. The contribution is the complete two-epoch optimum and its exact +separation from the forest echo. + +## Lower bound for all words + +First, every successful word has at least four ADDs. Rows one and two +must each be an ADD destination, since P0 does not directly change them +and their final values depend on p. Neither row can be a destination +exactly once. Project the state onto the three original dirt symbols, +equivalently set p=0. Every prefix dirt matrix is invertible. Before the +unique destination occurrence on row i its dirt row is `e_i`. The source +dirt row at that occurrence is nonzero, so afterward row i differs from +`e_i`. No later gate changes it. It cannot end at `e_i`, a contradiction. +Thus each of rows one and two is an ADD destination at least twice. +This is the one-row dirt argument credited to PR3063 and PR3121. + +If any ADD has price M, the ADD bill is at least `M+3 >= 6`, by that +four-ADD floor. This already gives a total of at least seven. + +It remains to consider words using only the two cheap ADDs in each +epoch. Write A for the preparation dirt matrix and B for the post-call +dirt matrix. Cheap preparation has the form + +```text +A = [1 0 0] + [a 1 0] + [c b 1], a,b,c in F2. +``` + +Cheap post-call computation has the form + +```text +B = [1 0 0] + [v 1 u] + [t 0 1], u,v,t in F2. +``` + +The required dirt endpoint is `BA=I`. Comparing the third row gives +`b=0` and `t=c`. Comparing the second gives `u=0` and `v=a`. +The p coefficient is `B e0=(1,v,t)^T`. It must be `(1,1,1)^T`, so +`a=c=v=t=1`. Consequently `A=B=S`. + +No word of at most two cheap preparation ADDs gives S. Repeating one +generator twice gives I. Using each once leaves a nonzero coefficient +of a1 in row two, while S has zero there. A single generator also +cannot give S. Interchanging rows one and two gives the same argument +for the post-call cheap alphabet. Each epoch therefore needs at least +three cheap ADDs. The total ADD bill is at least six, completing the +lower bound. + +This proves the all-word and all-width statement without relying on +the finite shortest-path computations. + +## Exact forest bill + +There are exactly three outward spanning trees rooted at zero: + +```text +{0->1, 0->2}, {0->1, 1->2}, {0->2, 2->1}. +``` + +Every edge appearing here has combined before-plus-after price `M+1`. +Each tree has two edges, so its ADD bill is `2M+2` and its complete bill +is `2M+3`. Dividing by seven proves the unbounded ratio. + +For one required row the oracle alone is optimal. For two required +rows, ADD(1,0) must occur at least once before the oracle to make the +preparation send `(1,1)^T` to `e0`, and at least once after the oracle +to deliver p to row one. The usual one-edge echo attains the sum of +these two prices. Thus three rows are the smallest size for this +separation in the exactly-one-P0, two-epoch XOR contract. + +## Finite independent evidence + +The primary verifier enumerates GL(3,2), the 24 permissible cut maps, +and shortest paths in both epoch-specific Cayley graphs. It verifies +both attaining path costs and every Bellman inequality, so a faulty +distance search cannot silently publish a larger optimum. At M=3 the +minimum combined ADD distance is six. Values M=1,2,6,11 are controls and +corroboration, not extra theorem claims. All three trees are enumerated. +The literal word also runs on every input tuple at widths one through +three, including arbitrary independent dirt and common values. + +The separate checker uses the complete 16-entry Boolean truth tables +for three dirt bits and one common bit. Its graph contains the before +and after epochs and the single paid P0 transition. It exhausts all +1,344 reachable states and 8,232 transitions, independently obtaining +total seven. It imports neither the primary verifier nor predecessor +executables. These are two implementations by the same contributor, +not independent human review or formal proof-kernel acceptance. + +## Boundary of the conclusion + +The stationary theorem and its cut lower bounds are retained. Their +conversion to a repeated cheapest tree cannot be made with the +naive combined edge prices in this changed model. A valid unrestricted +optimizer must allow different algebraic realizations of the same cut +matrix on the two sides. This example still has one fixed source value +and does not answer the separate changing-source scheduling problem. + +Physical routing, source access, frames, precision, ownership, head +return and restoration must all be included before any actual ADD +can be assigned these complete prices. The example supplies no such +caller. No selected construction, recursive rank profile, supplier +admission, new kappa or multiplication theorem follows. diff --git a/research/two-epoch-dirty-fanout/README.md b/research/two-epoch-dirty-fanout/README.md new file mode 100644 index 0000000000..a41337dd4c --- /dev/null +++ b/research/two-epoch-dirty-fanout/README.md @@ -0,0 +1,137 @@ +# Different epoch prices defeat the same-tree dirty echo + +A three-row dirty fanout costs exactly **7**, while every same-tree echo +costs **9**, under the complete two-epoch prices below. This is a scoped +written proof with exact finite corroboration, produced by Nick Petalas. +It is a negative result for extending the stationary forest normal form. +It changes no supplier or selected kappa. + +Ross Richardson's [PR3121](https://github.com/CrocSwap/integer-mult-bounds/pull/3121) +proves an exact forest tariff under stationary directed prices, and +explicitly leaves changing prices outside its contract. Here exactly one +common-value call on row zero separates two price epochs. The three rows +have arbitrary independent dirt, the common source is preserved, and every +row must finish with its original dirt XOR the common value. No helper or +free basis change is supplied. The only changed hypothesis is the ADD price +across the cut. The predecessor theorem is a cited result, not a replay +deliverable. + +## Result and word + +Before the call, ADD(1,0) and ADD(2,1) cost one. After the call, ADD(2,0) +and ADD(1,2) cost one. All other ADDs cost M in their respective epoch. +The complete common call P0 costs one. For every real M>=3 and every +positive row width, the unrestricted optimum is **7** and every same-tree +echo costs **2M+3**. Three is the smallest row count for this separation in +the declared exactly-one-call model. + +The chronological attaining word is + +```text +ADD(2,1), ADD(1,0), ADD(2,1), +P0, +ADD(1,2), ADD(2,0), ADD(1,2). +``` + +Both three-ADD words realize the same involution S, which adds row zero +to each other row. Their different spellings use only cheap directions +in their respective epochs. Every gate and the single oracle are paid. +The usual three-ADD identity is classical. The new result is the sharp +two-epoch tariff and its complete comparison with every rooted-tree echo. + +[PROOF.md](PROOF.md) gives the all-word proof. Every successful program +needs at least four ADDs by the inherited one-row dirt invariant. A program +using an expensive ADD therefore pays at least M+3>=6 in ADDs. If it uses +only cheap ADDs, restoration forces both cut matrices to equal S, and each +epoch needs at least three ADDs. The three possible rooted trees each pay +2M+2 for ADDs. The ratio of their total bill to seven is unbounded as M grows. + +The scope is the same-tree echo, including its children-before-parents +preparation and literal reversal. This does not contradict the stationary +theorem, forbid other useful forests, or settle changing-source scheduling. +An optimizer for changed epoch prices must allow different words for the +same cut map. + +## Exact evidence and reproduction + +From the repository root with standard-library CPython 3.12: + +```sh +/Users/nick/git/integer-mult-bounds/.venv/bin/python3.12 -X dev -W error -B research/two-epoch-dirty-fanout/verify.py +/Users/nick/git/integer-mult-bounds/.venv/bin/python3.12 -X dev -W error -B research/two-epoch-dirty-fanout/independent.py +/Users/nick/git/integer-mult-bounds/.venv/bin/python3.12 -B scripts/research_package.py --package research/two-epoch-dirty-fanout +/Users/nick/git/integer-mult-bounds/.venv/bin/python3.12 -B scripts/check_research_commit.py --package research/two-epoch-dirty-fanout --check-source-history +``` + +An equivalent CPython 3.12 path works. The registered replay runs both +checkers normally and under optimization. Direct execution is read-only. + +The primary prints `PASS_TWO_EPOCH_DIRTY_FANOUT` in a generated JSON +receipt bound to every package file's SHA256. It enumerates all 168 matrices +in GL(3,2) and all 24 legal cut maps at M=1,2,3,6,11. For each price it +checks every attaining path and all 2,016 directed Bellman inequalities. +It enumerates all three trees, runs all 4,368 literal input assignments at +widths one through three, and passes thirteen boundary and semantic controls. +The M=1 stationary control has four ADDs, as expected. The M=2 computation +is corroboration, not an extension of the stated M>=3 proof. + +The separate [independent.py](independent.py) prints +`PASS_INDEPENDENT_TWO_EPOCH_FANOUT`. It exhausts the full 1,344-state +two-epoch graph using sixteen-entry Boolean truth tables, including the +single paid oracle transition. Its 8,232 transitions give exact total seven +at M=3. It imports no primary or predecessor code. These are two separate +implementations by the same contributor. Independent human and formal +proof-kernel review are unclaimed. + +[SOURCES.json](SOURCES.json) pins the unchanged predecessor documents as +live inputs and the catalogue/selected record as historical provenance in +reachable base history. No predecessor scientific executable is run. + +## Limits and implementation bounds + +These are declared complete tariffs. No selected caller is shown to have +them. Physical access, frames, routing, precision/storage, owned lifetimes, +restoration and head return remain unpriced. No native implementation, +complete recursive invoice, selected cold replay, Lean or Docker execution, +new kappa or complete multiplication theorem is claimed. All five selected +framework assumptions remain. The family decision is to stop at this +tariff counterexample until an actual caller makes the changed contract useful. + +The primary has a fixed three-row domain. Its price evaluator accepts only +integer M in [1,1000]; these are checker limits, not theorem restrictions. +All loops have explicit finite bounds. The two Cayley searches each retain +at most 168 states, with at most 1,009 queue insertions. The separate search +retains 1,344 states, each with three sixteen-bit tables, and has at most +9,409 queue insertions. The independent main function is under sixty lines. +There is no recursion, dynamic evaluation, network access or subprocess. + +Power-of-Ten rule 3 needs a managed-runtime deviation for Python's integer, +tuple and dictionary allocation. The fixed domains bound all live objects; +receipt hashing reads at most twelve package files and two pinned input +documents. Python runtime/library allocation is not a physical fixed-capacity +implementation. Warning-strict normal/optimized runs, AST parsing and +compilation provide diagnostics. A separate static type checker is unrun. + +## Open next questions + +1. Bind one actual caller whose legal frame or routing change induces two + different complete epoch tariffs. First identify the owner/cut and price + both realizations of S, including source access and restoration. No such + physical price assignment is supplied here. +2. Characterize two-epoch price matrices for which one same-tree echo is + still optimal. First compare the exact cut-matrix optimization with the + combined-edge tree bill for a fixed small caller. The unrestricted number + of cut matrices and the physical meaning of a price change remain blockers. + +[TASK.json](TASK.json) records these questions and the scope change. + +## Credit + +The new tariff proof, example and checkers were produced by Nick Petalas. +Credit Ross Richardson #3121 for the stationary directed tariff theorem, +the boundary excluding changing prices and its one-row dirt argument; +Ross Richardson #3063 and Cinna Davis #1944/#1968 for dirty-output echo and +common-value lineage. Anthony #774 and Oscar Fennell #759 retain the earlier +forest-compensation credit preserved by #3121. No priority is claimed for +elementary XOR identities, forest synthesis or shortest-path algorithms. +Predecessor files and credit lines are unchanged. Apache-2.0. diff --git a/research/two-epoch-dirty-fanout/SOURCES.json b/research/two-epoch-dirty-fanout/SOURCES.json new file mode 100644 index 0000000000..600321ebae --- /dev/null +++ b/research/two-epoch-dirty-fanout/SOURCES.json @@ -0,0 +1,30 @@ +{ + "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/dirty-anchor-edge-tariffs/PROOF.md", + "usage": "input", + "git_blob": "7643ababf0f003eaf699edb4910ce9693025b5cd", + "sha256": "1c73b56222dbd63a2230a23c00ce4b822eaa3aa7cdd4c5d6ba9975b98857b289" + }, + { + "path": "research/dirty-anchor-edge-tariffs/README.md", + "usage": "input", + "git_blob": "16aa73e36b791fd4c025011123b8101dd4a1c2d6", + "sha256": "dae5277016949f17bc55191e34a5f9470475b94ed679c843217973711ce2a341" + } + ] +} diff --git a/research/two-epoch-dirty-fanout/TASK.json b/research/two-epoch-dirty-fanout/TASK.json new file mode 100644 index 0000000000..632aecad2e --- /dev/null +++ b/research/two-epoch-dirty-fanout/TASK.json @@ -0,0 +1,104 @@ +{ + "schema_version": 1, + "task_id": "joint-query-controller", + "priority_revision": 8, + "base_commit": "e54523517d0f03e58352e647c403a5af3e525a57", + "original_card": { + "id": "joint-query-controller", + "question": "Can a changed query demand or caller remove real work while satisfying native chronology and restoration?", + "starting_points": [ + "docs/research/current-priorities.md", + "docs/research/research-family-status.md", + "certificates/selected-result.json", + "docs/research/pr-intake-evidence/pr5599-completion/PROOF-REVIEW.md" + ], + "methods": [ + "Construct and independently check one source-bound instance of the stated first experiment.", + "Seek an exact counterexample or target-specific complete-budget obstruction to that same proposed change." + ], + "acceptance_gate": "A source-bound arbitrary-input identity and legal producer/consumer boundary with the complete paid and productive target invoice, including restoration, ownership, native alignment and extra charges. Price under the actual current model; historical ceiling.py assumptions must be established before use. A favorable optimistic relaxation keeps a route open but is not a completed supplier. A scoped local result remains useful; expansion requires the family-level budget gate.", + "first_step": { + "command": [ + "python3", + "-B", + "scripts/research_selected_baseline.py" + ], + "expected": "PASS_RESEARCH_BASELINE_BINDINGS_ONLY", + "inspect": "Read revision 8, the selected review and live exact-source handoffs. Then follow this card's bounded first_experiment.", + "scope": "Source-bound orientation only, not a supplier replay or theorem proof." + }, + "first_experiment": "Choose an exact caller and a new demand/interface hypothesis. Read the scoped #5617/#5631/#5649/#5747 and #5720/#5745 objections before rebuilding an excluded schedule. Compare the complete matched source/consumer protocols including all retained helper outputs. For an active-mode injection, first check #5745: its canonical delivery claim repays the eight removed centre jobs. Audit that exact claim or change its channel/feedback hypothesis; do not repeat the same free-injection search. Stop if the full favorable budget fails or the required restored output is unobservable.", + "bottleneck_link": "Judge the actual current supplier contract and complete signed target/paid bill; frozen-profile ceilings require an applicability proof.", + "allowed_variations": [ + "One exact source head, helper/cut region or quantified proposition and changed hypothesis; check live handoffs first. Different seeds are not different scopes." + ], + "scope_change_triggers": [ + "Changing source head, helper/cut domain, operation alphabet or caller boundary without recording the new scope.", + "Treating an archived proposal or local numerical pass as complete supplier admission." + ], + "overlap_terms": [ + "query demand", + "active mode", + "5720", + "5745", + "5747", + "caller" + ], + "existing_checks": [ + { + "scope": "PR #4166: author-checked installed producer/service/return/bridge connection; native-component comparison loses.", + "evidence": "research/qq16-caller-install/README.md", + "remaining": "Complete matched physical protocol bill, or changed source-compatible demand/circuit; no affordable supplier yet.", + "status": "author-checked", + "source_commit": "0b082d22a0e9a442d264ab0633e35ef26c790630", + "selected_record_sha256": "bb2eaa58647b353f88d0aec2eafb9d30df1be53589231b23e12ceef3e4bad129" + }, + { + "scope": "Selected PR5599: complete helper-subspace construction and independent caller replay; five framework assumptions remain.", + "evidence": "docs/research/pr-intake-evidence/pr5599-completion/PROOF-REVIEW.md", + "remaining": "The next experiment must identify uncovered source-specific work. Successor archive intake does not transfer this admission.", + "status": "reviewed", + "source_commit": "09dd0965711ca7eeb169057a420abab1c9052137", + "selected_record_sha256": "2a0220e866417774606e0f991e41b9c1d26b1f43b97857238cf478dbc7d330b5" + } + ] + }, + "scope_status": "changed", + "actual_scope": "Exact three-row, one-P0 dirty XOR fanout under different stationary directed ADD prices before and after the oracle cut. Prove optimum 7 versus same-tree echo 2M+3 for all real M>=3 and all finite positive row widths.", + "scope_change_reason": "The card concerns changed current supplier interfaces. This is a local tariff side result motivated by PR3121's explicit exclusion of changing prices, with no selected-source physical mapping or supplier claim.", + "bottleneck_link": "Complete interface accounting can depend on the cut. The example rules out naively extending the stationary same-tree optimum by summing the two epoch edge prices. An actual caller and its complete costs remain necessary.", + "budget_minutes": 60, + "stop_rule": "Stop at the first verified separation. No wider census or physical implementation expansion is assigned.", + "outcome": "completed", + "evidence": "PROOF.md; primary GL(3,2) factor and Bellman checks; separate full truth-table graph; literal all-input tests at widths 1..3.", + "author": "Nick Petalas", + "ai_assistance": "Independent human and formal proof-kernel review are unclaimed.", + "open_questions": [ + { + "question": "Can an actual caller supply complete two-epoch tariffs with a useful alternative spelling of the cut involution?", + "why_it_matters": "The abstract separation alone removes no recursive work.", + "first_step": "Identify one owner and oracle cut, then price both S realizations including frames, routing, source access, restoration and return.", + "blocked_by": "No named selected physical caller or complete tariff matrix is supplied." + }, + { + "question": "Which two-epoch price matrices retain an optimal same-tree echo?", + "why_it_matters": "The stationary combined-edge optimizer fails even on three dirty rows.", + "first_step": "Compare cut-matrix shortest paths and combined-edge tree costs for one fixed small caller.", + "blocked_by": "Unrestricted cut-matrix complexity and the physical meaning of the tariff change." + } + ], + "environment": { + "python": "CPython 3.12.15", + "platform": "macOS 27.0.1 arm64", + "interpreter": "/Users/nick/git/integer-mult-bounds/.venv/bin/python3.12" + }, + "overlap": { + "checked_at_utc": "2026-11-13T14:23:06Z", + "canonical_main": "e54523517d0f03e58352e647c403a5af3e525a57", + "source": "PR #3121, RossRichardson", + "coverage": "Live open PR metadata and bodies via cached full 810-record scan; active Discussions and latest handoffs; main README term searches and merged PR searches. Closed-body bulk refresh timed out; targeted merged searches and main source coverage supplement it. No absence-of-match novelty guarantee.", + "nearest_recent_same_account": "PR #7183 has independent radical demands over R16 with stationary prices. This result changes epoch pricing for one binary common value, reuses none of that package, and changes neither its group nor its target as a counterpart.", + "claim_url": "https://github.com/CrocSwap/integer-mult-bounds/discussions/1166#discussioncomment-19592119" + }, + "claim_type": "scoped written proof with exact finite corroboration" +} diff --git a/research/two-epoch-dirty-fanout/VERIFY.json b/research/two-epoch-dirty-fanout/VERIFY.json new file mode 100644 index 0000000000..369d7a81cc --- /dev/null +++ b/research/two-epoch-dirty-fanout/VERIFY.json @@ -0,0 +1,66 @@ +{ + "schema_version": 1, + "status": "ready", + "python": "3.12", + "requirements": [], + "inputs": [ + "research/dirty-anchor-edge-tariffs/PROOF.md", + "research/dirty-anchor-edge-tariffs/README.md" + ], + "commands": [ + { + "argv": [ + "{python}", + "-X", + "dev", + "-W", + "error", + "-B", + "{package}/verify.py" + ], + "timeout_seconds": 60, + "checks": "Complete GL(3,2) factor distances, all Bellman inequalities, three trees, arbitrary dirty inputs and controls; generated file-hash receipt." + }, + { + "argv": [ + "{python}", + "-X", + "dev", + "-W", + "error", + "-B", + "-O", + "{package}/verify.py" + ], + "timeout_seconds": 60, + "checks": "Complete GL(3,2) factor distances, all Bellman inequalities, three trees, arbitrary dirty inputs and controls; generated file-hash receipt." + }, + { + "argv": [ + "{python}", + "-X", + "dev", + "-W", + "error", + "-B", + "{package}/independent.py" + ], + "timeout_seconds": 60, + "checks": "Independent complete 1344-state truth-table graph and exact total optimum 7." + }, + { + "argv": [ + "{python}", + "-X", + "dev", + "-W", + "error", + "-B", + "-O", + "{package}/independent.py" + ], + "timeout_seconds": 60, + "checks": "Independent complete 1344-state truth-table graph and exact total optimum 7." + } + ] +} diff --git a/research/two-epoch-dirty-fanout/independent.py b/research/two-epoch-dirty-fanout/independent.py new file mode 100644 index 0000000000..5bbf55f5ac --- /dev/null +++ b/research/two-epoch-dirty-fanout/independent.py @@ -0,0 +1,59 @@ +"""Full truth-table state search; imports no primary or predecessor code.""" + +import heapq +import json + + +def check(condition, message): + if not condition: + raise ValueError(message) + + +def main(): + # Bit t of each table is the row value on input assignment t in {0,...,15}. + identity = tuple(sum(((t >> i) & 1) << t for t in range(16)) for i in range(3)) + common = sum(((t >> 3) & 1) << t for t in range(16)) + start = (0, identity) + goal = (1, tuple(row ^ common for row in identity)) + distance = {start: 0} + pending = [(0, start)] + scanned = 0 + transitions = 0 + for _ in range(1344 * 7 + 1): + if not pending: + break + value, state = heapq.heappop(pending) + if value != distance[state]: + continue + phase, rows = state + scanned += 1 + successors = [] + for destination in range(3): + for source in range(3): + if destination == source: + continue + cheap = ((1, 0), (2, 1)) if phase == 0 else ((2, 0), (1, 2)) + cost = 1 if (destination, source) in cheap else 3 + changed = list(rows) + changed[destination] ^= changed[source] + successors.append(((phase, tuple(changed)), cost)) + if phase == 0: + successors.append(((1, (rows[0] ^ common, rows[1], rows[2])), 1)) + for target, cost in successors: + transitions += 1 + candidate = value + cost + if candidate < distance.get(target, 10**9): + distance[target] = candidate + heapq.heappush(pending, (candidate, target)) + check(not pending, "search capacity exhausted") + check(len(distance) == scanned == 1344, "state inventory mismatch") + check(transitions == 8232, "transition inventory mismatch") + check(distance[goal] == 7, "unrestricted optimum mismatch") + print(json.dumps({"status": "PASS_INDEPENDENT_TWO_EPOCH_FANOUT", "errors": 0, + "truth_assignments_per_state": 16, "states": scanned, + "transitions": transitions, "optimal_total": distance[goal]}, + sort_keys=True)) + + +if __name__ == "__main__": + main() diff --git a/research/two-epoch-dirty-fanout/verify.py b/research/two-epoch-dirty-fanout/verify.py new file mode 100644 index 0000000000..de679ce974 --- /dev/null +++ b/research/two-epoch-dirty-fanout/verify.py @@ -0,0 +1,201 @@ +"""Exact two-epoch fanout certificate; standard-library, read-only replay.""" + +import hashlib +import heapq +import itertools +import json +from pathlib import Path + + +IDENTITY = (1, 2, 4) +GATES = tuple((i, j) for i in range(3) for j in range(3) if i != j) +PREPARE = ((2, 1), (1, 0), (2, 1)) +RESTORE = ((1, 2), (2, 0), (1, 2)) + + +def require(condition, message): + if not condition: + raise ValueError(message) + + +def add(rows, gate): + result = list(rows) + result[gate[0]] ^= result[gate[1]] + return tuple(result) + + +def product(left, right): + result = [] + for row in left: + value = 0 + for k in range(3): + if row & (1 << k): + value ^= right[k] + result.append(value) + return tuple(result) + + +def matrices(): + result = [] + for rows in itertools.product(range(1, 8), repeat=3): + images = {product((mask,), rows)[0] for mask in range(8)} + if len(images) == 8: + result.append(rows) + require(len(result) == 168, "GL(3,2) inventory") + return tuple(result) + + +def prices(epoch, expensive): + require(epoch in (0, 1), "unknown epoch") + require(type(expensive) is int and 1 <= expensive <= 1000, "price domain") + cheap = ((1, 0), (2, 1)) if epoch == 0 else ((2, 0), (1, 2)) + return {gate: 1 if gate in cheap else expensive for gate in GATES} + + +def distances(cost): + distance = {IDENTITY: 0} + witnesses = {IDENTITY: ()} + pending = [(0, IDENTITY)] + for _ in range(168 * 6 + 1): + if not pending: + break + value, rows = heapq.heappop(pending) + if value != distance[rows]: + continue + for gate in GATES: + target = add(rows, gate) + candidate = value + cost[gate] + if candidate < distance.get(target, 10**9): + distance[target] = candidate + witnesses[target] = witnesses[rows] + (gate,) + heapq.heappush(pending, (candidate, target)) + require(not pending and len(distance) == 168, "distance capacity") + return distance, witnesses + + +def check_distances(distance, witnesses, cost): + require(distance[IDENTITY] == 0, "distance origin") + inequalities = 0 + for rows, value in distance.items(): + current = IDENTITY + total = 0 + require(len(witnesses[rows]) <= 167, "witness length") + for gate in witnesses[rows]: + current = add(current, gate) + total += cost[gate] + require(current == rows and total == value, "distance witness") + for gate in GATES: + require(distance[add(rows, gate)] <= value + cost[gate], "Bellman") + inequalities += 1 + return inequalities + + +def factor_certificate(expensive, group): + before, paths_before = distances(prices(0, expensive)) + after, paths_after = distances(prices(1, expensive)) + bellman = check_distances(before, paths_before, prices(0, expensive)) + bellman += check_distances(after, paths_after, prices(1, expensive)) + candidates = [] + for rows in group: + if tuple(row.bit_count() % 2 for row in rows) != (1, 0, 0): + continue + inverses = [other for other in group if product(other, rows) == IDENTITY] + require(len(inverses) == 1, "unique inverse") + candidates.append(before[rows] + after[inverses[0]]) + require(len(candidates) == 24, "legal cut maps") + expected = 4 if expensive == 1 else 6 + require(min(candidates) == expected, "unrestricted ADD optimum") + return {"price": expensive, "cut_maps": len(candidates), + "ADD_optimum": expected, "Bellman_inequalities": bellman} + + +def forest_certificate(expensive): + before, after = prices(0, expensive), prices(1, expensive) + trees = [] + for parent1 in (0, 2): + for parent2 in (0, 1): + if (parent1, parent2) == (2, 1): + continue + edges = ((1, parent1), (2, parent2)) + bill = sum(before[edge] + after[edge] for edge in edges) + require(bill == 2 * expensive + 2, "forest bill") + trees.append(bill) + require(len(trees) == 3, "rooted tree inventory") + return min(trees) + + +def endpoint(prepare, restore, value_mask=8): + rows = IDENTITY + for gate in prepare: + rows = add(rows, gate) + rows = (rows[0] ^ value_mask, rows[1], rows[2]) + for gate in restore: + rows = add(rows, gate) + return rows + + +def endpoints_and_controls(): + target = (9, 10, 12) + require(endpoint(PREPARE, RESTORE) == target, "symbolic endpoint") + concrete = 0 + for width in range(1, 4): + for values in itertools.product(range(1 << width), repeat=4): + state = list(values[:3]) + for gate in PREPARE: + state[gate[0]] ^= state[gate[1]] + state[0] ^= values[3] + for gate in RESTORE: + state[gate[0]] ^= state[gate[1]] + require(tuple(state) == tuple(x ^ values[3] for x in values[:3]), + "arbitrary dirty endpoint") + concrete += 1 + controls = 0 + for index in range(6): + pre = PREPARE[:index] + PREPARE[index + 1:] if index < 3 else PREPARE + j = index - 3 + post = RESTORE[:j] + RESTORE[j + 1:] if index >= 3 else RESTORE + require(endpoint(pre, post) != target, "deleted gate accepted") + controls += 1 + require(endpoint(PREPARE, tuple(reversed(PREPARE))) == target, + "literal inverse should preserve endpoint") + require(sum(prices(1, 3)[g] for g in reversed(PREPARE)) == 9, + "literal inverse wrongly priced at three") + require(endpoint(PREPARE, RESTORE, 0) != target, "missing oracle") + return concrete, controls + 2 + + +def source_and_package_hashes(): + package = Path(__file__).resolve().parent + source = json.loads((package / "SOURCES.json").read_text()) + root = package.parent.parent + for entry in source["files"]: + if entry.get("usage") == "input": + digest = hashlib.sha256((root / entry["path"]).read_bytes()).hexdigest() + require(digest == entry["sha256"], "source hash " + entry["path"]) + files = sorted(path for path in package.iterdir() if path.is_file()) + require(len(files) <= 12, "package inventory bound") + return {path.name: hashlib.sha256(path.read_bytes()).hexdigest() for path in files} + + +def main(): + group = matrices() + certificates = [factor_certificate(value, group) for value in (1, 2, 3, 6, 11)] + forest = forest_certificate(3) + concrete, controls = endpoints_and_controls() + for bad_epoch, bad_price in ((-1, 3), (2, 3), (0, 0), (1, 1001), (0, True)): + try: + prices(bad_epoch, bad_price) + except ValueError: + controls += 1 + else: + raise ValueError("invalid price accepted") + print(json.dumps({"status": "PASS_TWO_EPOCH_DIRTY_FANOUT", "errors": 0, + "claim_type": "scoped written proof with exact finite corroboration", + "matrices": len(group), "certificates": certificates, + "M3_total_optimum": 7, "M3_forest_total": forest + 1, + "concrete_assignments": concrete, "controls": controls, + "package_sha256": source_and_package_hashes()}, sort_keys=True)) + + +if __name__ == "__main__": + main()