#!/usr/bin/env python3 # -*- coding: utf-8 -*- """The end-to-end conditional implication of the twin-prime target, as an executable graph. WHAT THIS IS. One object, in one place: the chain from "infinitely many twin primes" down to the concrete estimates the corpus is actually working on, with every node carrying (a) a calibration tag from a fixed vocabulary, (b) the owning document or return, (c) the exact textual tokens that make the node's numbers checkable against that owner, and (d) its edges. Edges come in three kinds and only one of them is used by the engine: routes a disjunction of conjunctions: each route is a list of node ids that TOGETHER imply the node; several routes are alternative sufficient conditions. This is the engine's only input, and it is the shape every mathematical "it suffices to prove X" statement has. supports informational: classical inputs or context that establish the node (Vaughan, PNT, BV). attempted informational: attacks that were tried at the node and did not close it. A closed attack is evidence, not a gate: the engine never derives anything through it. TAGS (fixed vocabulary, mapped to the corpus's own calibration words in the report): published an external theorem, cited, not reproved here derived an in-corpus derivation, reviewed, no new estimate proved_conditional proved modulo a named input numeric verified or measured by computation analysis a stated analysis, explicitly NOT a theorem open an open obligation refuted closed/refuted at its stated scope (a failed bound, a closed route) ESTABLISHED = published|derived|proved_conditional|numeric|analysis. ONLY open and refuted block. QUERIES. `derive(n)` = tag(n) is ESTABLISHED, or some route of n has all its members derivable. frontier the open nodes the root reaches, split into obligations and attempts branches one row per consumer: its conjunction, its cheapest closure, its irreplaceable members cheapest the smallest set of named obligations that must be closed for the root, by route fatal nodes whose single deletion kills the root (the structural single points of failure) impact n the nodes that stop being derivable if n is deleted -- for a closed attack, EMPTY verify every node's tokens checked literally against its cited local document or return Usage: python work/tpc_deps.py selftest # graph invariants + determinism + verify python work/tpc_deps.py verify # source-token gate only python work/tpc_deps.py frontier|branches|cheapest|fatal python work/tpc_deps.py impact python work/tpc_deps.py show python work/tpc_deps.py render # the markdown tables used by the report python work/tpc_deps.py json # artifacts/tpc-deps.json """ import json import os import re import sys sys.stdout.reconfigure(encoding="utf-8", errors="replace") RUN = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) DOCS = os.path.join(RUN, "evidence", "docs") RETS = os.path.join(RUN, "evidence", "returns") ESTABLISHED = {"published", "derived", "proved_conditional", "numeric", "analysis"} BLOCKING = {"open", "refuted"} TAGS = ESTABLISHED | BLOCKING ROOT = "TPC" def N(id, tag, title, statement, owner, routes=(), supports=(), attempted=(), src=(), note=None, role=None): return {"id": id, "tag": tag, "title": title, "statement": statement, "owner": owner, "routes": [list(r) for r in routes], "supports": list(supports), "attempted": list(attempted), "src": [dict(s) for s in src], "note": note, "role": role} # --------------------------------------------------------------------------------------------------- # The graph. Every `src` entry is a local file that must contain every token listed with it; that is # the gate that keeps this document from drifting away from the corpus it claims to summarise. # --------------------------------------------------------------------------------------------------- NODES = [ # ---------- the target, and the two independent consumers -------------------------------------- N("TPC", "open", "The target", "There are infinitely many twin primes.", "docs/README.md, Status", routes=[["ZONE-WEAK"], ["MARGIN-SHRINK"], ["CENTERED-MARGIN"], ["B-MARGIN"]], supports=["EQ-ZONE-TPC"], src=[{"doc": "README.md", "tokens": ["No proof or demonstrated route"]}], note="Two sufficient consumers exist and they are independent: zone occupancy (a Jacobsthal " "exponent) and the signed arithmetic margin. The failure of one does not close the " "programme, and no accumulated partial progress in one transfers to the other.", role="target"), N("EQ-ZONE-TPC", "derived", "Zone weak form == TPC", "The weak Zone Postulate is equivalent to TPC, both directions, elementary.", "research/ZONE-POSTULATE.md section 2", src=[{"doc": "research__ZONE-POSTULATE.md", "tokens": ["weak form is equivalent to the Twin Prime Conjecture"]}], note="So the zone branch is not a weakening of the target: it IS the target in primality-free " "language.", role="equivalence"), # ---------- branch 1: zone occupancy ---------------------------------------------------------- N("ZONE-WEAK", "open", "Zone Postulate, weak form", "For infinitely many primes p, the first twin slot of the tile T_p lies below p'^2 - 2.", "research/ZONE-POSTULATE.md sections 1-2", routes=[["GAP-INF"]], supports=["EQ-ZONE-TPC", "GAP-REFORM", "ZONE-VERIFIED", "PARITY-ANALYSIS"], attempted=["LEMMA-V-MS", "USUP", "BOOLE-FRECHET", "TILE-FLOORS"], src=[{"doc": "research__ZONE-POSTULATE.md", "tokens": ["Zone Postulate (weak form)"]}], note="The corpus's own verdict: the obstruction is named; none of the four attack routes " "closes it.", role="obligation"), N("GAP-REFORM", "derived", "The Gap Reformulation", "G2(p#) < p'^2 - 2 implies the zone at p is occupied; since ln(p#) ~ p the window p^2 is " "(log q)^2, so the sufficient condition is a two-class Jacobsthal exponent below 2.", "research/ZONE-POSTULATE.md section 3", src=[{"doc": "research__G2-STATE.md", "tokens": ["two-class Jacobsthal exponent below 2"]}], role="reduction"), N("GAP-INF", "open", "Jacobsthal exponent below 2, infinitely often", "G2(q) << (log q)^(2-delta) for some fixed delta > 0, infinitely often.", "research/ZONE-POSTULATE.md section 3; research/G2-STATE.md section 6", supports=["GAP-DHR-BOUND", "GAP-BAND", "ZONE-VERIFIED", "PARITY-ANALYSIS", "LADDER"], attempted=["LEMMA-V-MS", "USUP", "BOOLE-FRECHET", "TILE-FLOORS"], src=[{"doc": "research__ZONE-POSTULATE.md", "tokens": ["4.2665"]}], note="The distance is 4.2665 against 2. A perfect distribution oracle moves the exponent by " "nothing: the missing ingredient is a positivity/cancellation statement, not a " "distribution statement.", role="obligation"), N("GAP-DHR-BOUND", "published", "The achieved bound", "G2(x#) <<_eps x^(4.266450284...+eps) by the dimension-2 sieve in primorial formulation (DHR).", "paper/beta2-note.md; docs/README.md Status", src=[{"doc": "README.md", "tokens": ["4.266450284"]}], note="The first two-class bound at any exponent. The constant is an achieved sifting limit, " "not a proved floor.", role="ceiling"), N("GAP-BAND", "derived", "The open band", "The open band is (2, 4.2665]; the threshold is an achieved dimension-2 sifting limit, and " "Selberg's 4 is a conjecture, not a proved floor.", "docs/README.md, Status, points 1-3", src=[{"doc": "README.md", "tokens": ["achieved dimension-2 sifting limit"]}], role="ceiling"), N("PARITY-ANALYSIS", "analysis", "Not a distribution problem", "All five discard points of the dimension-2 sieve were mapped; distribution hypotheses enter " "at exactly one, which the primorial formulation already saturates. A perfect distribution " "oracle moves the exponent by nothing.", "research/ZONE-POSTULATE.md section 3 (ANALYSIS, not a theorem)", src=[{"doc": "research__ZONE-POSTULATE.md", "tokens": ["positivity problem"]}, {"doc": "research__ZONE-POSTULATE.md", "tokens": ["distribution oracle"]}], role="analysis"), N("ZONE-VERIFIED", "numeric", "Exhaustive verification to 10^11", "The strong form holds for every prime up to 10^11: 4,118,054,813 primes, 224,376,048 twin " "pairs, zero failures (599 s, segmented sieve).", "research/window-check.js; research/ZONE-POSTULATE.md section 4", src=[{"doc": "research__ZONE-POSTULATE.md", "tokens": ["4,118,054,813", "224,376,048"]}], note="Finite evidence. It is not an asymptotic statement and it is not evidence about the " "exponent.", role="measurement"), N("LEMMA-V-MS", "derived", "Lemma V, mean-square form", "The mean-square form of Lemma V is proved unconditionally, which changes the status of the " "vector-sieve estimate -- but the almost-all exponent it buys is 0, so on its own it moves " "nothing.", "research/sift-limit-attack.md section 7e; ZONE-POSTULATE.md preamble", src=[{"doc": "research__ZONE-POSTULATE.md", "tokens": ["almost-all exponent"]}], note="A status change, not a gain. Explicitly not counted as progress toward the exponent.", role="attempt"), N("USUP", "refuted", "The u_sup bound", "u_sup read below 4.26645 on four points and was closed the same day: extended to nine points " "over z = 13..43 it rises at every step to 3.2026, and the bounded family's best asymptote is " "5.46, above beta_2.", "research/sift-limit-attack.md section 7e; research/G2-STATE.md", src=[{"doc": "research__ZONE-POSTULATE.md", "tokens": ["3.2026", "5.46"]}], role="closed-attack"), N("BOOLE-FRECHET", "refuted", "The Boole-Frechet certificate", "The degree-k Boole-Frechet certificate is unconditional and all-positions but certifies " "about (x#)^(1/(2 floor(k/2))), exponential in x at every fixed degree; the degree it needs " "diverges like x/(B log x) under any polynomial bound O(x^B).", "research/sift-limit-attack.md section 7e; history/staging/attack-bonferroni-degree.md", src=[{"doc": "research__ZONE-POSTULATE.md", "tokens": ["Boole"]}], note="DP1 carries 71% of the loss, and as of 2026-08-19 its one known mechanism is closed " "with a theorem. A closed attack, not a closed programme.", role="closed-attack"), N("TILE-FLOORS", "refuted", "Certified per-tile floors", "History-blind per-prime caps force survivors by pigeonhole, giving certified twin counts at " "six levels without locating a strike -- but they certify twins in a tile, not in a zone, and " "do not scale to infinitude.", "paper/staircase-note.md; research/ZONE-POSTULATE.md section 3", src=[{"doc": "research__ZONE-POSTULATE.md", "tokens": ["Certified per-tile floors"]}], role="closed-attack"), # ---------- branch 2: the signed arithmetic margin --------------------------------------------- N("MARGIN-SHRINK", "open", "Sufficient signed margin", "C2 x + E_dagger(x) >= c0 x/(log x)^K for fixed c0 > 0, K >= 0, on an unbounded set of dyadic " "x.", "research/RESEARCH-HANDOFF.md section 3", routes=[["REDUCTION", "BOX-CONTROL", "COMPLEMENT"]], supports=["REDUCTION", "CONSUMER-COUNT", "CONTROLLED-REGIONS", "EXTREMAL-CEILING", "CORNER"], attempted=["SMOOTH-ABS"], src=[{"doc": "README.md", "tokens": ["R>=-C2*x+c*x/log^K x"]}], note="THE target of the arithmetic campaign. Its three sufficient forms (fixed fraction; " "shrinking margin; block-summed) are equivalent up to constants with existential " "positive constants; all three OPEN. The reduction does not permit H or K to grow " "with x.", role="obligation"), N("CONSUMER-COUNT", "derived", "The consumer deduction", "MARGIN-SHRINK gives at least (c0/2)*x/log^(K+2) x actual prime pairs on the witnessing " "scales, i.e. infinitely many twins on unbounded dyadic scales.", "research/RESEARCH-HANDOFF.md section 3", src=[{"doc": "research__RESEARCH-HANDOFF.md", "tokens": ["(c0/2)*x/log^(K+2) x"]}], role="consumer"), N("REDUCTION", "derived", "The checked reduction", "S(x) = sum_{n in J_x} Lambda(n)Lambda(n-2) = C2 x + E_dagger(x) + O_H(x/log^H x) for every " "fixed H > 0, with E_dagger the exact weighted compatible CRT endpoint sum on the " "four-condition domain W_dagger. Its premises are the six classical inputs below; the " "reduction itself is a premises of the sufficient margin, not a fact that stands beside " "it.", "research/TWIN-REDUCTION.md section 1; research/RESEARCH-HANDOFF.md section 3", supports=["VAUGHAN", "PNT", "BV-LAMBDA", "BV-MU", "EXCLUDED-MEANS"], src=[{"doc": "research__TWIN-REDUCTION.md", "tokens": ["reviewed three times"]}], note="Derived, adjudicated three times (2026-09-06), no defect found. Constants are " "ineffective: Siegel-Walfisz enters, so no effective numerical onset is supplied.", role="reduction"), N("VAUGHAN", "published", "Vaughan's identity", "Vaughan's identity applied to Lambda(n) and then to Lambda(n-2).", "research/TWIN-REDUCTION.md section 1", src=[{"doc": "research__TWIN-REDUCTION.md", "tokens": ["Vaughan's identity"]}], role="classical"), N("PNT", "published", "Quantitative PNT", "The main term C2 x is carried by the quantitative prime number theorem.", "research/TWIN-REDUCTION.md section 1", src=[{"doc": "research__TWIN-REDUCTION.md", "tokens": ["quantitative PNT"]}], role="classical"), N("BV-LAMBDA", "published", "Bombieri-Vinogradov for Lambda", "BV at level x^(12/25) carries the Type I comparison.", "research/TWIN-REDUCTION.md section 1", src=[{"doc": "research__TWIN-REDUCTION.md", "tokens": ["level x^(12/25)"]}], role="classical"), N("BV-MU", "published", "Mobius Bombieri-Vinogradov", "The Mobius BV input at level x^(1/10) had no published statement and is derived from four " "numbered results of Koukoulopoulos GSM 203; itself reviewed.", "research/mobius-bv-derivation.md; research/TWIN-REDUCTION.md section 1", src=[{"doc": "research__TWIN-REDUCTION.md", "tokens": ["x^(1/10)"]}], role="classical"), N("EXCLUDED-MEANS", "published", "Excluded-prime Mobius means", "Two excluded-prime Mobius mean estimates carry the last classical pieces to the first " "endpoint remainder.", "research/TWIN-REDUCTION.md section 1", src=[{"doc": "research__TWIN-REDUCTION.md", "tokens": ["excluded-prime"]}], role="classical"), N("BOX-CONTROL", "open", "The witness box, controlled", "At the witness box the signed ordered-pair sum is bounded with a fixed power saving, " "uniformly over the actual coefficient classes, support boxes, harmonic bands, endpoints and " "required twists.", "research/RESEARCH-HANDOFF.md section 5", routes=[["X-SMALL"], ["D1-BLOCK"]], supports=["CONTROLLED-REGIONS", "EXTREMAL-CEILING"], src=[{"doc": "research__RESEARCH-HANDOFF.md", "tokens": ["36/25-eta"]}], note="TWO DISTINCT TARGETS LIVE HERE AND THEY ARE NOT SUBSTITUTABLE. The native orientation " "needs a saving strictly greater than 3/50 (generic top moment exponent 3/2); the " "structured fixed-q sector needs more than 7/200 (block exponent 407/400). The corpus " "warns in its own words that these belong to different Cauchy arrangements and that one " "exponent must not be substituted into the other's sum.", role="obligation"), N("X-SMALL", "open", "Native orientation: saving > 3/50", "One-sided bound X_small <= C x^(36/25-eta) for some fixed eta > 0, uniformly over the " "actual coefficients, boxes, bands, endpoints and twists; an absolute bound suffices but is " "stronger. The generic top moment exponent is 3/2, so a saving strictly greater than 3/50 is " "needed.", "research/RESEARCH-HANDOFF.md section 5", attempted=["SMALL-DIVISOR-KERNEL", "DFI", "SPECTRAL-DIAG", "TYPE-I-II", "FKM", "WRIGHT", "GURIA", "DET-COROLLARY", "CHOWLA-FAMILY"], src=[{"doc": "research__RESEARCH-HANDOFF.md", "tokens": ["3/50 is needed"]}], note="At a saving of exactly 3/50 there is no fixed slack. Eleven priced interfaces have " "been tried at this object and none closes it; none of them says anything about the " "sign or size of the actual correlation.", role="obligation"), N("D1-BLOCK", "open", "Structured sector: saving > 7/200", "A bound for the actual nonzero-R small-j_e moment below x^(139/100) with fixed slack controls " "the top sector sigma = 1/20; the needed saving is greater than 7/200.", "research/structured-dispersion-estimate.md; research/RESEARCH-HANDOFF.md section 5", routes=[["D1-SMALL-GCD"]], supports=["D1-ACCOUNTING"], src=[{"doc": "research__RESEARCH-HANDOFF.md", "tokens": ["139/100"]}], note="Even proving this controls only this one rectangle; it does not prove the global margin.", role="obligation"), N("D1-ACCOUNTING", "derived", "The block accounting", "Top sector sigma = 1/20, a = 14/25, b = 1/2: moment majorant Q^(3/2)E^3 -> exponent 57/40; " "Cauchy factor MQ -> 61/100; resulting block exponent 407/400 > 1.", "research/structured-dispersion-estimate.md; research/RESEARCH-HANDOFF.md section 5", src=[{"doc": "research__RESEARCH-HANDOFF.md", "tokens": ["57/40", "61/100", "407/400"]}], note="The return's 17/200 and 17/300 were arithmetic errors, corrected in the 2026-09-09 " "review.", role="accounting"), N("D1-SMALL-GCD", "open", "The remaining small-gcd range", "The factor j_e^(-3/2) already pays the needed 7/200 for j_e > x^(7/300+eps) with fixed " "eps > 0; no such improvement is proved for the remaining small-gcd range, and it is the " "only piece of the sector left.", "research/structured-dispersion-estimate.md; research/RESEARCH-HANDOFF.md section 5", attempted=["S-FAMILY-CEILING", "ROUTE48-RANGE-INPUT", "UNBALANCED-BAND", "PARSEVAL-L2", "FOUR-CLASS-SPLIT", "G-HALF-ETA"], src=[{"doc": "research__RESEARCH-HANDOFF.md", "tokens": ["7/300"]}], note="This is the single object this run's windows 1562-1569 attacked, from six independent " "directions. Five of the six are now closed scopes; one is blocked on a named " "literature input.", role="obligation"), N("S-FAMILY-CEILING", "derived", "Fixed-modulus family ceiling", "The fixed-modulus bilinear Kloosterman family of arXiv:2607.24311v1 tops out at a saving of " "7/380 in c-units against a requirement of 7/190 -- exactly half -- and its one " "composite-modulus term (Theorem 5.2's square-full term) is inert at the record's c2, which " "sits x^0.330 and x^0.296 below the tie thresholds.", "return 780 (route 48 triage); sibling return 632", src=[{"return": 780, "tokens": ["7/380", "7/190"]}], note="The losing step is the LENGTH RATIO: one of the record's two lengths lies below the " "paper's whole improvement window. A scoped ceiling of one family, not an impossibility " "statement.", role="ceiling"), N("ROUTE48-RANGE-INPUT", "open", "Range coverage at composite modulus", "The cell is a short-length Kloosterman-FRACTION form (family F: e(a m_bar/(b n)), " "denominator variable in the summation), disjoint from the fixed-modulus family S; what is " "needed is a published statement covering lengths n^(o(1))..n^0.21 at composite modulus.", "return 778 (route 48 proposal, accepted as route 48)", src=[{"return": 778, "tokens": ["Kloosterman"]}], note="Blocked, not refuted: the block is the COVERAGE of a length range by the published " "literature, and the requirement is weak -- any c^(-delta) for any delta > 0 suffices, " "since the deficit is one logarithm and log y = c^(o(1)).", role="blocked-obligation"), N("UNBALANCED-BAND", "open", "One logarithm of decorrelation", "The nu-mass sits inside the critical scale (1 - F = pi^-2 sqrt(n/L^2)), so the objection of " "form is lifted; the deficit localises in the unbalanced band, where the signed-to-absolute " "ratio measures 2.87 / 13.98 / 55.54 at x = 13 / 17 / 19 and GROWS with x, i.e. the phases " "reinforce exactly where a saving requires them to cancel. The requirement there is one " "logarithm of decorrelation.", "return 777 (job 1565), the two pre-registered measurements", src=[{"return": 777, "tokens": ["nu"]}], note="Measured, with a positive control: the same enumeration reproduces the corpus " "producer's own R ln y numbers. The requirement is logarithmic, which is the weakest " "requirement anywhere in the graph -- and the band is the complement of the balanced " "case in which the published Example 1.3 delivers c^(-1/12).", role="obligation"), N("PARSEVAL-L2", "refuted", "Parseval / l2 substitution", "Replacing the uniform/variation bound on the edge weight by its exact l2 mass " "(sum_t |w_hat(t)|^2 = cM) does not buy the factor x^(7/25): the gain appears locally and is " "repaid by the sums that the uniform bound was absorbing.", "return 762 family (windows 1552-1569); work/T791-linfty-vs-l2.md", src=[{"doc": "research__structured-dispersion-estimate.md", "tokens": ["407/400"]}], role="closed-attack"), N("FOUR-CLASS-SPLIT", "refuted", "The (++/--/+-/-+) splitting", "Splitting the moment into the four sign classes gives saving = 0: the diagonal classes carry " "no usable gain and the mixed classes are only available in absolute value, which is the " "103/100 generic term.", "work/T791-class-split.md (runs 1562-1569)", src=[{"doc": "research__structured-dispersion-estimate.md", "tokens": ["103/100"]}], role="closed-attack"), N("G-HALF-ETA", "refuted", "G^(1/2-eta) alone", "An improvement of the Kloosterman bound of the form sqrt(cG) G^(-eta) does not close the " "407/400 -> 1 step at any eta reachable from the current bound; the required cancellation is " "not a perturbation of the Weil bound at this object.", "work/T791-arithmetic-threshold.md (run 1562-1569)", src=[{"doc": "research__structured-dispersion-estimate.md", "tokens": ["7/200"]}], role="closed-attack"), N("CONTROLLED-REGIONS", "derived", "What the moment already controls", "The grouped and structured moments control, to O_H(x/log^H x), every rectangle with " "delta+nu < 19/25, or 5 delta + 2 nu < 123/50, or (delta < 19/25 and delta + 3 nu < 161/100). " "The uniform product threshold has not moved from 19/25 and the witness (8/25, 11/25) lies " "outside all three regions.", "research/TWIN-REDUCTION.md section 3; research/grouped-divisor-moment.md", src=[{"doc": "research__TWIN-REDUCTION.md", "tokens": ["19/25", "123/50", "161/100", "(8/25, 11/25)"]}], note="Four simultaneous conditions after the 2026-09-08 addition; the fourth removes only a " "strip and changes the summation domain, not the estimates.", role="ceiling"), N("EXTREMAL-CEILING", "derived", "The ceiling of this argument shape", "In the prescribed-exponent corner S_0 = {p < 2 eta_0} and {q < 2 eta_0}, a uniform saving " "gamma reduces the leftover to S_0 exactly at gamma = 2 and at no smaller value; the target " "priced at one box is gamma > 3/50 and, applied uniformly, removes about 3 percent of the " "leftover area. Clearing either edge apart from the corner also costs gamma tending to 2.", "research/reachability-coverage.md; research/TWIN-REDUCTION.md section 4", src=[{"doc": "research__TWIN-REDUCTION.md", "tokens": ["gamma = 2"]}], note="THE MOST IMPORTANT NEGATIVE FACT OF THE ARITHMETIC BRANCH: closing one box, however " "hard, removes about 3 percent of the leftover area. This is why BOX-CONTROL is a " "necessary step and never a sufficient one, and why the graph does not route " "MARGIN-SHRINK through BOX-CONTROL alone. It is a property of one argument shape " "(arbitrary bounded coefficients, one Cauchy in the left divisor, zero frequencies " "bounded absolutely), not an impossibility theorem.", role="ceiling"), N("CORNER", "derived", "The corner is the conclusion", "On S_0 the endpoint sum equals R, and on the exactly-prime cofactors R is a two-point Mobius " "correlation at the fixed shift 2 with nonnegative prime-band weights; relative to its mass " "it needs a log^(2+eps) x saving, where no unconditional saving of any size is known, and " "one-sided control of the full corner is, given the full complement at O_H(x/log^H x), " "inter-derivable with the sufficient margin itself.", "research/corner-correlation.md; research/TWIN-REDUCTION.md section 5", src=[{"doc": "research__TWIN-REDUCTION.md", "tokens": ["two-point Mobius correlation", "no unconditional saving"]}], note="A TRAP NODE. Attacking it head-on is attacking the conclusion: it is the conclusion, " "not a lemma. It is offered here as a route only so that the graph records it, and the " "cheapest-closure query rejects it for that reason: its closure set is the root itself.", role="trap"), N("COMPLEMENT", "open", "The global complement", "The complement of the controlled regions at O_H(x/log^H x), i.e. the control of everything " "the regional estimates do not reach, on unbounded dyadic scales.", "research/RESEARCH-HANDOFF.md sections 3 and 5", attempted=["SMOOTH-ABS"], src=[{"doc": "research__RESEARCH-HANDOFF.md", "tokens": ["unbounded set of dyadic"]}], note="Named together with the box in the corpus's own sufficiency: the box controls one " "rectangle, the consumer needs the whole remainder. This node is the one that makes the " "arithmetic branch a conjunction rather than a single target; it is also the node that " "the completed assignments never addressed.", role="obligation"), N("SMOOTH-EQUIV", "derived", "Complete smooth alternative", "With the fixed C3 profiles, S = C2 x + R_hat + O_H(x/log^H x) and R_hat = E_dagger + " "O_H(x/log^H x), so the same sufficient margins transfer to R_hat.", "research/global-smooth-majorant.md; research/RESEARCH-HANDOFF.md section 3", src=[{"doc": "research__RESEARCH-HANDOFF.md", "tokens": ["Complete smooth"]}], role="equivalence"), N("SMOOTH-ABS", "refuted", "Full absolute O(x) bound", "A full absolute O(x) bound for a C3 profile is available, and it supplies no sufficient " "signed constant; the implied constant does not establish the needed signed comparison. " "The assembly's rule, stated by the corpus itself: a new representation, an absolute O(x) " "bound, an improved local rectangle or a conditional sufficient statement is not the " "estimate.", "research/global-smooth-majorant.md; research/RESEARCH-HANDOFF.md section 1", src=[{"doc": "research__RESEARCH-HANDOFF.md", "tokens": ["supplies no sufficient signed"]}], note="This is the most frequently re-derived dead end of the corpus and the reason tags " "matter: a statement can be PROVEN and still be a failed step.", role="closed-attack"), # ---------- the reviewed fixed-endpoint normalization ------------------------------------------- N("B-EXACT", "derived", "The reviewed endpoint B", "The reviewed continuation fixes the centered endpoint and pays its low Type I term, leaving " "S = C2 x + B + O_A(x/log^A x) with an exact unestimated B.", "research/fixed-endpoint-discrepancy.md; docs/README.md Status", src=[{"doc": "README.md", "tokens": ["exact unestimated B"]}], note="A representation result: it replaces the question about E_dagger with the same question " "about B, in a normalization where the classical term converges slowly -- which is why " "the finite census cannot see the object.", role="reduction"), N("B-MARGIN", "open", "A sufficient signed bound on B", "A signed lower bound on B on unbounded dyadic scales, B >= -(C2 - c0)x + o(x) for a fixed " "c0 > 0, or the logarithmic-rate analogue, is sufficient and remains OPEN.", "docs/README.md Status; research/fixed-endpoint-discrepancy.md", supports=["B-EXACT", "CENTERED-CENSUS"], src=[{"doc": "README.md", "tokens": ["R>=-C2*x+c*x/log^K x"]}], note="A fourth sufficient formulation, in a different normalization from MARGIN-SHRINK. The " "corpus's own warning applies: regional and representation results cannot be added as " "independent gains toward a twin count, and the formulations are not additive with each " "other. They are alternative routes, not a sum.", role="obligation"), # ---------- the centered consumer -------------------------------------------------------------- N("CENTERED-MARGIN", "open", "Centered prime-Mobius discrepancy", "D_y(x) >= -4x/25 + o(x), with D_y the centered prime-Mobius discrepancy of the " "moving-cutoff repair, remains OPEN.", "research/moving-cutoff-parity.md; research/fixed-endpoint-discrepancy.md", supports=["MOVING-CUTOFF-REPAIR", "CENTERED-CENSUS"], src=[{"doc": "README.md", "tokens": ["4x/25"]}], note="A third sufficient consumer, independent of the regional route in its arithmetic " "inputs.", role="obligation"), N("MOVING-CUTOFF-REPAIR", "derived", "The moving-cutoff repair", "The missing lower endpoint in a Murty-Vatwani displayed switch is retained and a complete " "dyadic repair derived; the source repair is not a new discrepancy estimate and not a " "refutation of the surrounding conditional theorem.", "research/moving-cutoff-parity.md", src=[{"doc": "research__moving-cutoff-parity.md", "tokens": ["Murty"]}], role="reduction"), N("CENTERED-CENSUS", "numeric", "Census to 2^38", "A finite census to x = 2^38 refutes neither sufficient form; its D_y comparison is dominated " "by the classical term's slow convergence on the measured range.", "research/centered-discrepancy-measurement.md; docs/README.md Status", src=[{"doc": "README.md", "tokens": ["2^38"]}], note="An honest negative: the measurement is in a regime where the object of interest is " "invisible.", role="measurement"), # ---------- published conditional routes ------------------------------------------------------- N("COND-ROUTES", "published", "Conditional published routes", "The reviewed Murty-Vatwani, Pintz and exceptional-zero routes are matched to the sufficient " "consumer, with their source and hypothesis limits; those conditional inputs are not " "established here.", "research/consumer-comparison.md; research/TWIN-REDUCTION.md section 7", routes=[["COND-INPUTS"]], src=[{"doc": "research__TWIN-REDUCTION.md", "tokens": ["exceptional-zero"]}], role="imported"), N("COND-INPUTS", "open", "The conditional inputs themselves", "The hypothesis of whichever published conditional route is used (an exceptional zero " "configuration, or the corresponding distribution input) is not established here.", "research/consumer-comparison.md; research/TWIN-REDUCTION.md section 7", src=[{"doc": "research__TWIN-REDUCTION.md", "tokens": ["consumer-comparison"]}], role="obligation"), N("PARITY-WALL", "analysis", "The wall must name its inputs", "Classical parity obstructions concern the distribution estimates and error tolerances " "available to particular sieve methods; they do not say that exact residue arrangements lose " "all primality information. A new obstruction claim must name the method class, retained " "statistics, tolerated errors and quantifiers, and the parity ledger line is documentation, " "not a proof that an argument succeeds or is impossible.", "docs/README.md, Status", src=[{"doc": "README.md", "tokens": ["The wall has to specify a method and its inputs"]}], role="analysis"), # ---------- measurements of this run -------------------------------------------------------- N("RUN-MEASUREMENTS", "numeric", "This run's own measurements", "On the corpus's own producer: the nu-mass profile 1 - F(n) = pi^-2 sqrt(n/L^2) with the mass " "inside the critical scale (residual 2.6e-4 at x = 19, 6.5e-5 at x = 23); the completion " "price log F / log y = 0.3253 / 0.3065 / 0.2865 at x = 13 / 17 / 19, decreasing; the " "frequency length T99/n^(13/28) = 0.2539 then 0.07359, so no published improvement window " "contains the cell and the exclusion tightens with x.", "returns 777, 778, 780 (jobs 1565, 1566, 1567)", src=[{"return": 780, "tokens": ["7/380"]}, {"doc": "research__structured-dispersion-estimate.md", "tokens": ["7/200"]}], note="All measured on the corpus's own producer with a positive control (the same " "enumeration reproduces the producer's own R ln y values to four digits).", role="measurement"), # ---------- the priced-and-failed interfaces (all attacks on X-SMALL) -------------------------- N("SMALL-DIVISOR-KERNEL", "refuted", "Bettin-Chandee on the separated trilinear form", "129/125 against a required 1, with the whole deficit at common divisor 1.", "research/small-divisor-kernel.md; research/TWIN-REDUCTION.md section 6", src=[{"doc": "research__TWIN-REDUCTION.md", "tokens": ["129/125"]}], role="closed-attack"), N("DFI", "refuted", "Duke-Friedlander-Iwaniec (1.1)", "1267/1200 at the same box.", "research/small-divisor-kernel.md; research/TWIN-REDUCTION.md section 6", src=[{"doc": "research__TWIN-REDUCTION.md", "tokens": ["1267/1200"]}], role="closed-attack"), N("SPECTRAL-DIAG", "refuted", "Spectral large sieve diagnostic", "Trivial for all common divisors up to x^(19/50) at the same box.", "research/small-divisor-kernel.md; research/structural-literature-audit.md", src=[{"doc": "research__small-divisor-kernel.md", "tokens": ["19/50"]}], role="closed-attack"), N("TYPE-I-II", "refuted", "Type I/II decomposition of the left Mobius coefficient", "Best block 41/40; the balanced piece returns to 103/100; the corner is untouched and needs " "a per-block saving eta' > 1 against the square-root ceiling 1/2.", "research/left-divisor-signs.md; research/TWIN-REDUCTION.md section 6", src=[{"doc": "research__TWIN-REDUCTION.md", "tokens": ["41/40", "103/100"]}], role="closed-attack"), N("FKM", "refuted", "Fouvry-Kowalski-Michel algebraic twists", "Prime modulus required; at most 1/48 against a required 3/25.", "research/TWIN-REDUCTION.md section 6", src=[{"doc": "research__TWIN-REDUCTION.md", "tokens": ["1/48", "3/25"]}], role="closed-attack"), N("WRIGHT", "refuted", "Wright, subdyadic Bettin-Chandee", "The hypothesis is on the inverted variables, not the harmonic band; 1157/1000 when forced.", "research/TWIN-REDUCTION.md section 6", src=[{"doc": "research__TWIN-REDUCTION.md", "tokens": ["1157/1000"]}], role="closed-attack"), N("GURIA", "refuted", "Guria, Kloosterman fractions averaged over primes", "Needs two variables of weight one and a main term; the corner has neither.", "research/corner-correlation.md; research/TWIN-REDUCTION.md section 6", src=[{"doc": "research__TWIN-REDUCTION.md", "tokens": ["Guria"]}], role="closed-attack"), N("DET-COROLLARY", "refuted", "Bettin-Chandee Corollary 1 on the determinant equation", "Legal after moving the prime-power part of beta onto the coefficient side; adds exactly zero " "area.", "research/determinant-corollary.md; research/TWIN-REDUCTION.md section 6", src=[{"doc": "research__TWIN-REDUCTION.md", "tokens": ["adds exactly zero area"]}], role="closed-attack"), N("CHOWLA-FAMILY", "refuted", "Averaged and logarithmic Chowla inputs", "Averaged Chowla (Matomaki-Radziwill-Tao), logarithmic two-point Chowla (Tao), Tao-Teravainen, " "Helfgott-Radziwill and Pilatte: wrong average type, fixed forms, or saving far below " "log^(2+eps) x.", "research/corner-correlation.md; research/consumer-comparison.md", src=[{"doc": "research__TWIN-REDUCTION.md", "tokens": ["log^(2+eps) x"]}], role="closed-attack"), # ---------- the two other measurements of the arithmetic branch -------------------------------- N("KERNEL-SIGN", "numeric", "Mobius signs vs random signs", "The actual Mobius signs give no advantage over random signs in the kernel moment at " "x <= 2^30, in a regime where the object is invisible.", "research/kernel-sign-control.md; research/TWIN-REDUCTION.md section 6", src=[{"doc": "research__TWIN-REDUCTION.md", "tokens": ["2^30"]}], role="measurement"), N("CORNER-MEAS", "numeric", "Corner correlation at random-sign size", "The corner correlation sits at random-sign size at x <= 2^36, and the actual right prime " "band holds at most one prime below x = 2^70.", "research/corner-measurement.md; research/TWIN-REDUCTION.md section 6", src=[{"doc": "research__TWIN-REDUCTION.md", "tokens": ["2^36", "2^70"]}], role="measurement"), N("LADDER", "numeric", "The trusted G2 ladder", "The trusted ladder, its controls and its calibration; its fitted power is a local slope, " "not an asymptotic exponent and not evidence that the sufficient twin margin holds.", "research/G2-STATE.md sections 2-3; docs/README.md Status", src=[{"doc": "README.md", "tokens": ["local slope"]}], role="measurement"), ] # --------------------------------------------------------------------------------------------------- BY_ID = {n["id"]: n for n in NODES} DOC_EDGES = ("supports", "attempted") def graph(minus=frozenset()): """The route structure, optionally with some nodes DELETED: a deleted node is gone from the graph and every route that named it loses that member (so a conjunction it belonged to can no longer be satisfied by the other members alone).""" g = {} for n in NODES: if n["id"] in minus: continue g[n["id"]] = [r for r in n["routes"] if not (minus & set(r))] return g def status_now(): return {n["id"]: n["tag"] for n in NODES} def derivable(status, g, target, memo=None): """TODAY's question: the node's tag is established, or some route of it is fully derivable.""" if memo is None: memo = {} if target in memo: return memo[target] if target not in g: memo[target] = False return False memo[target] = False # cycle guard: a cycle is a defect, not a grant out = status[target] in ESTABLISHED or any( all(derivable(status, g, c, memo) for c in route) for route in g[target]) memo[target] = out return out def assumed_open_leaves(): """Open nodes with no route of their own: the atomic obligations a closure hypothesis closes.""" return {n["id"] for n in NODES if n["tag"] == "open" and not n["routes"]} def derivable_struct(g, target, removed=frozenset(), assumed=None, memo=None): """THE STRUCTURAL QUESTION, with every atomic obligation presumed closed. Used only by `fatal` and `impact`, and it is the question those two queries are meant to answer: with all the named obligations hypothetically proved, which nodes are irreplaceable and what does the loss of one cost. `removed` is a node whose content is unavailable -- deleting it is not refuting it, but the effect on a conjunction is the same and cleaner to state. """ if assumed is None: assumed = assumed_open_leaves() if memo is None: memo = {} key = (target, target in removed) if key in memo: return memo[key] n = BY_ID.get(target) if n is None or target in removed or target not in g: memo[key] = False return False if target in assumed: memo[key] = True return True if n["tag"] in ESTABLISHED: memo[key] = True return True memo[key] = False out = any(all(derivable_struct(g, c, removed, assumed, memo) for c in route) for route in g[target]) memo[key] = out return out def route_reach(node_id, seen=None): """Nodes reachable through routes edges: the derivational subgraph of a node.""" if seen is None: seen = set() for route in BY_ID[node_id]["routes"]: for c in route: if c not in seen: seen.add(c) route_reach(c, seen) return seen def doc_reach(node_id, seen=None): """Nodes reachable through routes AND documentation edges: the whole documented neighbourhood, used only for the orphan check.""" if seen is None: seen = set() kids = [c for route in BY_ID[node_id]["routes"] for c in route] for key in DOC_EDGES: kids += list(BY_ID[node_id][key]) for c in kids: if c not in seen: seen.add(c) doc_reach(c, seen) return seen def frontier(): """What the root reaches today: the obligations on its paths, and the attacks around them. Two layers, kept separate because conflating them is what makes a programme look like one obstruction seen many times: the ROUTE layer (nodes whose closure would actually deliver the root) and the ATTACK layer (nodes listed as `attempted` at some route-reachable obligation, which gates nothing either way). """ on_path = route_reach(ROOT) out = {"obligation": [], "blocked": [], "traces_of_closed_attacks_on_a_path": [], "closed_attacks_around_the_paths": [], "attacks_in_flight": []} for nid in sorted(on_path): n = BY_ID[nid] if n["tag"] == "refuted": out["traces_of_closed_attacks_on_a_path"].append(nid) elif n["tag"] == "open": (out["blocked"] if n["role"] in ("blocked-obligation", "trap") else out["obligation"]).append(nid) attempted = set() for nid in on_path: attempted |= set(BY_ID[nid]["attempted"]) for nid in sorted(attempted): n = BY_ID[nid] if n["tag"] == "refuted": out["closed_attacks_around_the_paths"].append(nid) elif n["tag"] == "open": out["attacks_in_flight"].append(nid) return out def cheapest(target=ROOT, g=None, status=None, _memo=None): """Smallest set of OPEN nodes whose closure makes `target` derivable, by route. Cost of a route = union of its members' closures, plus the node itself when it is open. The metric is a COUNT OF NAMED OBLIGATIONS, not a difficulty: two obligations can be one easy theorem and one wall. The trap node has no closure set: closing the conclusion is not a plan. """ g = graph() if g is None else g status = status_now() if status is None else status memo = {} if _memo is None else _memo def cost(nid, stack=()): if nid in memo: return memo[nid] if nid in stack or nid not in g: return None if BY_ID[nid]["role"] == "trap": memo[nid] = None return None if status[nid] in ESTABLISHED: memo[nid] = frozenset() return memo[nid] best = None for route in g[nid]: parts, ok = set(), True for c in route: cc = cost(c, stack + (nid,)) if cc is None: ok = False break parts |= cc if not ok: continue if status[nid] == "open" and nid != target: parts = parts | {nid} cand = frozenset(parts) if best is None or len(cand) < len(best) or (len(cand) == len(best) and sorted(cand) < sorted(best)): best = cand if best is None and status[nid] == "open": # an atomic obligation: it has no route to anything simpler, so closing it IS the cost best = frozenset({nid}) memo[nid] = best return best return cost(target) def fatal(target=ROOT): """Nodes irreplaceable for `target`: with all atomic obligations presumed closed, removing this one node leaves `target` underivable by any re-routing. An `attempted` interface can never appear here, which is the whole point of separating attacks from obligations. """ g = graph() out = [] for n in NODES: if n["id"] == target: continue if not derivable_struct(g, target, removed=frozenset({n["id"]})): out.append(n["id"]) return sorted(out) def impact(node_id): """Nodes that stop being derivable when node_id's content is unavailable (all other obligations presumed closed). The node itself is excluded: removing a node removes it, it does not refute it, so counting the node against itself would report a nonempty impact for every node. For a closed attack this is EMPTY -- a failed attempt gates nothing. """ g = graph() rem = frozenset({node_id}) before = {n["id"] for n in NODES if derivable_struct(g, n["id"])} after = {n["id"] for n in NODES if derivable_struct(g, n["id"], removed=rem)} return sorted((before - after) - {node_id}) def branches(): """One row per sufficient route to the root: its member, closure, and irreplaceable set. The rows are the root's four consumer formulations. Each member is itself an obligation, so the row reports the member's OWN cheapest closure (including the member) and its OWN irreplaceable set: the conjunction inside a member is where the real content lives, and flattening it to the root's route would hide it. """ rows = [] for route in BY_ID[ROOT]["routes"]: for member in route: closure = set(cheapest(member) or []) if BY_ID[member]["tag"] == "open": closure.add(member) rows.append({"member": member, "member_is_the_whole_route": len(route) == 1, "why_it_reaches_the_root": BY_ID[member]["note"], "closure": sorted(closure), "fatal": fatal(member)}) return rows def source_text(entry): if "doc" in entry: p = os.path.join(DOCS, entry["doc"]) else: p = os.path.join(RETS, "return-%d.json" % entry["return"]) if not os.path.exists(p): return None with open(p, encoding="utf-8", errors="replace") as fh: return fh.read() def verify(verbose=True): """Every node's tokens, checked literally against the document or return it cites.""" bad, checked_tokens, checked_nodes = [], 0, 0 for n in NODES: if not n["src"]: bad.append((n["id"], "no source declared")) continue checked_nodes += 1 for entry in n["src"]: text = source_text(entry) label = entry.get("doc") or ("return %s" % entry["return"]) if text is None: bad.append((n["id"], "missing source file: %s" % label)) continue for tok in entry.get("tokens", []): checked_tokens += 1 if tok not in text: bad.append((n["id"], "token %r not found in %s" % (tok, label))) if verbose: print(json.dumps({"ok": not bad, "nodes": len(NODES), "nodes_with_sources": checked_nodes, "tokens_checked": checked_tokens, "failures": bad}, indent=1)) return {"ok": not bad, "nodes_with_sources": checked_nodes, "tokens_checked": checked_tokens, "failures": bad} def validate(verbose=True): """Graph invariants: unique ids, resolvable refs, acyclic routes, tags in the vocabulary.""" problems = [] ids = [n["id"] for n in NODES] for nid in ids: if ids.count(nid) > 1: problems.append("duplicate id %s" % nid) for n in NODES: if n["tag"] not in TAGS: problems.append("%s: tag %r outside the vocabulary" % (n["id"], n["tag"])) for key in ("supports", "attempted"): for c in n[key]: if c not in BY_ID: problems.append("%s.%s -> unknown node %s" % (n["id"], key, c)) for route in n["routes"]: if not route: problems.append("%s: empty route" % n["id"]) for c in route: if c not in BY_ID: problems.append("%s.routes -> unknown node %s" % (n["id"], c)) # acyclicity through routes colour = {} def visit(u, stack): colour[u] = 1 for route in BY_ID[u]["routes"]: for v in route: if colour.get(v) == 1: problems.append("cycle: %s -> %s (via %s)" % (u, v, " -> ".join(stack + [u]))) elif colour.get(v) is None: visit(v, stack + [u]) colour[u] = 2 visit(ROOT, []) # every node must be reachable from the root through routes or documentation edges orphans = sorted(set(ids) - doc_reach(ROOT) - {ROOT}) # the target must not be derivable today if derivable(status_now(), graph(), ROOT): problems.append("the root is derived from the corpus's current tags: that is a modelling " "error, the programme is open") if verbose: print(json.dumps({"ok": not problems, "nodes": len(NODES), "root_derivable_now": derivable(status_now(), graph(), ROOT), "orphans_not_reached_from_root": orphans, "problems": problems}, indent=1)) return not problems def selftest(): """Invariants, the source gate, determinism, and the two structural assertions that matter.""" ok = validate(verbose=False) ver = verify(verbose=False) ok &= ver["ok"] problems = [] r1, r2 = cheapest(), cheapest() if r1 is None or r1 != r2: problems.append("cheapest() is not deterministic or is empty") fl = frontier() if fl["obligation"] != sorted(fl["obligation"]): problems.append("frontier() is not deterministic") closed = [n["id"] for n in NODES if n["tag"] == "refuted"] for nid in closed: if impact(nid): problems.append("%s has nonempty impact: a closed attack must gate nothing" % nid) if nid in fatal(ROOT): problems.append("%s is fatal to the root: a closed attack cannot be" % nid) if "CORNER" in fl["obligation"]: problems.append("CORNER is offered as a plain obligation; it is the conclusion") if "CORNER" in cheapest(): problems.append("CORNER is inside a closure set; the trap must never be a plan") # the render grouping must cover the graph exactly once: the first version of it was a # hand-written list and silently omitted two nodes added later covered = [i for _title, ids in groups() for i in ids] if sorted(covered) != sorted(BY_ID): problems.append("the render grouping does not cover the graph exactly once: %s" % sorted(set(BY_ID) - set(covered))) if len(covered) != len(set(covered)): problems.append("the render grouping repeats a node") # structural assertions: the conjunction members of the arithmetic branch are irreplaceable, # the reduction is load-bearing for it, and no single node is globally fatal. arith = None for row in branches(): if row["member"] == "MARGIN-SHRINK": arith = row if arith is None: problems.append("no arithmetic branch found: the graph lost a consumer") else: for nid in ("REDUCTION", "COMPLEMENT"): if nid not in arith["fatal"]: problems.append("%s is not fatal inside the arithmetic branch" % nid) if "X-SMALL" not in arith["closure"]: problems.append("X-SMALL is not in the cheapest closure of the arithmetic branch") zone = [row for row in branches() if row["member"] == "ZONE-WEAK"] if not zone or zone[0]["fatal"] != ["GAP-INF"] or zone[0]["closure"] != ["GAP-INF", "ZONE-WEAK"]: problems.append("the zone branch's closure or fatal set is not what the model says") out = {"ok": ok and not problems, "graph_valid_and_sourced": ok, "nodes": len(NODES), "tokens_checked": ver["tokens_checked"], "nodes_with_sources": ver["nodes_with_sources"], "cheapest_closure": sorted(r1), "cheapest_size": len(r1), "globally_fatal": fatal(ROOT), "branches": branches(), "problems": problems} print(json.dumps(out, indent=1)) return 0 if out["ok"] else 1 ROLE_LABEL = { "classical": "Supporting: classical inputs", "reduction": "Supporting: reductions and equivalences", "equivalence": "Supporting: reductions and equivalences", "consumer": "Supporting: reductions and equivalences", "accounting": "Supporting: reductions and equivalences", "ceiling": "Supporting: ceilings and scoped limits", "closed-attack": "The closed attacks", "attempt": "The closed attacks", "analysis": "Supporting: analyses, explicitly not theorems", "measurement": "Measurements", "imported": "Imported conditionals", "trap": "The trap", } def groups(): """Every node, in exactly one group, derived from the graph rather than listed by hand. The first version of this function was a hand-written list of ids, and it silently omitted the two nodes added after it was written -- the same class of defect as a hand-typed table, in the very tool built to avoid it. The groups are now computed: each consumer's derivational subgraph first, then whatever is left by its role, and `selftest` asserts that the groups cover every node exactly once. """ order, seen = [], set() order.append(("Target", [ROOT])) seen.add(ROOT) for route in BY_ID[ROOT]["routes"]: for member in route: ids = [i for i in [member] + _ordered(route_reach(member)) if i not in seen] if ids: order.append(("Branch: `%s`" % member, ids)) seen |= set(ids) for role in ("reduction", "equivalence", "consumer", "accounting", "ceiling", "classical", "closed-attack", "attempt", "analysis", "measurement", "imported", "trap"): ids = [n["id"] for n in NODES if n["id"] not in seen and n["role"] == role] if ids: order.append((ROLE_LABEL[role], ids)) seen |= set(ids) left = [n["id"] for n in NODES if n["id"] not in seen] if left: order.append(("Unclassified (a defect: every node needs a role)", left)) return order def _ordered(ids): return [n["id"] for n in NODES if n["id"] in ids] def render(): """Markdown tables, generated from the data so the report cannot drift from the model.""" lines = [] lines.append("### The graph, by branch\n") for title, ids in groups(): lines.append("**%s**\n" % title) lines.append("| node | tag | claim (short) | owner |") lines.append("|---|---|---|---|") for nid in ids: n = BY_ID[nid] lines.append("| `%s` | %s | %s | %s |" % (nid, n["tag"], n["title"], n["owner"])) lines.append("") c = sorted(cheapest()) fl = frontier() lines.append("### Sufficient closures, one row per consumer formulation\n") lines.append("| consumer | cheapest closure (named open obligations) | size | irreplaceable inside it |") lines.append("|---|---|---|---|") for row in branches(): lines.append("| `%s` | %s | %d | %s |" % ( row["member"], ", ".join("`%s`" % x for x in row["closure"]) or "(established)", len(row["closure"]), ", ".join("`%s`" % x for x in row["fatal"]) or "(none above it)")) lines.append("") lines.append("Smallest closure over all branches: **%d** node(s), %s\n" % (len(c), ", ".join("`%s`" % x for x in c))) lines.append("Globally fatal single failures: **%s** -- no node lies on every consumer route, " "so losing any one branch leaves the others intact.\n" % (", ".join("`%s`" % x for x in fatal(ROOT)) or "none")) lines.append("### Frontier: what the root reaches today\n") lines.append("On the root's paths, open obligations: %s\n" % ", ".join("`%s`" % x for x in fl["obligation"])) lines.append("On the root's paths, blocked on a named literature input: %s\n" % (", ".join("`%s`" % x for x in fl["blocked"]) or "none")) lines.append("Closed attacks attached to those paths (traces, not gates): %s\n" % (", ".join("`%s`" % x for x in fl["closed_attacks_around_the_paths"]) or "none")) lines.append("Attacks still in flight, open: %s\n" % (", ".join("`%s`" % x for x in fl["attacks_in_flight"]) or "none")) lines.append("") lines.append("### Every closed attack, and what it changes if its content is removed\n") lines.append("_(Every node appears in exactly one group above; the self-test asserts that the " "grouping covers the graph, so a node added later cannot be silently omitted.)_\n") lines.append("| node | impact |") lines.append("|---|---|") for n in NODES: if n["tag"] == "refuted": imp = impact(n["id"]) lines.append("| `%s` | %s |" % (n["id"], ", ".join(imp) if imp else "nothing")) lines.append("") lines.append("### The one load-bearing claim that is not an obligation\n") lines.append("`REDUCTION` is tagged `derived` (checked, adjudicated three times) and is " "nevertheless irreplaceable inside the arithmetic branch: every margin statement " "in that branch is a statement about `E_dagger`, which exists only because the " "reduction holds. Impact of removing it: %s.\n" % (", ".join("`%s`" % x for x in impact("REDUCTION")) or "nothing")) lines.append("") return "\n".join(lines) def emit_json(): doc = {"root": ROOT, "nodes": NODES, "status_now": status_now(), "root_derivable_now": derivable(status_now(), graph(), ROOT), "frontier": frontier(), "cheapest_closure": sorted(cheapest()), "branches": branches(), "globally_fatal": fatal(ROOT)} out = os.path.join(RUN, "artifacts", "tpc-deps.json") with open(out, "w", encoding="utf-8", newline="\n") as fh: json.dump(doc, fh, indent=1, ensure_ascii=False, sort_keys=True) fh.write("\n") print(json.dumps({"ok": True, "path": os.path.relpath(out, RUN), "nodes": len(NODES), "bytes": os.path.getsize(out)}, indent=1)) def main(argv): cmd = argv[0] if argv else "selftest" if cmd == "selftest": return selftest() if cmd == "validate": return 0 if validate() else 1 if cmd == "verify": return 0 if verify()["ok"] else 1 if cmd == "frontier": print(json.dumps(frontier(), indent=1)) return 0 if cmd == "branches": print(json.dumps(branches(), indent=1)) return 0 if cmd == "cheapest": c = sorted(cheapest()) print(json.dumps({"size": len(c), "nodes": c, "detail": [{"id": x, "title": BY_ID[x]["title"], "owner": BY_ID[x]["owner"]} for x in c]}, indent=1)) return 0 if cmd == "loadbearing" or cmd == "fatal": print(json.dumps({"globally_fatal": fatal(ROOT), "branches": branches()}, indent=1)) return 0 if cmd == "impact": if len(argv) < 2 or argv[1] not in BY_ID: raise SystemExit("usage: impact ") imp = impact(argv[1]) print(json.dumps({"deleting": argv[1], "stops_being_derivable": imp, "verdict": ("LOAD-BEARING" if imp else "CHANGES NOTHING")}, indent=1)) return 0 if cmd == "show": if len(argv) < 2 or argv[1] not in BY_ID: raise SystemExit("usage: show ") print(json.dumps(BY_ID[argv[1]], indent=1, ensure_ascii=False)) return 0 if cmd == "render": text = render() out = os.path.join(RUN, "artifacts", "tpc-deps.render.md") with open(out, "w", encoding="utf-8", newline="\n") as fh: fh.write(text + "\n") print(json.dumps({"ok": True, "path": os.path.relpath(out, RUN), "bytes": len(text)}, indent=1)) return 0 if cmd == "json": emit_json() return 0 raise SystemExit("unknown command %r" % cmd) if __name__ == "__main__": sys.exit(main(sys.argv[1:]))