Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Unweighted Goldbach count

Definition
LL_Decomp1526a_gcount

by sthubbar · Oct 30, 2026 · Mathlib 0df444a (Lean v4.33.1)

For N∈NN\in\mathbb NN∈N, the natural number g(N)=#{p≤N:p and N−p are both prime}g(N)=\#\{p\le N : p \text{ and } N-p \text{ are both prime}\}g(N)=#{p≤N:p and N−p are both prime}, counting ordered pairs.

Definition code
import Mathlib

namespace LL_Decomp1526a

noncomputable section

open Finset Real
open scoped Chebyshev Classical

def gcount (N : ℕ) : ℕ := #{p ∈ range (N + 1) | p.Prime ∧ (N - p).Prime}

end

end LL_Decomp1526a
Read-back

What the Lean code literally says, in plain math · claude-haiku

Read-back: gcount

For a natural number NNN, gcount(N)\mathrm{gcount}(N)gcount(N) is the number of elements of the set

{ p∈{0,1,2,…,N}  :  p is prime and N−p is prime }.\{\, p \in \{0, 1, 2, \dots, N\} \;:\; p \text{ is prime and } N - p \text{ is prime} \,\}.{p∈{0,1,2,…,N}:p is prime and N−p is prime}.

Inputs and binders. The only input is NNN, ranging over all natural numbers. The bound variable ppp ranges over 000 to NNN inclusive. There are no hypotheses on NNN.

Meaning of the terms. "Prime" has its usual meaning: ppp is prime when p≥2p \ge 2p≥2 and its only positive divisors are 111 and ppp. The difference N−pN - pN−p is ordinary subtraction. Because p≤Np \le Np≤N, it is never truncated.

Counting. The count is over values of ppp, not unordered pairs. Each decomposition N=p+qN = p + qN=p+q into two primes is counted twice, once as ppp and once as q=N−pq = N - pq=N−p, unless p=qp = qp=q.

Edge cases.

  • N=0N = 0N=0 and N=1N = 1N=1: the candidates are 000 and 111, neither of which is prime, so gcount(0)=gcount(1)=0\mathrm{gcount}(0) = \mathrm{gcount}(1) = 0gcount(0)=gcount(1)=0.
  • N≥3N \ge 3N≥3 odd: ppp and N−pN - pN−p have opposite parity, so for both to be prime one of them must equal 222. Hence gcount(N)≤2\mathrm{gcount}(N) \le 2gcount(N)≤2.
Human review
  • Endorsed by Shuze Chen · Oct 30, 2026

    Confirmed by the moderator at approval.

  • Endorsed by sthubbar · Oct 30, 2026

    Confirmed by the mission captain (proposal self-audit).

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me