{
  "id": "3296",
  "ident": "NS.03296",
  "slug": "erdos-819",
  "title": "Erdős Problem 819",
  "status": "open",
  "statement_status": "reviewed",
  "statement_md": "Let $f(N)$ be maximal such that there exists $A\\subseteq \\{1,\\ldots,N\\}$ with\n$\\lvert A\\rvert=\\lfloor N^{1/2}\\rfloor$ such that $\\lvert (A+A)\\cap [1,N]\\rvert=f(N)$.\nEstimate $f(N)$.",
  "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": "Erdos819.erdos_819",
  "statement_lean": "theorem erdos_819 : (fun N ↦ (f N : ℝ)) ~[atTop] erdos_819.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 819\n\n*References:*\n- [erdosproblems.com/819](https://www.erdosproblems.com/819)\n- [Er91] Erdős, P., *Problems and results in combinatorial analysis and combinatorial number\n  theory*. Graph theory, combinatorics, and applications, Vol. 1 (Kalamazoo, MI, 1988) (1991),\n  397-406.\n- [ErFr91] Erdős, P. and Freud, R., *On sums of a Sidon-sequence*. J. Number Theory 38 (1991),\n  196-205.\n-/\n\n@[expose] public section\n\nopen Filter Asymptotics\nopen scoped Finset Pointwise\n\nnamespace Erdos819\n\n/-- $f(N)$ is the maximum of $\\lvert (A + A) \\cap [1, N] \\rvert$ over all\n$A \\subseteq \\{1, \\ldots, N\\}$ with $\\lvert A \\rvert = \\lfloor N^{1/2} \\rfloor$, where\n$\\lfloor N^{1/2} \\rfloor$ is `Nat.sqrt N`. Such sets exist for every $N$, since\n$\\lfloor N^{1/2} \\rfloor \\leq N$, so the maximum is over a nonempty family. -/\ndef f (N : ℕ) : ℕ :=\n  (Finset.powersetCard (Nat.sqrt N) (Finset.Icc 1 N)).sup\n    fun A ↦ #((A + A) ∩ Finset.Icc 1 N)\n\n/-- Trivial upper bound: $f(N) \\leq N$. -/\n@[category API, AMS 5 11]\ntheorem f_le (N : ℕ) : f N ≤ N := by\n  refine Finset.sup_le fun A _ ↦ ?_\n  calc #((A + A) ∩ Finset.Icc 1 N) ≤ #(Finset.Icc 1 N) :=\n        Finset.card_le_card Finset.inter_subset_right\n    _ = N := by simp\n\n/-- Every sum $a + b$ with $a, b \\in A$ comes from an unordered pair $\\{a, b\\}$, so\n$\\lvert A + A\\rvert \\leq \\binom{\\lvert A\\rvert + 1}{2}$. -/\n@[category API, AMS 5 11]\ntheorem card_add_self_le (A : Finset ℕ) : #(A + A) ≤ (#A + 1).choose 2 := by\n  rw [← Finset.card_sym2]\n  calc #(A + A) ≤ #(A.sym2.image (Sym2.lift ⟨fun a b ↦ a + b, fun a b ↦ add_comm a b⟩)) := by\n        refine Finset.card_le_card fun x hx ↦ ?_\n        obtain ⟨a, ha, b, hb, rfl⟩ := Finset.mem_add.1 hx\n        exact Finset.mem_image.2 ⟨s(a, b), Finset.mk_mem_sym2_iff.2 ⟨ha, hb⟩, rfl⟩\n    _ ≤ #A.sym2 := Finset.card_image_le\n\n/-- With $k = \\lfloor N^{1/2} \\rfloor$, we have $f(N) \\leq \\binom{k+1}{2} = (k^2 + k)/2$, and\n$k^2 \\leq N$, $k \\leq N^{1/2}$. -/\n@[category API, AMS 5 11]\ntheorem f_le_half_add_sqrt (N : ℕ) : (f N : ℝ) ≤ (N + Real.sqrt N) / 2 := by\n  have hf : f N ≤ (Nat.sqrt N + 1).choose 2 := by\n    refine Finset.sup_le fun A hA ↦ ?_\n    rw [← (Finset.mem_powersetCard.1 hA).2]\n    exact (Finset.card_le_card Finset.inter_subset_left).trans (card_add_self_le A)\n  have hsq : ((Nat.sqrt N : ℕ) : ℝ) ^ 2 ≤ N := by exact_mod_cast Nat.sqrt_le' N\n  have hle : ((Nat.sqrt N : ℕ) : ℝ) ≤ Real.sqrt N := Real.nat_sqrt_le_real_sqrt\n  calc (f N : ℝ) ≤ ((Nat.sqrt N + 1).choose 2 : ℕ) := by exact_mod_cast hf\n    _ = ((Nat.sqrt N : ℝ) ^ 2 + Nat.sqrt N) / 2 := by\n        rw [Nat.cast_choose_two]; push_cast; ring\n    _ ≤ (N + Real.sqrt N) / 2 := by linarith\n\ndef erdos_819.answer : ℕ → ℝ := sorry\n\n/--\nLet $f(N)$ be maximal such that there exists $A\\subseteq \\{1,\\ldots,N\\}$ with\n$\\lvert A\\rvert=\\lfloor N^{1/2}\\rfloor$ such that $\\lvert (A+A)\\cap [1,N]\\rvert=f(N)$.\nEstimate $f(N)$.\n-/\n@[category research open, question value, AMS 5 11]\ntheorem erdos_819 : (fun N ↦ (f N : ℝ)) ~[atTop] erdos_819.answer := by\n  sorry\n\n/--\nErdős and Freud [ErFr91] proved\n$$\\left(\\frac{3}{8}-o(1)\\right)N \\leq f(N) \\leq \\left(\\frac{1}{2}+o(1)\\right)N.$$\n\nThis is the lower bound.\n-/\n@[category research solved, AMS 5 11]\ntheorem erdos_819.variants.erdos_freud_lower :\n    ∀ ε > (0 : ℝ), ∀ᶠ N : ℕ in atTop, (3 / 8 - ε) * N ≤ (f N : ℝ) := by\n  sorry\n\n/--\nErdős and Freud [ErFr91] proved\n$$\\left(\\frac{3}{8}-o(1)\\right)N \\leq f(N) \\leq \\left(\\frac{1}{2}+o(1)\\right)N.$$\n\nThis is the upper bound.\n-/\n@[category research solved, AMS 5 11]\ntheorem erdos_819.variants.erdos_freud_upper :\n    ∀ ε > (0 : ℝ), ∀ᶠ N : ℕ in atTop, (f N : ℝ) ≤ (1 / 2 + ε) * N := by\n  intro ε hε\n  filter_upwards [eventually_ge_atTop ⌈1 / (4 * ε ^ 2)⌉₊] with N hN\n  have hN' : 1 / (4 * ε ^ 2) ≤ (N : ℝ) := (Nat.le_ceil _).trans (by exact_mod_cast hN)\n  have h1 : 1 ≤ 4 * ε ^ 2 * N := by\n    rw [div_le_iff₀ (by positivity)] at hN'\n    linarith\n  -- $\\sqrt{N} \\leq 2\\varepsilon N$, since $N \\leq (2\\varepsilon N)^2$ once $4\\varepsilon^2 N \\geq 1$.\n  have hs : Real.sqrt N ≤ 2 * ε * N := by\n    rw [Real.sqrt_le_left (by positivity)]\n    nlinarith [(Nat.cast_nonneg N : (0 : ℝ) ≤ N)]\n  linarith [f_le_half_add_sqrt N]\n\nend Erdos819\n",
  "statement_hash": "6d005b2a178f3647e9924775b60a983e6dd52d93dcdf423d14d886d118bc4e24",
  "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."
}