// zone-conv.c -- job #5 (break: crystallization, research/04-crystallization-and-hl.js // against research/ZONE-POSTULATE.md section 1). Method A: least-prime-factor sieve. // // For every prime p <= PMAX, with p' the next prime, counts the twin slots of T_p // (r, r+2 both coprime to p#) and the twin prime pairs in seven window conventions, // and reports the slots that are NOT twin prime pairs ("bad") and the twin prime // pairs that are NOT slots ("miss"). Also finds the first bad slot above p. // // S r > p, r+2 < p^2 the served script's window // S<= r > p, r+2 <= p^2 // Z r > p, r+2 < p'^2 ZONE-POSTULATE section 1: "wholly inside (p, p'^2)" // Z<= r > p, r+2 <= p'^2 ceiling closed // Zs r > p, r < p'^2 slot merely starts in the zone // Z[ r >= p, r+2 < p'^2 zone closed at p // Z0 r >= 1, r+2 < p'^2 whole head of the tile // // Hole test uses only lpf: x is coprime to p# iff x == 1 or lpf(x) > p (lpf(prime) = x). // Build: cc -O2 -o zone-conv zone-conv.c Run: ./zone-conv > zone-conv.log #include #include #include #include #define N 110000000u // sieve bound; p'^2 + 2 = 100140051 at p = 9973 #define PMAX 9973u static uint16_t *lpf; // 0 = prime (for x >= 2); else least prime factor static int is_prime(uint32_t x) { return x >= 2 && lpf[x] == 0; } static int hole(uint32_t x, uint32_t p) { if (x == 0) return 0; if (x == 1) return 1; uint32_t f = lpf[x] ? lpf[x] : x; return f > p; } enum { S, SLE, Z, ZLE, ZS, ZC, Z0, NW }; static const char *wname[NW] = { "S", "S<=", "Z", "Z<=", "Zs", "Z[", "Z0" }; int main(void) { lpf = calloc(N + 3, sizeof(uint16_t)); if (!lpf) { fprintf(stderr, "alloc\n"); return 1; } for (uint32_t i = 2; (uint64_t)i * i <= N + 2; i++) if (!lpf[i]) for (uint64_t j = (uint64_t)i * i; j <= N + 2; j += i) if (!lpf[j]) lpf[j] = (uint16_t)i; uint32_t primes[2000], np = 0; for (uint32_t i = 2; np < 2000 && i < 20000; i++) if (is_prime(i)) primes[np++] = i; uint64_t tot_bad[NW] = {0}, tot_miss[NW] = {0}, p_bad[NW] = {0}, p_miss[NW] = {0}; uint64_t fb_top = 0, fb_bottom = 0, fb_other = 0, fb_none = 0, nprimes = 0; printf("# p p' | S cand act | Z cand act | bad,miss per window S S<= Z Z<= Zs Z[ Z0 | first_bad_r class\n"); for (uint32_t k = 0; k + 1 < np && primes[k] <= PMAX; k++) { uint32_t p = primes[k], pn = primes[k + 1]; uint64_t p2 = (uint64_t)p * p, pn2 = (uint64_t)pn * pn; uint64_t cand[NW] = {0}, act[NW] = {0}, bad[NW] = {0}, miss[NW] = {0}; for (uint64_t r = 1; r < pn2; r += 2) { int slot = hole(r, p) && hole(r + 2, p); int twin = is_prime(r) && is_prime(r + 2); if (!slot && !twin) continue; int in[NW]; in[S] = r > p && r + 2 < p2; in[SLE] = r > p && r + 2 <= p2; in[Z] = r > p && r + 2 < pn2; in[ZLE] = r > p && r + 2 <= pn2; in[ZS] = r > p && r < pn2; in[ZC] = r >= p && r + 2 < pn2; in[Z0] = r >= 1 && r + 2 < pn2; for (int w = 0; w < NW; w++) if (in[w]) { cand[w] += slot; act[w] += twin; bad[w] += slot && !twin; miss[w] += twin && !slot; } } // first slot above p that is not a twin prime pair uint64_t fb = 0; for (uint64_t r = (p + 1) | 1; r + 2 <= N; r += 2) if (hole(r, p) && hole(r + 2, p) && !(is_prime(r) && is_prime(r + 2))) { fb = r; break; } const char *cls; if (!fb) { cls = "none<=N"; fb_none++; } else if (fb + 2 == pn2) { cls = "top=p'^2"; fb_top++; } else if (fb == pn2) { cls = "bottom=p'^2"; fb_bottom++; } else { cls = "other"; fb_other++; } if (fb && fb + 2 < pn2) { fprintf(stderr, "FALSIFIER p=%u r=%llu\n", p, (unsigned long long)fb); } printf("%u %u | %llu %llu | %llu %llu |", p, pn, (unsigned long long)cand[S], (unsigned long long)act[S], (unsigned long long)cand[Z], (unsigned long long)act[Z]); for (int w = 0; w < NW; w++) printf(" %llu,%llu", (unsigned long long)bad[w], (unsigned long long)miss[w]); printf(" | %llu %s\n", (unsigned long long)fb, cls); for (int w = 0; w < NW; w++) { tot_bad[w] += bad[w]; tot_miss[w] += miss[w]; p_bad[w] += bad[w] > 0; p_miss[w] += miss[w] > 0; } nprimes++; } printf("# SUMMARY over %llu primes p = 2..%u\n", (unsigned long long)nprimes, PMAX); for (int w = 0; w < NW; w++) printf("# %-3s bad slots %llu (at %llu primes) missed twins %llu (at %llu primes)\n", wname[w], (unsigned long long)tot_bad[w], (unsigned long long)p_bad[w], (unsigned long long)tot_miss[w], (unsigned long long)p_miss[w]); printf("# first bad slot above p: top member = p'^2 at %llu primes, bottom member = p'^2 at %llu, other %llu, none <= N %llu\n", (unsigned long long)fb_top, (unsigned long long)fb_bottom, (unsigned long long)fb_other, (unsigned long long)fb_none); return 0; }