{"id":49068284,"url":"https://github.com/zfifteen/prime-gap-structure","last_synced_at":"2026-04-20T06:10:34.856Z","repository":{"id":348315550,"uuid":"1197448197","full_name":"zfifteen/prime-gap-structure","owner":"zfifteen","description":"Investigates deterministic prime-gap interiors using the Divisor Normalization Identity (DNI). Establishes the Gap Winner Rule (GWR) the raw-Z maximizer is always the leftmost min-d(n) carrier. Validates the No-Later-Simpler-Composite Theorem with zero violations through 10^18. Documents hierarchical first-arrival laws and square-phase terminal.","archived":false,"fork":false,"pushed_at":"2026-04-12T12:04:24.000Z","size":12902,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-12T12:22:26.702Z","etag":null,"topics":["analytic-number-theory","computational-number-theory","divisor-function","divisor-normalization-identity","dn-minimization","gap-winner-rule","gwr","hierarchical-first-arrival","no-later-simpler-composite-theorem","number-theory","prime-gap-structure","prime-gaps","prime-placement","prime-squares","raw-z-maximizer","square-phase-closure"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zfifteen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-03-31T15:33:32.000Z","updated_at":"2026-04-12T09:01:24.000Z","dependencies_parsed_at":null,"dependency_job_id":"a58ef44e-2283-42c1-b50e-809fb1dc499e","html_url":"https://github.com/zfifteen/prime-gap-structure","commit_stats":null,"previous_names":["zfifteen/geodesic-prime-prefilter","zfifteen/z-band-prime-prefilter","zfifteen/prime-gap-structure"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/zfifteen/prime-gap-structure","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zfifteen%2Fprime-gap-structure","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zfifteen%2Fprime-gap-structure/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zfifteen%2Fprime-gap-structure/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zfifteen%2Fprime-gap-structure/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zfifteen","download_url":"https://codeload.github.com/zfifteen/prime-gap-structure/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zfifteen%2Fprime-gap-structure/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32035291,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-20T00:18:06.643Z","status":"online","status_checked_at":"2026-04-20T02:00:06.527Z","response_time":94,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["analytic-number-theory","computational-number-theory","divisor-function","divisor-normalization-identity","dn-minimization","gap-winner-rule","gwr","hierarchical-first-arrival","no-later-simpler-composite-theorem","number-theory","prime-gap-structure","prime-gaps","prime-placement","prime-squares","raw-z-maximizer","square-phase-closure"],"created_at":"2026-04-20T06:10:34.118Z","updated_at":"2026-04-20T06:10:34.847Z","avatar_url":"https://github.com/zfifteen.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Prime Gap Structure\n\n![Prime Gap Structure hero](docs/assets/prime-gap-structure-hero.jpg)\n\nThis repository is about one simple deterministic rule inside prime gaps.\n\nTake the consecutive primes `23` and `29`. The integers between them are\n`24, 25, 26, 27, 28`. Their divisor counts are:\n\n- `d(24) = 8`\n- `d(25) = 3`\n- `d(26) = 4`\n- `d(27) = 4`\n- `d(28) = 6`\n\nSo `25` wins this gap because it has the smallest divisor count present.\n\nNow take `89` and `97`. The interior integers are\n`90, 91, 92, 93, 94, 95, 96`. Their divisor counts are:\n\n- `d(90) = 12`\n- `d(91) = 4`\n- `d(92) = 6`\n- `d(93) = 4`\n- `d(94) = 4`\n- `d(95) = 4`\n- `d(96) = 12`\n\nHere the smallest divisor count present is `4`, and the leftmost carrier of\nthat minimum is `91`, so `91` wins.\n\nThe central claim of this repository is that this is not a toy pattern or a\nnear miss. It is exact.\n\n## Gap Winner Rule\n\nThe **Gap Winner Rule (GWR)** says:\n\n1. inside a prime gap, find the smallest divisor count present among the\n   interior composites;\n2. if more than one interior composite has that divisor count, take the\n   leftmost one.\n\nThat chosen interior integer is the winner of the gap.\n\nThe headline mathematical result carried by the repository is that the\nimplemented divisor-normalization score picks exactly that same integer in\nevery prime gap. The theorem statement is\n[Gap Winner Rule — Hierarchical Local-Dominator Law](gwr/findings/gwr_hierarchical_local_dominator_theorem.md),\nand the proof surface is summarized in [GWR_PROOF.md](GWR_PROOF.md).\n\n## Why The Score Exists\n\nThe score exists because the repo wants one number per interior composite, so a\nwhole gap can be compared as a single ordered field rather than as a list of\ncases.\n\nDivisor count already tells part of the story: fewer divisors means less\nfactor structure. But divisor count alone does not give one scalar quantity for\nthe whole gap, and it does not explain what the winner is winning relative to.\n\nThe divisor-normalization program builds that scalar by using primes as the\nreference class. Its purpose is to answer one concrete question:\n\n\u003e Which composite in the gap comes closest to the prime baseline?\n\nThe normalization is built so that every prime lands at the same fixed point,\n`Z = 1.0`, while composites fall below that point. That makes the winner easy\nto interpret: it is the interior composite closest to the prime fixed point\nunder the normalization.\n\nThe raw quantity is\n\n$$\nZ_{\\mathrm{raw}}(n) = n^{1 - d(n)/2}\n$$\n\nand the implementation compares interiors using its logarithm\n\n$$\nL(n) = \\ln Z_{\\mathrm{raw}}(n) = \\left(1 - \\frac{d(n)}{2}\\right)\\ln(n).\n$$\n\nMaximizing `Z_raw(n)` and maximizing `L(n)` pick the same winner. The score is\nthere to turn the gap interior into one exact competition, not to decorate the\nrule with jargon.\n\n## What This Repository Carries\n\nThe main result in this repository is the proved GWR theorem.\n\nDownstream from that, the repo also carries:\n\n- an exact DNI/GWR recursive next-prime walk,\n- a deterministic prime-generation filter derived from the same\n  divisor-normalization program.\n\nThe deterministic filter is a secondary engineering artifact built from the\nsame normalization. The central result is the winner law.\n\n## Novel Structures in This Repository\n\nFive structures introduced here do not appear under these names in the\nliterature:\n\n- **Gap Winner Rule (GWR):** inside any prime gap, the log-score argmax is\n  exactly the leftmost carrier of the minimum interior divisor class. On the\n  repository's current proof surface, this is a proved universal prime-gap\n  winner theorem summarized in [GWR_PROOF.md](GWR_PROOF.md) and recorded in\n  [gwr/findings/gwr_hierarchical_local_dominator_theorem.md](gwr/findings/gwr_hierarchical_local_dominator_theorem.md).\n- **Divisor Normalization Identity (DNI):** `Z(n) = n^(1 - d(n)/2)` is an\n  exact arithmetic identity collapsing all primes to `Z = 1.0`.\n- **No-Later-Simpler-Composite (NLSC) condition:** once the GWR winner\n  appears, no later interior composite with strictly smaller divisor count\n  precedes the next prime. Zero violations observed through `10^18`.\n- **Dominant d=4 arrival reduction:** under square exclusion, the GWR winner\n  is exactly the first interior `d=4` carrier. Exact on full scans through\n  `2x10^7`.\n- **Dynamic cutoff conjecture:** `C(q) = max(64, ceil(0.5 * log(q)^2))` bounds\n  the GWR winner offset for the bounded walker. Empirically calibrated through\n  `p \u003c= 10^6`. The fixed map `{2:44, 4:60, 6:60}` is falsified at\n  `q = 24,098,209`.\n\n## Divisor Normalization Identity\n\nThe raw-$Z$ quantity exists because the repo wants a normalization in which the\nentire prime class lands at one fixed point while composites fall below it.\n\nThe construction starts from the divisor normalization load\n\n$$\n\\kappa(n) = \\frac{d(n) \\cdot \\ln(n)}{e^{2}}\n$$\n\nand then passes that load through the Z-transform:\n\n$$\nZ(n) = \\frac{n}{\\exp(v \\cdot \\kappa(n))}\n$$\n\nwhere $v$ is the normalization scaling parameter.\n\nFor the prime-gap structure program in this repository, the distinguished value is\n\n$$\nv = \\frac{e^{2}}{2}\n$$\n\nbecause it produces an exact cancellation. Substitute the Divisor Normalization Equation into the Z-transform:\n\n$$\nZ(n) = \\frac{n}{\\exp\\left(v \\cdot \\frac{d(n) \\cdot \\ln(n)}{e^{2}}\\right)}\n$$\n\nNow set $v = e^{2}/2$:\n\n$$Z(n) = \\frac{n}{\\exp\\left(\\frac{e^{2}}{2} \\cdot \\frac{d(n) \\cdot \\ln(n)}{e^{2}}\\right)}$$\n\n$$Z(n) = \\frac{n}{\\exp\\left(\\frac{d(n)}{2} \\cdot \\ln(n)\\right)}$$\n\n$$Z(n) = \\frac{n}{n^{d(n)/2}}$$\n\n$$Z(n) = n^{1 - d(n)/2}$$\n\nSo the **Divisor Normalization Identity** (DNI) $Z(n) = n^{1 - d(n)/2}$ is\n\n$$\nZ(n) = n^{1 - d(n)/2}\n$$\n\nThis has an immediate effect:\n\n- Prime: $d(p) = 2$, so $Z(p) = 1$\n- Semiprime with two distinct prime factors: $d(n) = 4$, so $Z(n) = 1/n$\n- Composite in general: $d(n) \u003e 2$, so $Z(n) \u003c 1$\n\nUnder the exact DNI, the entire prime class collapses to the fixed-point locus $Z = 1.0$. Composites are pushed strictly below that locus.\n\nThis fixed-point collapse is the mathematical base of the repository. It is\nthe invariant behind both the prime-gap theorem and the downstream\ndeterministic filter.\n\n## GWR Proof Surface\n\nThe central winner law in this repository is that the log-score argmax inside\na prime gap collapses to a simpler arithmetic choice:\n\n1. minimize the interior divisor count $d(n)$,\n2. among ties, take the leftmost interior carrier.\n\nThat is the Gap Winner Rule.\n\nThe formal theorem file expresses this as a hierarchical local-dominator law.\nThe proof is closed on the repository's current proof surface: ordered\ndominance closes the later side, the local admissibility theorem closes the\nearlier side, the residual-class closure artifacts discharge the former\nlow-class remainder, and the exact no-early-spoiler audits through\n$p \u003c 5 \\times 10^9$ plus the square-adjacent stress surface at $10^{12}$\nremain clean.\n\nSee [gwr/story/README.md](gwr/story/README.md),\n[GWR_PROOF.md](GWR_PROOF.md),\n[gwr/findings/gwr_hierarchical_local_dominator_theorem.md](gwr/findings/gwr_hierarchical_local_dominator_theorem.md),\n[gwr/findings/gap_winner_rule.md](gwr/findings/gap_winner_rule.md), and\n[gwr/findings/prime_gap_admissibility_theorem.md](gwr/findings/prime_gap_admissibility_theorem.md).\n\n## Exact Recursive Prime Walk\n\nThe most jarring combined predictor result in the repository is this: once the\nimplemented winner appears inside a prime gap, the next prime arrives before\nany later interior composite with strictly smaller divisor count can appear.\nThat closure law is what lets the unbounded DNI/GWR walker recover the next\nprime exactly from the ordered divisor structure of the next-gap interior.\n\nGiven a known prime `q`, the oracle scans divisor counts to the right until the\nfirst prime boundary, takes the lexicographic minimum over the composite\ninterior, and recovers the next prime by the witness map. That mechanism is\nexact by construction. No cutoff theorem is involved.\n\nOn the current verified surface, that mechanism supports an exact deterministic\nno-skip sequential walk. The transition rule is exact on `743,075 / 743,075`\nrows from the combined $10^6 + 10^7$ next-gap surface, and the recursive walk\nrecords `664,578 / 664,578` exact consecutive next-prime recoveries from prime\n`11` through prime `10,000,121` with `0` skipped gaps. The sampled decade\nladder from $10^2$ through $10^18$ also stayed at exact hit rate `1.0` with\n`0` skipped gaps across `860` measured recursive steps.\n\nThe predictor note is documented in\n[docs/research/predictor/gwr_dni_exact_recursive_prime_walk_note.md](docs/research/predictor/gwr_dni_exact_recursive_prime_walk_note.md),\nand the live implementation is\n[benchmarks/python/predictor/gwr_dni_recursive_walk.py](benchmarks/python/predictor/gwr_dni_recursive_walk.py).\n\n![Exact DNI recursive-walk performance](docs/research/predictor/figures/gwr_dni_recursive_gap_scaling_performance.png)\n\n## Dynamic Cutoff and Square-Branch Falsification\n\nThe old fixed cutoff theorem `{2:44, 4:60, 6:60}` is false. It fails at\n`q = 24,098,209`, where the square branch gives `E(q) = 72 \u003e 60`. The bounded\nwalker in the repo no longer treats that fixed map as live.\n\nThe current bounded compression is empirical:\n`C(q) = max(64, ceil(0.5 * log(q)^2))`. Through the direct square-branch audit\nat `p \u003c= 10^6`, the repo tested `78,498` prime squares, found `7,477`\nviolations of the old fixed map, and observed maximum square offset `246`.\nThe compare mode in the recursive walker is the live falsification instrument:\nit runs the bounded and unbounded walkers in lockstep and records any bounded\nmiss immediately.\n\nSee\n[benchmarks/python/predictor/square_branch_gap_audit.py](benchmarks/python/predictor/square_branch_gap_audit.py),\n[benchmarks/python/predictor/gwr_dni_recursive_walk.py](benchmarks/python/predictor/gwr_dni_recursive_walk.py),\nand\n[docs/research/predictor/gwr_dni_exact_recursive_prime_walk_note.md](docs/research/predictor/gwr_dni_exact_recursive_prime_walk_note.md).\n\n## No-Later-Simpler-Composite\n\nThe strongest closure consequence currently documented in the repository is\nthis: once the implemented winner appears inside a prime gap, the next prime\narrives before any later interior composite with strictly smaller divisor\ncount can appear.\n\nThis is the closure law behind the exact recursive walk. After the winner\nappears, the gap interior does not later produce a simpler composite before\nthe next prime closes the interval.\n\nIn symbols, if $w$ is the implemented log-score winner in the gap $(p, q)$ and\n\n$$\nT_{\u003c}(w) = \\min \\{\\, n \u003e w : d(n) \u003c d(w) \\,\\},\n$$\n\nthen the closure condition is\n\n$$\nq \\le T_{\u003c}(w).\n$$\n\nThis is an exact corollary of the proved GWR theorem. The separate\nquestion is whether it can stand on its own as a direct prime-gap theorem without\nusing GWR as the parent result. The current documented surface includes a\ndeterministic even-band ladder at every decade from $10^8$ through $10^{18}$\nwith zero observed violations.\n\nSee\n[gwr/findings/closure_constraint_findings.md](gwr/findings/closure_constraint_findings.md),\n[gwr/findings/claim_hierarchy.md](gwr/findings/claim_hierarchy.md),\nand\n[docs/current_headline_results.md](docs/current_headline_results.md).\n\n## Dominant d=4 Reduction\n\nIn the dominant winner regime, the tested gaps admit no interior prime square,\nand the implemented winner is exactly the first interior carrier with\n$d(n)=4$.\n\nThat gives the leading regime a visible mechanism: square exclusion first,\nthen first-`d=4` arrival. The stricter semiprime-only slogan is false; a thin\nprime-cube exception family survives inside the broader `d=4` class.\n\nSee\n[gwr/findings/dominant_d4_arrival_reduction_findings.md](gwr/findings/dominant_d4_arrival_reduction_findings.md)\nand\n[gwr/findings/claim_hierarchy.md](gwr/findings/claim_hierarchy.md).\n\n## Deterministic Filter Performance\n\nThis fixed-point separation is one downstream engineering use of the method.\nCryptographic prime generation spends most of its time on candidates that are\ncomposite and never need a full probable-prime path. The exact DNI provides\nthe invariant target. The production implementation below is the bounded\ndeterministic surrogate calibrated against that target rather than a runtime\nexact-divisor evaluator.\n\nBecause confirmed primes live at $Z = 1.0$ under the DNI and composites\ncontract below it, the filter creates a clean structural separation in\nnormalized space. That separation makes it possible to reject many candidates\nbefore paying the full cost of the survivor regime.\n\nEmpirically, this extracted Python path produced:\n\n- $2.09\\times$ end-to-end speedup across $300$ deterministic $2048$-bit RSA keypairs\n- $2.82\\times$ end-to-end speedup across $50$ deterministic $4096$-bit RSA keypairs\n- $90.97\\,\\%$ to $91.07\\,\\%$ Miller-Rabin reduction in the current covered-table configuration\n\nThose numbers are not a side note. They are the production consequence of the\nsame invariant program, carried through a narrow deterministic runtime path\nthat rejects many doomed candidates before Miller-Rabin.\n\nSee [docs/prefilter/benchmarks.md](docs/prefilter/benchmarks.md) and\n[technical-note/technical_note.md](technical-note/technical_note.md).\n\n## Production Filter Path\n\nThe exact DNI depends on exact divisor count. That exact path is valuable as\nthe derivation and as the oracle, but it is not the runtime path for\ncryptographic-scale key generation.\n\nThe production implementation in this repository therefore uses a deterministic\nsurrogate with the same invariant target:\n\n- generate deterministic odd candidates from a SHA-256 namespace/index stream\n- reject immediately when a concrete factor appears in the gated prime tables\n- keep survivors on the locus convention `proxy_z = 1.0`\n- run fixed-base Miller-Rabin on survivors\n- apply final `sympy.isprime` confirmation in the current Python path\n\nIn the production path, `proxy_z = 1.0` means only that the candidate survived\nthe current gated factor tables and therefore advances to Miller-Rabin. It is\nnot a primality proof by itself.\n\nThe current measured rejection rate comes from the covered prime-table depth of\nthis implementation. The repository includes deterministic table-depth sweeps\nto show that dependence directly rather than attributing the `~91%` figure to\nruntime exact DNI evaluation.\n\n## Empirical Results\n\n### End-to-End RSA Key Generation\n\n- $2048$ bits, $300$ deterministic keypairs:  \n  baseline $291938.126792$ ms  \n  accelerated $139942.831833$ ms  \n  speedup $2.09\\times$  \n  Miller-Rabin reduction $90.97\\,\\%$\n- $4096$ bits, $50$ deterministic keypairs:  \n  baseline $757750.922792$ ms  \n  accelerated $268557.631625$ ms  \n  speedup $2.82\\times$  \n  Miller-Rabin reduction $91.07\\,\\%$\n\n### Candidate-Loop Screening\n\n- $2048$-bit control corpus:  \n  proxy rejection $91.02\\,\\%$  \n  pipeline speedup $2.95\\times$\n- $4096$-bit control corpus:  \n  proxy rejection $91.41\\,\\%$  \n  pipeline speedup $3.33\\times$\n\n### DNI Calibration\n\n- $29/29$ calibration primes stayed on $Z = 1.0$\n- $0$ composite false fixed points\n\n### Exact Raw Composite Z Field\n\n- This is a separate exact-field concern from the production filter.\n- Up to $10^6$ on the natural number line, the strongest exact raw composite\n  $Z$ value inside a prime gap lands at edge-distance $2$ in $43.6006\\%$ of\n  gaps versus an exact within-gap baseline of $22.1859\\%$, and is carried by a\n  $d(n)=4$ composite in $82.9027\\%$ of gaps versus a baseline of $20.1401\\%$.\n- Later repository notes sharpen that ridge picture into the current winner\n  theorem: GWR says the implemented log-score winner is the arithmetic choice\n  “minimize interior divisor count, then take the leftmost carrier,” and the\n  current proof route reduces the remaining earlier-side burden to a finite\n  local admissibility closure. The tested surfaces\n  remain the finite base, stress surface, and audit record for that proof chain.\n- The dedicated closure study then strengthens the right-edge reading further:\n  on the current documented even-band ladder through $10^{18}$, once the\n  winner appears, no later strictly simpler composite is observed before the\n  next prime closes the gap.\n\nSee [docs/gap_ridge/raw_composite_z_gap_edge.md](docs/gap_ridge/raw_composite_z_gap_edge.md),\n[gwr/findings/gap_winner_rule.md](gwr/findings/gap_winner_rule.md), and\n[gwr/findings/closure_constraint_findings.md](gwr/findings/closure_constraint_findings.md).\n\nSee [docs/prefilter/benchmarks.md](docs/prefilter/benchmarks.md) for the curated benchmark summary and [docs/prefilter/manual_validation.md](docs/prefilter/manual_validation.md) for the exact reproduction commands.\n\n## Python API\n\nInstall the Python package from the repo root:\n\n```bash\npython3 -m pip install -e ./src/python\n```\n\n## License\n\nThis repository is source-available under the\n[Business Source License 1.1](LICENSE).\n\nThe current grant keeps the code open for research, evaluation, and other\nnon-production work, and it also permits internal production use for smaller\norganizations under the Additional Use Grant in [LICENSE](LICENSE).\n\nCommercial production use outside that grant requires a separate commercial\nlicense. For licensing terms, support, or private commercial use, contact\n`dionisio.lopez@icloud.com`.\n\nEach version converts to [Apache License, Version 2.0](LICENSE) four years\nafter that version is first publicly distributed under the Business Source\nLicense 1.1.\n\nVersions that were first publicly distributed before this change under the MIT\nlicense remain available under those earlier terms.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzfifteen%2Fprime-gap-structure","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzfifteen%2Fprime-gap-structure","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzfifteen%2Fprime-gap-structure/lists"}