/- Copyright 2026 The Formal Conjectures Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -/ import FormalConjecturesUtil

Erdős Problem 538

Reference: erdosproblems.com/538

open Filteropen scoped Topologynamespace Erdos538open scoped Classical in

The representations m = p * a with p prime and a ∈ A.

def representations (A : Finset ) (m : ) : Finset ( × ) := (Finset.range (m + 1) ×ˢ A).filter (fun pa => Nat.Prime pa.1 m = pa.1 * pa.2)

A ⊆ {1, …, N} and every m has at most r representations m = p a.

def Admissible (r N : ) (A : Finset ) : Prop := ( a A, 1 a a N) m : , (representations A m).card r

The reciprocal sum ∑_{n ∈ A} 1/n of the problem.

def reciprocalMass (A : Finset ) : := a A, (1 : ) / a

The largest reciprocal sum ∑_{n ∈ A} 1/n over admissible A ⊆ {1, …, N}.

noncomputable def maxMass (r N : ) : := sSup ((fun A => (reciprocalMass A : )) '' {A : Finset | Admissible r N A})

Let $r\geq 2$ and suppose that $A\subseteq{1,\ldots,N}$ is such that, for any $m$, there are at most $r$ solutions to $m=pa$ where $p$ is prime and $a\in A$. Give the best possible upper bound for $\sum_{n\in A}\frac{1}{n}$.

The order is known — ∑ 1/n = Θ_r(log N / loglog N) (see erdos_538.matching_order) — but the sharp constant is not. This asks whether maxMass r N has a well-defined leading constant c_r in c_r · log N / loglog N.

@[category research open, AMS 11] theorem erdos_538 : answer(sorry) r : , 2 r c : , 0 < c Tendsto (fun N : => maxMass r N * Real.log (Real.log N) / Real.log N) atTop (𝓝 c) := True (r : ), 2 r c, 0 < c Tendsto (fun N maxMass r N * Real.log (Real.log N) / Real.log N) atTop (𝓝 c) All goals completed! 🐙

The reciprocal sum has matching order Θ_r(log N / loglog N): an explicit upper bound for every admissible A, together with a witnessing construction achieving the same order. This pins the order (up to the one iterated-logarithm factor) but not the sharp constant asked for in erdos_538.

@[category research solved, AMS 11, formal_proof using lean4 at "https://github.com/williamjblair/lean-proofs/blob/4f915a323443bfb1709a6805a013812016dca88a/starfleet/erdos-538/Research/FinalMatchingOrder.lean"] theorem erdos_538.matching_order (r N : ) (hr : 2 r) (hN : 2 N) : ( A : Finset , Admissible r N A Real.log (Real.log (N + 1)) * (reciprocalMass A : ) 2 * r * (1 + Real.log (N * N))) ( A : Finset , Admissible r N A Real.log (N + 1) 4 + (8192 * (Nat.log 2 (Nat.log 2 N) + 1) : ) * (reciprocalMass A : )) := r:N:hr:2 rhN:2 N(∀ (A : Finset ), Admissible r N A Real.log (Real.log (N + 1)) * (reciprocalMass A) 2 * r * (1 + Real.log (N * N))) A, Admissible r N A Real.log (N + 1) 4 + 8192 * ((Nat.log 2 (Nat.log 2 N)) + 1) * (reciprocalMass A) All goals completed! 🐙end Erdos538