diff --git a/research/swap-contact-fusion-gate/.gitattributes b/research/swap-contact-fusion-gate/.gitattributes new file mode 100644 index 0000000000..b7823e3f34 --- /dev/null +++ b/research/swap-contact-fusion-gate/.gitattributes @@ -0,0 +1 @@ +inputs/* -text diff --git a/research/swap-contact-fusion-gate/PROOF.md b/research/swap-contact-fusion-gate/PROOF.md new file mode 100644 index 0000000000..2e3e6b1334 --- /dev/null +++ b/research/swap-contact-fusion-gate/PROOF.md @@ -0,0 +1,145 @@ +# A two-region retiming gate after carried-frame field swaps + +This is a source-scoped abstract transport result, not a physical supplier +or a universal frame-optimization theorem. It uses the unchanged source at +PR4971 `0130b196145a43a7d305de41f49e56e8e8556378`, including the actual +forward and backward scalar words. Substantial OpenAI Codex assistance; +Apache-2.0. The original swap construction and endpoint proof are Dugongue's. + +## The declared replacement class + +Keep the scalar contact order, weighted field exchanges, signed native address +operators, source/target owners, start/end charts and all eight center queries. +Keep each center's copy/query/clear interface at its original charts. A field +exchange carries its chart. Between consecutive scalar contacts on each field +strand, fold all intervening signed native address maps into their actual +invertible binary map M. The strand contributes the containment constraint + + M F_u ⊆ F_v + +and one price `(dim F_v - dim F_u)^t`, where `00 +for 0 0. + +Thus b' is convex and lies below the chord joining its endpoint values. +Both are negative: b'(0)=-log 3 and b'(1)=log(16/27). Therefore b decreases +to b(1)=0, and B(t)≥0 on [0,1], strictly positive for t<1. + +For D, put q=log_2 5. The integer inequality `2^23<5^10` gives q>23/10. +Ignoring a positive term and enlarging the negative terms gives + + D'''(t)/l^3 = 3*q^3*5^t + p^3*3^t - 24*4^t - 9*2^t + ≥ (3*q^3-33)*5^t > 0. + +The last sign follows from 23^3>11*10^3. Again D' is convex. Its endpoint +values are negative because + + D'(0) = log(375/32768) < 0, + D'(1) = log(5^15*27/2^42) < 0. + +Consequently D decreases to D(1)=0 and is nonnegative on [0,1]. All numerical +premises here are exact integer inequalities checked by the replay. + +This proves that every declared one- or two-region replacement has local +recursive cost at least the source cost for every 0> v & 1 and not values >> v & 1: + result.append(v) + values |= sum(1 << (w ^ v) for w in range(512) if values >> w & 1) + require(values == space, "Space is not a binary subspace") + return tuple(result) + + +def dimension(space): + count = space.bit_count() + require(count > 0 and count & (count - 1) == 0, "Subspace cardinality") + return count.bit_length() - 1 + + +def apply_vector(v, matrix): + result = 0 + for j, column in enumerate(matrix): + if v >> j & 1: + result ^= column + return result + + +@lru_cache(None) +def transform(space, matrix): + return space if matrix == IDENTITY else span(apply_vector(v, matrix) for v in basis(space)) + + +@lru_cache(None) +def inverse(matrix): + values = {apply_vector(v, matrix): v for v in range(512)} + require(len(values) == 512, "Invertible native address map") + return tuple(values[1 << j] for j in range(9)) + + +def compose(left, right): + return tuple(apply_vector(v, left) for v in right) + + +@lru_cache(None) +def join(left, right): + if left & right == left: + return right + if left & right == right: + return left + return span(basis(left) + basis(right)) + + +class Graph: + def __init__(self, canonical, program): + self.labels, self.fixed, self.origins = [], [], [] + self.edges, self.incoming, self.outgoing = [], [], [] + self.frames = [span(vs) for vs in canonical["frames"]] + matrices = {w["op"]: tuple(w["G_columns"]) for w in canonical["warps"]} + matrices.update({-op: inverse(m) for op, m in list(matrices.items())}) + current = [(self.node(f, True, ["start", r]), IDENTITY) + for r, f in enumerate(canonical["start"])] + [None] + live = canonical["start"][:] + [None] + self.centers = Counter() + + def register(role): + return role[1] + (632 if role[0] == "C" else 0) + + for position, event in enumerate(program): + kind = event[0] + if kind == "climb": + _, _, r, before, after, rank = event + require(live[r] == before, "Chronological climb input") + require(self.frames[before] & self.frames[after] == self.frames[before], "Nested climb") + require(rank == dimension(self.frames[after]) - dimension(self.frames[before]) > 0, "Climb rank") + live[r] = after + elif kind == "weighted_swap": + _, r, s, _, _, before, after = event + require([live[r], live[s]] == before, "Swap input charts") + current[r], current[s] = current[s], current[r] + live[r], live[s] = live[s], live[r] + require([live[r], live[s]] == after, "Swap carries charts") + elif kind == "warp": + _, role, op, before, after = event + r = register(role) + require(live[r] == before, "Chronological warp input") + require(transform(self.frames[before], matrices[op]) == self.frames[after], "Operator carries warp chart") + n, matrix = current[r] + current[r] = n, compose(matrices[op], matrix) + live[r] = after + elif kind == "scalar": + gate, frame = event[1:] + r = register(gate[1]) + if gate[0] == "clear": + require(r == 632, "Owned clear only") + current[r] = self.node(frame, True, [position, "clear"]), IDENTITY + live[r] = frame + elif gate[0] == "copy": + s = register(gate[2]) + require(r == 632 and live[s] == frame, "Owned center copy input") + n = self.node(frame, True, [position, "copy"]) + self.edge(*current[s], n) + current[r] = current[s] = n, IDENTITY + live[r] = frame + elif gate[0] == "add": + s = register(gate[2]) + require(live[r] == live[s] == frame, "Scalar contact charts") + n = self.node(frame, r == 632 or s == 632, [position, "add"]) + for role in (r, s): + self.edge(*current[role], n) + current[role] = n, IDENTITY + else: + require(gate[0] == "scale" and live[r] == frame, "Scalar scale chart") + elif kind == "center": + _, _, before, after, rank = event + require(live[632] == before, "Owned center query input") + require(rank == abs(dimension(self.frames[before]) - dimension(self.frames[after])), "Center query rank") + self.centers[rank] += 1 + current[632] = self.node(after, True, [position, "center"]), IDENTITY + live[632] = after + else: + require(kind in ("adapter", "phase", "residual_adapter"), "Inherited event") + require(live[:632] == canonical["final"], "All terminal charts") + for r, frame in enumerate(canonical["final"]): + self.edge(*current[r], self.node(frame, True, ["final", r])) + self.validate() + + def node(self, frame, fixed, origin): + n = len(self.labels) + self.labels.append(self.frames[frame]) + self.fixed.append(fixed) + self.origins.append(origin) + self.incoming.append([]) + self.outgoing.append([]) + return n + + def edge(self, source, matrix, target): + e = len(self.edges) + self.edges.append((source, target, matrix)) + self.outgoing[source].append(e) + self.incoming[target].append(e) + + def validate(self): + for source, target, matrix in self.edges: + image = transform(self.labels[source], matrix) + require(image & self.labels[target] == image, "Graph edge containment") + + def histogram(self): + result = self.centers.copy() + for source, target, _ in self.edges: + rank = dimension(self.labels[target]) - dimension(self.labels[source]) + if rank: + result[rank] += 1 + return result + + def regions(self): + parent = list(range(len(self.labels))) + + def root(n): + while parent[n] != n: + parent[n] = parent[parent[n]] + n = parent[n] + return n + + for u, v, matrix in self.edges: + if matrix == IDENTITY and self.labels[u] == self.labels[v]: + parent[root(u)] = root(v) + groups = {} + for n in range(len(parent)): + groups.setdefault(root(n), []).append(n) + return groups, [root(n) for n in range(len(parent))] + + def boundary(self, nodes): + inside = set(nodes) + incoming = [e for n in nodes for e in self.incoming[n] if self.edges[e][0] not in inside] + outgoing = [e for n in nodes for e in self.outgoing[n] if self.edges[e][1] not in inside] + internal = [e for n in nodes for e in self.incoming[n] if self.edges[e][0] in inside] + lower, upper = 1, FULL + for e in incoming: + u, _, matrix = self.edges[e] + lower = join(lower, transform(self.labels[u], matrix)) + for e in outgoing: + _, v, matrix = self.edges[e] + upper &= transform(self.labels[v], inverse(matrix)) + return incoming, outgoing, internal, lower, upper + + def local_ranks(self, incoming, outgoing, frame): + d = dimension(frame) + return sorted([d - dimension(self.labels[self.edges[e][0]]) for e in incoming] + + [dimension(self.labels[self.edges[e][1]]) - d for e in outgoing], reverse=True) + + +def dominates(left, right): + require(len(left) == len(right), "Same priced edges") + if sum(left) != sum(right): + return False + a = b = 0 + for x, y in zip(left, right): + a += x + b += y + if a < b: + return False + return True + + +def certificate(old, new): + if dominates(old, new): + return "majorization" + difference = Counter(new) + difference.subtract(old) + key = tuple(sorted((r, n) for r, n in difference.items() if r and n)) + require(key in EXCEPTIONS, "Unproved moment polynomial: " + str(key)) + return EXCEPTIONS[key] + + +@lru_cache(None) +def interval_spaces(lower, upper): + if lower & upper != lower: + return () + require(dimension(upper) - dimension(lower) <= 4, "Bounded complete quotient enumeration") + found, pending = {lower}, [lower] + vectors = [v for v in range(1, 512) if upper >> v & 1] + for space in pending: + for v in vectors: + if not space >> v & 1: + larger = join(space, span([v])) + if larger not in found: + found.add(larger) + pending.append(larger) + return tuple(sorted(found)) + + +def study(graph): + groups, roots = graph.regions() + free = {r for r, ns in groups.items() if not any(graph.fixed[n] for n in ns)} + counts, witnesses = Counter(), [] + for root in sorted(free): + nodes = groups[root] + inc, out, internal, lower, upper = graph.boundary(nodes) + require(lower & upper == lower, "Nonempty one-region interval") + gap = dimension(upper) - dimension(lower) + require(gap <= 1, "All charts in interval enumerated") + counts["gap_" + str(gap)] += 1 + old = graph.local_ranks(inc, out, graph.labels[nodes[0]]) + for frame in sorted({lower, upper}): + if any(transform(frame, graph.edges[e][2]) != frame for e in internal): + counts["operator_rejected"] += 1 + continue + new = graph.local_ranks(inc, out, frame) + kind = certificate(old, new) + counts[kind] += 1 + witnesses.append([root, list(basis(frame)), old, new, kind]) + pairs = sorted({tuple(sorted((roots[u], roots[v]))) for u, v, m in graph.edges + if m == IDENTITY and roots[u] != roots[v] and roots[u] in free and roots[v] in free}) + fusion = [] + for left, right in pairs: + _, _, _, lower, upper = graph.boundary(groups[left] + groups[right]) + require(lower & upper != lower, "A pair admits constant-chart fusion") + # A literal vector in L outside U is a short, exact infeasibility witness. + vector = next(v for v in basis(lower) if not upper >> v & 1) + fusion.append([left, right, vector]) + adjacent = sorted({tuple(sorted((roots[u], roots[v]))) for u, v, _ in graph.edges + if roots[u] != roots[v] and roots[u] in free and roots[v] in free}) + pair_counts, pair_witnesses = Counter(), [] + for left, right in adjacent: + a, b = set(groups[left]), set(groups[right]) + both = a | b + touched = sorted({e for n in both for e in graph.incoming[n] + graph.outgoing[n]}) + + def options(nodes): + lower, upper = 1, FULL + for n in nodes: + for e in graph.incoming[n]: + u, _, matrix = graph.edges[e] + if u not in both: + lower = join(lower, transform(graph.labels[u], matrix)) + for e in graph.outgoing[n]: + _, v, matrix = graph.edges[e] + if v not in both: + upper &= transform(graph.labels[v], inverse(matrix)) + return interval_spaces(lower, upper) + + aa, bb = options(a), options(b) + pair_counts["candidate_assignments"] += len(aa) * len(bb) + old = sorted([dimension(graph.labels[graph.edges[e][1]]) - dimension(graph.labels[graph.edges[e][0]]) + for e in touched], reverse=True) + for fa in aa: + for fb in bb: + def value(n): + return fa if n in a else fb if n in b else graph.labels[n] + + ranks, valid = [], True + for e in touched: + u, v, matrix = graph.edges[e] + before, after = value(u), value(v) + image = transform(before, matrix) + if image & after != image: + valid = False + break + ranks.append(dimension(after) - dimension(before)) + if not valid: + continue + new = sorted(ranks, reverse=True) + kind = certificate(old, new) + pair_counts[kind] += 1 + pair_counts["feasible_assignments"] += 1 + pair_witnesses.append([left, right, list(basis(fa)), list(basis(fb)), kind]) + return { + "nodes": len(graph.labels), "edges": len(graph.edges), + "regions": len(groups), "free_regions": len(free), + "paid": dict(sorted(graph.histogram().items())), + "single_region_counts": dict(sorted(counts.items())), + "single_region_witnesses": witnesses, + "infeasible_identity_edge_fusions": fusion, + "adjacent_region_pairs": len(adjacent), + "two_region_counts": dict(sorted(pair_counts.items())), + "two_region_witnesses": pair_witnesses, + } diff --git a/research/swap-contact-fusion-gate/inputs/LICENSE b/research/swap-contact-fusion-gate/inputs/LICENSE new file mode 100644 index 0000000000..261eeb9e9f --- /dev/null +++ b/research/swap-contact-fusion-gate/inputs/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/research/swap-contact-fusion-gate/inputs/NOTICE b/research/swap-contact-fusion-gate/inputs/NOTICE new file mode 100644 index 0000000000..faa0f8ce7f --- /dev/null +++ b/research/swap-contact-fusion-gate/inputs/NOTICE @@ -0,0 +1,7 @@ +Cao Yifan / intqwq: authenticated joint-helper/native-map round-three word, canonical research/kappa-round3-warp-20261022, commit 624de9dc66858af0945e5f8a0942488d62280d43; PR4610 lineage. +Cinna Davis: PR4694 center-free/cache kernel and arbitrary-input raw dual, PR4698 cold-helper basis/conditional consumer; PR4440/4441/4447/4470 lineage. +Dugongue: present ground-chart helper pre-compensation and explicit invertible coded offer, with substantial OpenAI Codex assistance. +Retains native, E8, scalar, Clifford, compiler, precision, outer and contributor notices in the cited upstream sources; zxv, Jacob Alan Sussman, DaysSky, Nick Petalas and Ryanson Jonathan retain predecessor credit. +Apache-2.0. No independent human or formal proof-kernel review is claimed. + +Rohan Arun: PR1931 involutive source reflection and source-restored shear; Ali Romman: PR1862 broader source-code/repair family. Current 632-owner port and dyadic completion prepared by Dugongue with substantial OpenAI Codex assistance. Apache-2.0. diff --git a/research/swap-contact-fusion-gate/inputs/ORIGINS.json b/research/swap-contact-fusion-gate/inputs/ORIGINS.json new file mode 100644 index 0000000000..8815cdb6d9 --- /dev/null +++ b/research/swap-contact-fusion-gate/inputs/ORIGINS.json @@ -0,0 +1,44 @@ +[ + { + "file": "LICENSE", + "origin_commit": "0130b196145a43a7d305de41f49e56e8e8556378", + "origin_path": "research/native-frame-carrying-swaps/LICENSE", + "git_blob": "261eeb9e9f8b2b4b0d119366dda99c6fd7d35c64", + "sha256": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4" + }, + { + "file": "NOTICE", + "origin_commit": "0130b196145a43a7d305de41f49e56e8e8556378", + "origin_path": "research/native-frame-carrying-swaps/NOTICE", + "git_blob": "faa0f8ce7f3dfb9b7095302d60a37469cea91da4", + "sha256": "57d5bcf4f205d6d4c16eb81f37c5a1ab0c99185de26978cab99f0ce82b3147f0" + }, + { + "file": "RESULT.json", + "origin_commit": "0130b196145a43a7d305de41f49e56e8e8556378", + "origin_path": "research/native-frame-carrying-swaps/RESULT.json", + "git_blob": "d700df66fcc7e35fe15daf585220fd6b6742d776", + "sha256": "36dda716de598a09723c8a4d5e20ea2ad4c5b092f4f8bfd0946dcb19c7a76d9b" + }, + { + "file": "SOURCE-WORD.json.gz", + "origin_commit": "0130b196145a43a7d305de41f49e56e8e8556378", + "origin_path": "research/native-frame-carrying-swaps/SOURCE-WORD.json.gz", + "git_blob": "46d929df83817b85a5387bcdb9745e0627d6366e", + "sha256": "7679daa4ec6a40f56fc7f0202379a6f454310e94945aba4f48beaaaafb838d05" + }, + { + "file": "native_core.py", + "origin_commit": "0130b196145a43a7d305de41f49e56e8e8556378", + "origin_path": "research/native-frame-carrying-swaps/native_core.py", + "git_blob": "72bbd2fecb2134967e6cd6e2a7cfddfe9fd4ad2b", + "sha256": "c510b8c171a57a92b2cfe2ad516cde00fa8a1148b457bb8de2197635e37f3296" + }, + { + "file": "verify.py", + "origin_commit": "0130b196145a43a7d305de41f49e56e8e8556378", + "origin_path": "research/native-frame-carrying-swaps/verify.py", + "git_blob": "88aa08b7d54cdae5b2c6696fe96a73a9ae89debf", + "sha256": "9e536497b6bf5a1162a933c1aef0ff079f1ec21996095ccfeda40252e0b7b3dd" + } +] diff --git a/research/swap-contact-fusion-gate/inputs/RESULT.json b/research/swap-contact-fusion-gate/inputs/RESULT.json new file mode 100644 index 0000000000..d700df66fc --- /dev/null +++ b/research/swap-contact-fusion-gate/inputs/RESULT.json @@ -0,0 +1,34 @@ +{ + "source_payload_sha256": "cfcd36b40326d7a5815e1db5313444379b3fb756b27d5201c561574c085cc0dd", + "scope": "Exact normalized all-input and chronological-frame control. Inherited native physical maps remain source premises; no new kappa.", + "forward": { + "frame_carry_mutation_rejected": true, + "swaps": 534, + "unequal_input_frames": 43, + "paid": { + "1": 2201, + "3": 510, + "2": 412, + "4": 127, + "8": 8, + "5": 40 + }, + "rows_checked": 632, + "wrong_sign_rejected": true + }, + "backward": { + "frame_carry_mutation_rejected": true, + "swaps": 534, + "unequal_input_frames": 43, + "paid": { + "1": 2201, + "3": 510, + "2": 412, + "4": 127, + "8": 8, + "5": 40 + }, + "rows_checked": 632, + "wrong_sign_rejected": true + } +} diff --git a/research/swap-contact-fusion-gate/inputs/SOURCE-WORD.json.gz b/research/swap-contact-fusion-gate/inputs/SOURCE-WORD.json.gz new file mode 100644 index 0000000000..46d929df83 Binary files /dev/null and b/research/swap-contact-fusion-gate/inputs/SOURCE-WORD.json.gz differ diff --git a/research/swap-contact-fusion-gate/inputs/native_core.py b/research/swap-contact-fusion-gate/inputs/native_core.py new file mode 100644 index 0000000000..72bbd2fecb --- /dev/null +++ b/research/swap-contact-fusion-gate/inputs/native_core.py @@ -0,0 +1,73 @@ +"""Exact source-bound coded-supplier replay core. Apache-2.0; Codex assistance. +Frozen source: Cao Yifan #4610 and retained Cinna Davis/Dugongue lineage. +""" +from pathlib import Path +from fractions import Fraction as Q +from collections import Counter +from hashlib import sha256 +import gzip,json,copy,importlib.util,sys +HERE=Path(__file__).resolve().parent +SOURCE_SHA='cfcd36b40326d7a5815e1db5313444379b3fb756b27d5201c561574c085cc0dd' +def need(c,m): + if not c:raise ValueError(m) +def identity(i):return {(i,()):Q(1)} +def add(dst,src,a): + for k,v in tuple(src.items()): + z=dst.get(k,Q(0))+a*v + if z:dst[k]=z + else:dst.pop(k,None) +def warp(row,op,back): + s=(1 if op>0 else -1)*(abs(op)+(1000000 if back else 0));out={} + for (v,w),a in row.items(): + ww=w[1:]if w and w[0]==-s else(s,)+w;out[v,ww]=out.get((v,ww),Q(0))+a + return {k:a for k,a in out.items()if a} +def expected(i,back): + r=identity(i) + if back and i<112:add(r,identity(i+112),-1) + if not back and 112<=i<224:add(r,identity(i-112),1) + return r + +def replay(c,program,back=False,check_frames=True): + rows={i:identity(i)for i in range(632)};rows[632]={};cur=c['start'][:]+[None];paid=Counter();maxnorm=Q(1) + for e in program: + if e[0]=='scalar': + g,f=e[1:];r=g[1][1]+(632 if g[1][0]=='C'else 0) + if g[0]=='clear':need(r==632,'Borrowed erasure');rows[r]={};cur[r]=f + else: + if check_frames:need(cur[r]==f,'Scalar target frame') + if g[0]in('add','copy'): + v=g[2][1]+(632 if g[2][0]=='C'else 0) + if check_frames:need(cur[v]==f,'Scalar source frame') + if g[0]=='copy':need(r==632,'Borrowed overwrite');rows[r]=rows[v].copy() + else:need(r!=v,'Self add');add(rows[r],rows[v],Q(g[3],g[4])) + elif g[0]=='scale':rows[r]={k:Q(g[2],g[3])*v for k,v in rows[r].items()} + else:raise ValueError('Scalar opcode') + maxnorm=max(maxnorm,sum(map(abs,rows[r].values()),Q(0))) + elif e[0]=='warp': + _,r,op,x,y=e;r=r[1]+(632 if r[0]=='C'else 0) + if check_frames:need(cur[r]==x,'Warp source frame') + rows[r]=warp(rows[r],op,back);cur[r]=y + elif e[0]=='climb': + _,_,r,x,y,k=e + if check_frames:need(cur[r]==x,'Climb source frame') + need(k==len(c['frames'][y])-len(c['frames'][x])and k>0,'Ascending paid rank');cur[r]=y;paid[k]+=1 + elif e[0]=='center': + _,r,x,y,k=e;r+=632 + if check_frames:need(cur[r]==x,'Center source frame') + need(k==abs(len(c['frames'][y])-len(c['frames'][x])),'Center paid rank');cur[r]=y;paid[k]+=1 + else:need(e[0]in('phase','adapter','residual_adapter'),'Unknown opcode') + need(cur[:632]==c['final'],'Final frames');need(not rows[632],'Owned field cleared') + return rows,paid,maxnorm + +def clear_centers(program):return [['scalar',['clear',['C',e[1]]],e[3]]if e[0]=='center'else copy.deepcopy(e)for e in program] +def error_kernel(a): + rows,paid,_=replay(a['canonical'],clear_centers(a['programs']['forward']));E=[] + for i in range(632): + err=rows[i].copy();add(err,expected(i,False),-1) + for (j,w),v in sorted(err.items()): + need(112<=i<224 and(j<112 or j>=224),'Strict triangular error block');need(not w,'Constant owner kernel') + need(a['canonical']['final'][j]==1,'Repair source final full frame');need(j<112 or a['canonical']['start'][j]==0,'Pre-repair source initial ground') + E.append((i,j,v)) + need(len(E)==12532,'Frozen error term count') + return E + diff --git a/research/swap-contact-fusion-gate/inputs/verify.py b/research/swap-contact-fusion-gate/inputs/verify.py new file mode 100644 index 0000000000..88aa08b7d5 --- /dev/null +++ b/research/swap-contact-fusion-gate/inputs/verify.py @@ -0,0 +1,95 @@ +from pathlib import Path +from fractions import Fraction as Q +from collections import Counter +import sys,json,gzip,hashlib,copy +P=Path(__file__).resolve().parent +S=P +if hashlib.sha256((S/'native_core.py').read_bytes()).hexdigest() != 'c510b8c171a57a92b2cfe2ad516cde00fa8a1148b457bb8de2197635e37f3296': raise ValueError('Retained core hash') +sys.path.insert(0,str(S));import native_core as V +raw=gzip.decompress((S/'SOURCE-WORD.json.gz').read_bytes()) +V.need(hashlib.sha256(raw).hexdigest()==V.SOURCE_SHA,'Frozen source payload') +a=json.loads(raw);c=a['canonical'] +def space(b): + s={0} + for v in b:s|={x^v for x in tuple(s)} + return s +spaces=list(map(space,c['frames'])) + +def construct(program): + p=[copy.deepcopy(e)for e in program if e[0]!='climb'];cur=c['start'][:];out=[];count=0;i=0;unequal=0 + def climb(r,f): + old=cur[r] + if old!=f: + V.need(spaces[old] 0) + mutant_graph.labels[edge[1]] = span([]) + try: + mutant_graph.validate() + except ValueError: + checks.append("broken_edge_containment") + else: + raise ValueError("Broken graph containment accepted") + return checks + + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument("--write", action="store_true", help="Regenerate only this package's RESULT.json") + args = parser.parse_args() + source = load_source() + output = {"scope": "Exact at-most-two-region moment and adjacent identity-edge fusion gate; inherited physical maps, no new kappa.", + "source_payload_sha256": source["V"].SOURCE_SHA, "orientations": {}} + for direction in ("forward", "backward"): + word, swaps, unequal = source["construct"](source["a"]["programs"][direction]) + graph = Graph(source["c"], word) + require(dict(graph.histogram()) == source["res"][direction]["paid"], "Graph recount equals actual paid profile") + result = study(graph) + result.update(swaps=swaps, unequal_swaps=unequal, mutation_controls=controls(source["c"], word, graph)) + output["orientations"][direction] = result + require(set(interval_spaces(span([]), span([1, 2]))) == {span([]), span([1]), span([2]), span([3]), span([1, 2])}, + "Complete interval includes noncoordinate quotient lines") + for old, new in (([1, 1], [2, 0]), ([1], [0])): + try: + certificate(old, new) + except ValueError: + pass + else: + raise ValueError("Profitable or undercharged mutation accepted") + output["additional_controls"] = ["noncoordinate_quotient_line", "profitable_fusion_rejected", "omitted_paid_rank_rejected"] + # Exact integer premises used in PROOF.md's two derivative arguments. + require(3**5 < 2**8 and 8 * 5**3 - 8**3 - 2 * 5**3 > 0, "Four/three/two logarithm bounds") + require(2**23 < 5**10 and 23**3 > 11 * 10**3, "Five/four/three/two logarithm bounds") + require(16 < 27 and 375 < 32768 and 5**15 * 27 < 2**42, "Negative endpoint derivatives") + witnesses = {} + for direction, result in output["orientations"].items(): + witnesses[direction] = {key: result.pop(key) for key in ( + "single_region_witnesses", "two_region_witnesses", "infeasible_identity_edge_fusions")} + witness_bytes = json.dumps(witnesses, sort_keys=True, separators=(",", ":")).encode() + output["witness_payload_sha256"] = sha256(witness_bytes).hexdigest() + output = json.loads(json.dumps(output)) + path = HERE / "RESULT.json" + witness_path = HERE / "WITNESSES.json.gz" + if args.write: + path.write_text(json.dumps(output, indent=2) + "\n") + witness_path.write_bytes(gzip.compress(witness_bytes, mtime=0)) + else: + require(output == json.loads(path.read_text()), "Committed exact result matches replay") + require(witness_bytes == gzip.decompress(witness_path.read_bytes()), "Every exact witness matches replay") + for direction, result in output["orientations"].items(): + print(direction, {k: v for k, v in result.items() if not k.endswith("witnesses") and k != "infeasible_identity_edge_fusions"}) + print("PASS_SWAP_CONTACT_FUSION_GATE no_new_kappa") + + +if __name__ == "__main__": + main()