{
  "id": "3376",
  "ident": "NS.03376",
  "slug": "erdos-840",
  "title": "Erdős Problem 840",
  "status": "open",
  "statement_status": "reviewed",
  "statement_md": "Let $f(N)$ be the size of the largest quasi-Sidon subset $A\\subset\\{1,\\ldots,N\\}$, where we say\nthat $A$ is quasi-Sidon if\n$$\\lvert A+A\\rvert=(1+o(1))\\binom{\\lvert A\\rvert}{2}.$$\nHow does $f(N)$ grow?\n\nFollowing [Er81h, p. 175], we ask for the largest $c$ such that there are quasi-Sidon sets\n$A \\subseteq \\{1, \\ldots, N\\}$ with $\\lvert A\\rvert = (1+o(1))cN^{1/2}$.",
  "subjects": [
    "math.CO",
    "math.NT",
    "msc:05",
    "msc:11"
  ],
  "tags": [
    "question"
  ],
  "collection": "erdos",
  "source_url": null,
  "solved_on_platform": false,
  "needs_answer": false,
  "version": 1,
  "decl_name": "Erdos840.erdos_840",
  "statement_lean": "theorem erdos_840 : IsLUB {c : ℝ | IsQuasiSidonConstant c} erdos_840.answer",
  "challenge_source": "/-\nCopyright 2026 The Formal Conjectures Authors.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    https://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n-/\nmodule\n\npublic import FormalConjecturesUtil\n\n/-!\n# Erdős Problem 840\n\n*References:*\n- [erdosproblems.com/840](https://www.erdosproblems.com/840)\n- [Er81h] Erdős, P., *Some problems and results on additive and multiplicative number theory*.\n  Analytic number theory (Philadelphia, Pa., 1980), Lecture Notes in Math. 899 (1981), 171-182.\n  [PDF](https://www.renyi.hu/~p_erdos/1981-33.pdf)\n- [ErFr91] Erdős, P. and Freud, R., *On sums of a Sidon-sequence*. J. Number Theory 38 (1991),\n  196-205.\n- [Pi06] Pikhurko, O., *Dense edge-magic graphs and thin additive bases*. Discrete Math. 306\n  (2006), 2097-2107.\n-/\n\n@[expose] public section\n\nopen Filter Asymptotics\nopen scoped Finset Pointwise\n\nnamespace Erdos840\n\n/-- The constant $c$ is attained by quasi-Sidon sets: there are sets\n$A_N \\subseteq \\{1, \\ldots, N\\}$ with $\\lvert A_N\\rvert = (1+o(1))cN^{1/2}$ and\n$\\lvert A_N+A_N\\rvert=(1+o(1))\\binom{\\lvert A_N\\rvert}{2}$ as $N \\to \\infty$. -/\ndef IsQuasiSidonConstant (c : ℝ) : Prop :=\n  ∃ A : ℕ → Finset ℕ, (∀ N, A N ⊆ Finset.Icc 1 N) ∧\n    (fun N ↦ (#(A N) : ℝ)) ~[atTop] (fun N ↦ c * Real.sqrt N) ∧\n    (fun N ↦ (#(A N + A N) : ℝ)) ~[atTop] (fun N ↦ ((#(A N)).choose 2 : ℝ))\n\n/-- The constant $0$ is attained by the empty sets, so the set of attained constants is\nnonempty. -/\n@[category test, AMS 5 11]\ntheorem isQuasiSidonConstant_zero : IsQuasiSidonConstant 0 := by\n  refine ⟨fun _ ↦ ∅, fun _ ↦ Finset.empty_subset _, ?_, ?_⟩\n  · simpa using (IsEquivalent.refl : (fun _ : ℕ ↦ (0 : ℝ)) ~[atTop] fun _ ↦ 0)\n  · simpa using (IsEquivalent.refl : (fun _ : ℕ ↦ (0 : ℝ)) ~[atTop] fun _ ↦ 0)\n\ndef erdos_840.answer : ℝ := sorry\n\n/--\nLet $f(N)$ be the size of the largest quasi-Sidon subset $A\\subset\\{1,\\ldots,N\\}$, where we say\nthat $A$ is quasi-Sidon if\n$$\\lvert A+A\\rvert=(1+o(1))\\binom{\\lvert A\\rvert}{2}.$$\nHow does $f(N)$ grow?\n\nFollowing [Er81h, p. 175], we ask for the largest $c$ such that there are quasi-Sidon sets\n$A \\subseteq \\{1, \\ldots, N\\}$ with $\\lvert A\\rvert = (1+o(1))cN^{1/2}$.\n-/\n@[category research open, question value, AMS 5 11]\ntheorem erdos_840 : IsLUB {c : ℝ | IsQuasiSidonConstant c} erdos_840.answer := by\n  sorry\n\n/--\nErdős and Freud [ErFr91] proved\n$$\\left(\\frac{2}{\\sqrt{3}}+o(1)\\right)N^{1/2} \\leq f(N) \\leq \\left(2+o(1)\\right)N^{1/2}.$$\n(Although both bounds were already given by Erdős in [Er81h].)\n\nThis is the lower bound. The lower bound is taking a genuine Sidon set $B\\subset [1,N/3]$ of size\n$\\sim N^{1/2}/\\sqrt{3}$ and taking the union with $\\{N-b : b\\in B\\}$.\n-/\n@[category research solved, AMS 5 11]\ntheorem erdos_840.variants.erdos_freud_lower : IsQuasiSidonConstant (2 / Real.sqrt 3) := by\n  sorry\n\n/--\nErdős and Freud [ErFr91] proved\n$$\\left(\\frac{2}{\\sqrt{3}}+o(1)\\right)N^{1/2} \\leq f(N) \\leq \\left(2+o(1)\\right)N^{1/2}.$$\n(Although both bounds were already given by Erdős in [Er81h].)\n\nThis is the upper bound.\n-/\n@[category research solved, AMS 5 11]\ntheorem erdos_840.variants.erdos_freud_upper (c : ℝ) (hc : IsQuasiSidonConstant c) : c ≤ 2 := by\n  by_contra! hlt\n  have hc0 : 0 < c := by linarith\n  obtain ⟨A, hAsub, hk, hs⟩ := hc\n  -- $cN^{1/2} \\to \\infty$, so the constant $1$ is negligible: $|A_N| - 1 \\sim cN^{1/2}$.\n  have hsqrt : Tendsto (fun N : ℕ ↦ c * Real.sqrt N) atTop atTop :=\n    Tendsto.const_mul_atTop hc0 (Real.tendsto_sqrt_atTop.comp tendsto_natCast_atTop_atTop)\n  have hk1 := hk.sub_isLittleO (w := fun _ ↦ (1 : ℝ))\n    (isLittleO_const_left.2 (Or.inr (tendsto_norm_atTop_atTop.comp hsqrt)))\n  -- $\\binom{|A_N|}{2} = |A_N|(|A_N|-1)/2 \\sim (cN^{1/2})^2/2$.\n  have hC := ((hk.mul hk1).div (IsEquivalent.refl (u := fun _ : ℕ ↦ (2 : ℝ)))).congr_left\n    (w := fun N ↦ ((#(A N)).choose 2 : ℝ))\n    (Eventually.of_forall fun N ↦ by simp only [Pi.mul_apply, Pi.sub_apply, Pi.div_apply,\n      Nat.cast_choose_two])\n  -- Hence $|A_N + A_N|/N \\to c^2/2$.\n  have hlim : Tendsto (fun N : ℕ ↦ (#(A N + A N) : ℝ) / N) atTop (nhds (c ^ 2 / 2)) := by\n    refine (((hs.trans hC).div (IsEquivalent.refl (u := fun N : ℕ ↦ (N : ℝ)))).congr_right\n      (w := fun _ ↦ c ^ 2 / 2) ?_).tendsto_const\n    filter_upwards [eventually_gt_atTop 0] with N hN\n    have hN' : (N : ℝ) ≠ 0 := by exact_mod_cast hN.ne'\n    have hsq : Real.sqrt N * Real.sqrt N = N := Real.mul_self_sqrt (Nat.cast_nonneg N)\n    simp only [Pi.mul_apply, Pi.div_apply]\n    rw [show c * Real.sqrt N * (c * Real.sqrt N) = c ^ 2 * (Real.sqrt N * Real.sqrt N) by ring,\n      hsq]\n    field_simp\n  -- But $A_N + A_N \\subseteq [2, 2N]$, so $|A_N + A_N|/N \\leq 2$.\n  have hbound : ∀ᶠ N : ℕ in atTop, (#(A N + A N) : ℝ) / N ≤ 2 := by\n    filter_upwards [eventually_gt_atTop 0] with N hN\n    have hsub : A N + A N ⊆ Finset.Icc 2 (2 * N) := by\n      intro x hx\n      obtain ⟨a, ha, b, hb, rfl⟩ := Finset.mem_add.1 hx\n      have ha' := Finset.mem_Icc.1 (hAsub N ha)\n      have hb' := Finset.mem_Icc.1 (hAsub N hb)\n      exact Finset.mem_Icc.2 ⟨by omega, by omega⟩\n    have hcard : #(A N + A N) ≤ 2 * N := by\n      have := Finset.card_le_card hsub\n      rw [Nat.card_Icc] at this\n      omega\n    rw [div_le_iff₀ (by exact_mod_cast hN)]\n    exact_mod_cast hcard\n  have := le_of_tendsto hlim hbound\n  nlinarith\n\n/--\nThe upper bound was improved by Pikhurko [Pi06] to\n$$f(N) \\leq \\left(\\left(\\frac{1}{4}+\\frac{1}{(\\pi+2)^2}\\right)^{-1/2}+o(1)\\right)N^{1/2}$$\n(the constant here is $=1.863\\cdots$).\n-/\n@[category research solved, AMS 5 11]\ntheorem erdos_840.variants.pikhurko (c : ℝ) (hc : IsQuasiSidonConstant c) :\n    c ≤ (1 / 4 + 1 / (Real.pi + 2) ^ 2) ^ (-(1 : ℝ) / 2) := by\n  sorry\n\nend Erdos840\n",
  "statement_hash": "dc5e2ed339cd5f28ce59635c1a6986a15fd8ed9b4664900e83c70f2fc4a527ad",
  "toolchain": "leanprover/lean4:v4.33.1",
  "upstream_commit": "f9b3868d5ca994a7bf95039bcec05338c0c21e2f",
  "workspace": "formal-conjectures",
  "field": "math",
  "formalization": "formal",
  "verification": "lean-kernel",
  "license": "Apache-2.0",
  "attribution": "google-deepmind/formal-conjectures contributors",
  "metric_name": null,
  "metric_direction": null,
  "critiques": [],
  "public_partial_proofs": [],
  "research_threads": [],
  "instructions": "Read research_threads first: other people's public repositories and what they already tried. Write Solution.lean starting from challenge_source. Keep every definition identical, prove decl_name with exactly the same type, no sorry in its dependency closure, no new axioms, no native_decide, no metaprogramming. Submit with POST /api/v1/submissions."
}