Goldbach's Conjecture and Crystal Code

This comparison isn’t saying what you think it’s saying, for two reasons.

The first is that you’re conflating people who reject evidence (the people you’re talking about here) with people who are unconvinced because you haven’t shown sufficient evidence (the people you’re talking to).

People would be right to challenge evolution, general relativity, and a round earth without sufficient evidence. I wouldn’t say they’d be right to reject them without evidence to the contrary, but challenging those ideas would be valid.

That brings me to my second point, which is that people aren’t “challenging” evolution, general relativity, and the concept of a round earth. That they’re challenging it implies that they want more evidence. Instead, they’re flat-out rejecting centuries of evidence. They’re not seeking knowledge on these topics. This is an important distinction.

So when I say that it doesn’t say what you think it’s saying, comparing yourself to Darwin, Einstein, Aristotle, and Eratosthenes while comparing people wanting evidence for your claims to right-wing conspiracy theorists is a valid reason to question your credibility.

4 Likes

OK, here’s the paper.
I hope people will actually take the time to study it, and the results presented.
It’s much more than just about Goldbach’s Conjecture.

If there are any questions, please cite the specific page, math, code, data, etc
you have questions about. I will not address ad hominen statements.

Here are links to the paper.
2025/02/01

1 Like

I got help from the D forum to optimize the D version.
It turns out to be a little bit faster than Crystal.

// Compile with ldc2: $ ldc2 --release -O3 -mcpu native prime_pairs_lohi.d
// Run as: echo 100000 | ./prime_pairs_lohi
// Update: 2025/02/02 

module prime_pairs;

import std;
import std.datetime.stopwatch : StopWatch;

void prime_pairs_lohi(uint n) {
  if ((n&1) == 1 || n < 4) { return writeln("Input not even n > 2"); }
  if (n <= 6) { writeln([n, 1]); writeln([n/2, n/2]); writeln([n/2, n/2]); return; }

  // generate the low-half-residues (lhr) r < n/2
  auto ndiv2 = n/2;               // llr:hhr midpoint
  auto rhi   = n-2;               // max residue limit
  uint[] lhr = iota(3, ndiv2, 2).filter!(e => gcd(e, n) == 1).array;

  // store all the powers of the lhr members < n-2
  int[] lhr_mults;                // for lhr values not part of a pcp
  foreach(r; lhr) {               // step thru the lhr members
    auto r_pwr = r;               // set to first power of r
    if (r > rhi/r_pwr) break;     // exit if r^2 > n-2, as all others are too
    while (r < rhi/r_pwr)         // while r^e < n-2
      lhr_mults ~=(r_pwr *= r);   // store its current power of r
  }

  // store all the cross-products of the lhr members < n-2
  foreach(i, r; lhr) {
    auto ri_max = rhi / r;        // ri can't multiply r with values > this
    if (lhr[i+1] > ri_max) break; // exit if product of consecutive r’s > n-2
    foreach(ri; lhr[i+1..$]) {    // for each residue in reduced list
      if (ri > ri_max) break;     // exit for r if cross-product with ri > n-2
      lhr_mults ~= r * ri;        // store value if < n-2
  } }

  // convert lhr_mults vals > n/2 to their lhr complements n-r,
  // store them, those < n/2, in lhr_del; it now holds non-pcp lhr vals
  auto lhr_del = lhr_mults.map!((r_del) => r_del > ndiv2 ? n - r_del : r_del).array;
  lhr_del.sort!("a < b");
  lhr = setDifference(lhr, lhr_del).array;

  writeln([n,     lhr.length]);   // show n and pcp prime pairs count
  writeln([lhr[0],  n-lhr[0]]);   // show first pcp prime pair of n
  writeln([lhr[$-1],n-lhr[$-1]]); // show last  pcp prime pair of n
}

void main() {
  int n;
  readf("%s", &n);                // get input to n from terminal
  auto timer = StopWatch();       // create execution timer
  timer.start();                  // start it
  prime_pairs_lohi(n);            // run routine
  writeln(timer.peek());          // show timer results
}

The D versus Crystal times example.

D (LDC2 1.40)
➜  ~ echo 100000000 |./prime_pairs_lohi                     
[100000000, 291400]
[11, 99999989]
[49999757, 50000243]
7 secs, 422 ms, 641 μs, and 9 hnsecs

Crystal (1.15)
➜  ~ ./prime_pairs_lohi 100_000_000        
[100000000, 291400]
[11, 99999989]
[49999757, 50000243]
00:00:10.454055301

I found one typo for a number (pg 8) so I’ll post an update version at both sites.
It seems no matter how much I checked it something gets past me. :grinning:
If anyone finds more please let me know.

I’ve updated the code to make it shorter and simpler.

def prime_pairs_lohi(n)
  return puts "Input not even n > 2" unless n.even? && n > 2
  return (pp [n, 1]; pp [n//2, n//2]; pp [n//2, n//2]) if n <= 6

  # generate the low-half-residues (lhr) r < n/2
  lhr = 3u64.step(to: n//2, by: 2).select { |r| r if r.gcd(n) == 1 }.to_a
  ndiv2, rhi = n//2, n-2           # lhr:hhr midpoint, max residue limit

  # store all powers and cross-products of the lhr members < n-2
  lhr_mults = [] of typeof(n)      # lhr multiples, not part of a pcp
  lhr_dup = lhr.dup                # make copy of the lhr members list
  while (r = lhr_dup.shift) && !lhr_dup.empty? # do mults of 1st list r w/others
    rmax = rhi // r                # ri can't multiply r with values > this
    lhr_mults << r*r if r < rmax   # for r^2 multiples
    break if lhr_dup[0] > rmax     # exit if product of consecutive r’s > n-2
    lhr_dup.each do |ri|           # for each residue in reduced list
      break if ri > rmax           # exit for r if cross-product with ri > n-2
      lhr_mults << r * ri          # store value if < n-2
    end                            # check cross-products of next lhr member
  end

  # remove from lhr its lhr_mults, convert vals > n/2 to lhr complements first
  lhr -= lhr_mults.map { |r_del| r_del > ndiv2 ? n - r_del : r_del }

  pp [n, lhr.size]                 # show n and pcp prime pairs count
  pp [lhr.first, n-lhr.first]      # show first pcp prime pair of n
  pp [lhr.last,  n-lhr.last]       # show last  pcp prime pair of n
end

def gen_pcp
  n = (ARGV[0].to_u64 underscore: true) # get n input from terminal
  t1 = Time.monotonic             # start execution timing
  prime_pairs_lohi(n)             # execute code
  pp Time.monotonic - t1          # show execution time
end

gen_pcp

I now have versions in the following languages (fastest to slowest):
D
Crystal
Ruby
Julia
Python3

I plan to do Rust next, and probably an obligatory C++.

It’s been a week now since I released the paper and its been…crickets. :scream:

So I assume all this silence means no one can formulate a mathematical argument to refute anything I’ve presented in the paper, which means it’s correct, which means not only has Goldbach’s Conjecture been proved, but a much better bound on p than given by Bertrand’s Postulate has been found.

Wow, not bad work from one 16 page paper! :smile:
This should really shake up the math world, if the pursuit of knowledge is its goal.
We’ll see.

I’ll update the paper today|tomorrow with the shorter|simpler code.

Speaking for myself, I tried to read the underlying Prime Theory thing, and honsestly, i’m 90% sure you lost your marbles by thinking too hard about math.
Don’t feel bad about it, it’s a common thing, and the human brain is very easily tempted to see patterns anywhere.

The main problem though is that you don’t prove anything really.
As far as I can follow you through that paper, you just say "i examined known prime numbers, and then chose arbitrary intervals around them that have some properties and those intervals show other properties, which proves all primes have those properties.

And I really cannot see how anyone even slightly aquainted with math, would consider that prof of anything.

so, no. From what i saw, you didn’t prove anything, except that too much math drives people crazy.

3 Likes

Their code is just a bloated and imperformant form of a Sieve of Eratosthenes. Most of the code doesn’t do anything.

And yes, their “proof” is a classical fallacy of extrapolating a pattern. In my university, we jokingly called this type of proof “Incomplete Induction”, as opposed to “Complete Induction” for an actual proof by induction.

I highly think that this thread should finally be put to rest, because jzakiya is obviously not interested in actual code improvements, but only brags about their alleged proof. I stopped engaging with them a while ago (which they funnily seem to take as further confirmation for their paper).

4 Likes

Someone in the Python forum did a faster version (which i modded a bit).
When run on latest Python 3.13.2 performance is comparable to Ruby 3.4.1
(one is faster depending on values of n).

import sys
import time
from math import gcd

def prime_pairs_lohi(n):
    if (n & 1 == 1) or n < 4: print("Input not even n > 2"); return
    if n <= 6: print([n, 1]); print([n // 2, n // 2]); print([n // 2, n // 2]); return
    ndiv2, rhi = n // 2, n - 2                # lhr:hhr midpoint, max residue limit

    # generate the low-half-residues (lhr) r < n/2
    lhr = [r for r in range(3, ndiv2, 2) if gcd(r, n) == 1]

    # identify and store powers and cross-products of lhr members < n-2
    lhr_mults = []                             # lhr multiples, not part of a pcp
    L = len(lhr)-1                             # last lhr index value
    for i in range(L):                         # iterate thru lhr indexes
        r = lhr[i]                             # current lhr value
        rmax = rhi // r                        # r can't multiply others with values > this.
        if r < rmax: lhr_mults.append(r * r)   # for r^2 multiples
        if lhr[i + 1] > rmax: break            # exit if product of consecutive r’s > n-2
        for j in range(i + 1, L):              # for reduced lhr array indexes
            if lhr[j] > rmax: break            # exit for r if cross-product with ri > n-2
            lhr_mults.append(r * lhr[j])       # otherwise store cross-product

    # remove from lhr its lhr_mults, convert vals > n/2 to lhr complements first
    lhr_del = { (r if r < ndiv2 else n - r) for r in lhr_mults }
    lhr = [r for r in lhr if r not in lhr_del] # remove lhr_mults from lhr, pcp remain

    print([n, len(lhr)])                       # show n and pcp prime pairs count
    print([lhr[0], n - lhr[0]])                # show first pcp prime pair of n
    print([lhr[-1], n - lhr[-1]])              # show last  pcp prime pair of n

if __name__ == '__main__':
    # Allow input from the command line like Ruby.
    # Also allow underscores in numbers (e.g. 1_000_000)
    if len(sys.argv) > 1:
        # Remove any underscores then convert to int.
        try:
            n = int(sys.argv[1].replace('_', ''))
        except ValueError:
            print("Invalid number:", sys.argv[1])
            sys.exit(1)
    else:
        try:
            n = int(input("Enter even number > 2: ").replace('_', ''))
        except ValueError:
            print("Invalid input.")
            sys.exit(1)
    start_time = time.time()
    prime_pairs_lohi(n)
    print(time.time() - start_time)

Here’s the Go version. Go isn’t really designed for intensive numerical computing.
It doesn’t handle the removal of elements in one array from another very fast.
For n > 1,000,000 performance really drops.

// Compile as: $ go build prime_pairs_lohi.go
// Run as: $ ./prime_pairs_lohi 123_456

package main

import (
  "os"
  "fmt"
  "time"
  "slices"
  "strconv"
  "strings"
)

func coprime(m, n uint) bool {
  for m | 1 != 1 { m, n = n % m, m }
  return (m > 0)
}

func prime_pairs_lohi(n uint) {
  if n&1 == 1 || n < 4 {fmt.Printf("Input not even n > 2"); return }
  if n <= 6 { fmt.Printf("[%d, %d]\n[%d, %d]\n[%d, %d]\n",n,1,n/2,n/2,n/2,n/2); return }

  // generate the low-half-residues (lhr) r < n/2
  ndiv2, rhi := n/2, n-2                    // lhr:hhr midpoint, max residue limit
  lhr := []uint{}                           // to store low half residues
  var r uint = 3
  for r < ndiv2 {if coprime(r, n) { lhr = append(lhr, r)}; r += 2 }

  // identify and store all powers and cross-products of the lhr members < n-2
  lhr_mults := []uint{}                     // lhr multiples, not part of a pcp
  for i := 1; i < len(lhr)-1; i++ {         // iterate thru lhr to find prime multiples
    r := lhr[i-1]                           // for current residue
    rmax := rhi / r                         // ri can't multiply r with values > this
    if r < rmax {lhr_mults = append(lhr_mults, r * r)}  // for r^2 multiples
    if lhr[i] > rmax { break }              // exit if product of consecutive r’s > n-2
    for j := i; j < len(lhr)-1; j++ {       // iterate thru lhr to find prime multiples
      if lhr[j] > rmax { break }            // exit for r if cross-product with ri > n-2
      lhr_mults = append(lhr_mults, r * lhr[j]) // store value if < n-2
  } }

  // convert lhr_mults vals > n/2 to their lhr complements n-r,
  // store them, those < n/2, in lhr_del; it now holds non-pcp lhr vals
  lhr_del := []uint{}
  for _, r := range(lhr_mults) {if r > ndiv2 {r = n - r}; lhr_del = append(lhr_del, r)}
  lhr = slices.DeleteFunc(lhr, func(n uint) bool { return slices.Contains(lhr_del, n) })

  lcnt := len(lhr)
  fmt.Printf("[%d, %d]\n", n, lcnt)                    // show n and pcp prime pairs count
  fmt.Printf("[%d, %d]\n", lhr[0],n-lhr[0])            // show first pcp prime pair of n
  fmt.Printf("[%d, %d]\n", lhr[lcnt-1], n-lhr[lcnt-1]) // show last  pcp prime pair of n
}

func main() {
  s := os.Args[1]
  num := strings.Replace(s, "_", "", -1)
  n, err := strconv.ParseUint(num, 10, 64)
  if err != nil {panic(err)}

  ts := time.Now()
  prime_pairs_lohi(uint(n))
  te := time.Now()
  fmt.Printf("%v",te.Sub(ts))
}