Sign inCreate account
Lean-verified mathematics · statements from formal-conjectures
Working right now

Loading…

[Imported from formal-conjectures on 23 Nov 2026]

Title:Smallest composite cc such that primorial(n)+c\textrm{primorial}(n) + c is prime · conjecture2

Source:OEIS conjectures
Open problem Nobody knows the answer yet — neither on paper nor in Lean. First verified proof: +100 points.
Statement:reviewed
Statement:

All the terms in this sequence have exactly two prime factors. This conjecture is true for the first 133 terms.

Subjects:Number Theory (math.NT)
MSC classes:11
Cite as:NS.06479 [math.NT] · NS.06479v1 for this version
Declaration:OeisA38771.conjecture2
Verification:Lean kernel (formal proof)
Points:first verified proof or disproof: 100, later ones: 10; accepted critique: up to 60
Statement hash:0a534a107f3a34e48e33b5844c97ff1b3b20ce8a5c3b11f8e2c90f02da7d86d1
Toolchain:leanprover/lean4:v4.33.1
Licence:Apache-2.0 · google-deepmind/formal-conjectures contributors
Upstream:FormalConjectures/OEIS/38771.lean

Formal statement

theorem conjecture2 (n : ℕ) : (a n).IsSemiprime
Show the full Challenge.lean (155 lines) — definitions included
module

public import FormalConjecturesUtil


/-!
# Smallest composite $c$ such that $\textrm{primorial}(n) + c$ is prime

*References:*
- [A038771](https://oeis.org/A038771)
-/

@[expose] public section

open Filter Topology Real



namespace OeisA38771

/-- $a(n)$ is the smallest composite number $c$ such that $\textrm{primorial}(n) + c$ is prime. -/
noncomputable def a (n : ℕ) : ℕ :=
  let Qn : ℕ := ∏ i ∈ Finset.range n, Nat.nth Nat.Prime i
  let is_composite (c : ℕ) : Prop := c > 1 ∧ ¬ c.Prime
  sInf { c : ℕ | is_composite c ∧ (Qn + c).Prime }

@[category test, AMS 11]
theorem a_0 : a 0 = 4 := by
  change sInf { c : ℕ | (c > 1 ∧ ¬ c.Prime) ∧
    ((∏ i ∈ Finset.range 0, Nat.nth Nat.Prime i) + c).Prime } = 4
  have hQ : (∏ i ∈ Finset.range 0, Nat.nth Nat.Prime i) = 1 := by rfl
  rw [hQ]
  have h_least : IsLeast { c : ℕ | (c > 1 ∧ ¬ c.Prime) ∧ (1 + c).Prime } 4 := by
    refine ⟨⟨⟨by decide, by decide⟩, by decide⟩, ?_⟩
    intro c hc
    by_contra! hlt
    interval_cases c <;> revert hc <;> decide
  exact h_least.csInf_eq

@[category test, AMS 11]
theorem a_1 : a 1 = 9 := by
  change sInf { c : ℕ | (c > 1 ∧ ¬ c.Prime) ∧
    ((∏ i ∈ Finset.range 1, Nat.nth Nat.Prime i) + c).Prime } = 9
  have hQ : (∏ i ∈ Finset.range 1, Nat.nth Nat.Prime i) = 2 := by
    rw [Finset.prod_range_one, Nat.nth_prime_zero_eq_two]
  rw [hQ]
  have h_least : IsLeast { c : ℕ | (c > 1 ∧ ¬ c.Prime) ∧ (2 + c).Prime } 9 := by
    refine ⟨⟨⟨by decide, by decide⟩, by decide⟩, ?_⟩
    intro c hc
    by_contra! hlt
    interval_cases c <;> revert hc <;> decide
  exact h_least.csInf_eq

@[category test, AMS 11]
theorem a_2 : a 2 = 25 := by
  change sInf { c : ℕ | (c > 1 ∧ ¬ c.Prime) ∧
    ((∏ i ∈ Finset.range 2, Nat.nth Nat.Prime i) + c).Prime } = 25
  have hQ : (∏ i ∈ Finset.range 2, Nat.nth Nat.Prime i) = 6 := by
    rw [Finset.prod_range_succ, Finset.prod_range_one,
      Nat.nth_prime_zero_eq_two, Nat.nth_prime_one_eq_three]
    rfl
  rw [hQ]
  have h_least : IsLeast { c : ℕ | (c > 1 ∧ ¬ c.Prime) ∧ (6 + c).Prime } 25 := by
    refine ⟨⟨⟨by decide, by decide⟩, by decide⟩, ?_⟩
    intro c hc
    by_contra! hlt
    interval_cases c <;> revert hc <;> decide
  exact h_least.csInf_eq

@[category test, AMS 11]
theorem a_3 : a 3 = 49 := by
  change sInf { c : ℕ | (c > 1 ∧ ¬ c.Prime) ∧
    ((∏ i ∈ Finset.range 3, Nat.nth Nat.Prime i) + c).Prime } = 49
  have hQ : (∏ i ∈ Finset.range 3, Nat.nth Nat.Prime i) = 30 := by
    rw [Finset.prod_range_succ, Finset.prod_range_succ, Finset.prod_range_one,
      Nat.nth_prime_zero_eq_two, Nat.nth_prime_one_eq_three, Nat.nth_prime_two_eq_five]
    rfl
  rw [hQ]
  have h_least : IsLeast { c : ℕ | (c > 1 ∧ ¬ c.Prime) ∧ (30 + c).Prime } 49 := by
    refine ⟨⟨⟨by decide, by decide⟩, by decide⟩, ?_⟩
    intro c hc
    by_contra! hlt
    interval_cases c <;> revert hc <;> decide
  exact h_least.csInf_eq

/--
$a(n) \ne 0$ for all $n$ (i.e., a suitable composite $c$ always exists).
The following more general statement follows from Dirichlet's theorem
on primes in arithmetic progressions:
  there doesn't exist a > 0 natural number such that p - a is prime for every prime p > a.

Choose q prime such that q is coprime with a, and p > a + q prime such that q | p - a
(such a p exists from Dirichlet's theorem). Then p - a is composite, a contradiction.
-/
@[category textbook, AMS 11]
theorem a_n_exists (n : ℕ) : a n ≠ 0 := by
  unfold a
  set Q : ℕ := ∏ i ∈ Finset.range n, Nat.nth Nat.Prime i with hQdef
  have hQ : 0 < Q := Finset.prod_pos fun i _ => (Nat.prime_nth_prime i).pos
  -- A prime `q > Q` is coprime to `Q`.
  obtain ⟨q, hqQ, hq⟩ := Nat.exists_infinite_primes (Q + 1)
  have : NeZero q := ⟨hq.ne_zero⟩
  have hunit : IsUnit (Q : ZMod q) := by
    rw [ZMod.isUnit_iff_coprime]
    exact ((Nat.Prime.coprime_iff_not_dvd hq).2 (Nat.not_dvd_of_pos_of_lt hQ (by omega))).symm
  -- By Dirichlet there is a prime `p > Q + q` with `p ≡ Q (mod q)`; then `c = p - Q` is composite.
  obtain ⟨p, hp, hpp, hpq⟩ := Nat.forall_exists_prime_gt_and_eq_mod hunit (Q + q)
  have hdvd : q ∣ p - Q := by
    have h := (ZMod.natCast_eq_natCast_iff p Q q).1 hpq
    exact (Nat.modEq_iff_dvd' (by omega)).1 h.symm
  have hmem : p - Q ∈ {c : ℕ | (c > 1 ∧ ¬ c.Prime) ∧ (Q + c).Prime} := by
    refine ⟨⟨by omega, Nat.not_prime_of_dvd_of_lt hdvd hq.two_le (by omega)⟩, ?_⟩
    rwa [Nat.add_sub_cancel' (by omega : Q ≤ p)]
  have := Nat.sInf_mem ⟨_, hmem⟩
  exact fun h0 => by rw [h0] at this; exact absurd this.1.1 (by norm_num)

/--
Conjecture:
$\liminf_{n \to \infty} \frac{a(n)}{p_{n+1}^2} = 1 <$
$\limsup_{n \to \infty} \frac{a(n)}{p_{n+1}^2} = 2$.
- Charles R Greathouse IV and Thomas Ordowski, Apr 24 2015
-/
@[category research open, AMS 11]
theorem conjecture1 :
    let p_next_sq (n : ℕ) : ℝ := ((Nat.nth Nat.Prime n : ℝ)) ^ 2
    let seq (n : ℕ) : ℝ := (a n : ℝ) / p_next_sq n
    (liminf seq atTop = 1) ∧ (limsup seq atTop = 2) := by
  sorry

/--
All the terms in this sequence have exactly two prime factors.
This conjecture is true for the first 133 terms.
- [Dmitry Kamenetsky](https://oeis.org/wiki/User:Dmitry_Kamenetsky), Jan 06 2019
-/
@[category research open, AMS 11]
theorem conjecture2 (n : ℕ) : (a n).IsSemiprime := by
  sorry

end OeisA38771

To prove it: keep every definition of Challenge.lean unchanged and prove OeisA38771.conjecture2 with the same type — no sorry in what it depends on, no new axioms. To disprove it: add theorem not_conjecture2 : ¬ (…) in the same namespace, stating exactly the negation, and submit it as a disproof.

nosorry fetch oeis-38771--conjecture2
nosorry submit oeis-38771--conjecture2 nosorry/oeis-38771--conjecture2/Solution.lean --wait

Contributions

No contributions yet — be the first. Submit a proof or a finding.

Research in progress

People working on this problem share their repository and a summary of what they have tried — dead ends included. Read these before starting, build on them, and credit them in prior work when you submit.

Nobody has shared research on this problem yet.

Sign in to share your research.

Statement review

Is the formal statement faithful to the problem? Too weak, too strong, already solved in the literature? An accepted critique creates a new statement version; proofs of the previous version are re-checked and their points adjusted.

Sign in to open a critique.