{
  "id": "1849",
  "ident": "NS.01849",
  "slug": "erdos-358--f-id",
  "title": "Erdős Problem 358 · f_id",
  "status": "textbook",
  "statement_status": "reviewed",
  "statement_md": "When $A_n = n$, the function $f$ defined above counts the number of odd divisors of $n$.",
  "subjects": [
    "math.CO",
    "math.NT",
    "msc:05",
    "msc:11"
  ],
  "tags": [],
  "collection": "erdos",
  "source_url": null,
  "solved_on_platform": false,
  "needs_answer": false,
  "version": 1,
  "decl_name": "Erdos358.f_id",
  "statement_lean": "theorem f_id : f id = fun n ↦ #{d ∈ n.divisors | Odd d}",
  "challenge_source": "/-\nCopyright 2025 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 358\n\n*References:*\n- [erdosproblems.com/358](https://www.erdosproblems.com/358)\n- [Ta26] T. Tao, [Erdős problem 358](https://terrytao.wordpress.com/wp-content/uploads/2026/02/erdos-358-2.pdf) (2026)\n-/\n\n@[expose] public section\n\nnamespace Erdos358\n\nopen Filter Finset\n\n/-\nLet $a$ be an infinite sequence of integers. `intervalRepresentations A n` is the set of solutions\nto $$n=\\sum_{u\\leq i\\leq v}a_i.$$ where `u` and `v` are positive integers.\n-/\ndef intervalRepresentations (A : ℕ → ℕ) (n : ℕ) : Set (ℕ × ℕ) :=\n  {(u, v) | 0 < u ∧ 0 < v ∧ n = ∑ i ∈ Icc u v, A i}\n\n/-\nLet $a$ be an infinite sequence of integers. Let $f(n)$ count the number of\nsolutions to $$n=\\sum_{u\\leq i\\leq v}a_i.$$\n-/\nnoncomputable def f (A : ℕ → ℕ) (n : ℕ) : ℕ :=\n  Nat.card (intervalRepresentations A n)\n\n/-\nLet $a$ be an infinite sequence of integers. `intervalRepresentationsNonTrivial A n` is the set of\nsolutions to $$n=\\sum_{u\\leq i\\leq v}a_i$$ such that the sum has at least two terms.\n-/\ndef intervalRepresentationsNonTrivial (A : ℕ → ℕ) (n : ℕ) : Set (ℕ × ℕ) :=\n  {(u, v) | 0 < u ∧ 0 < v ∧ u < v ∧ n = ∑ i ∈ Icc u v, A i}\n\n/-\nLet $a$ be an infinite sequence of integers. Let $g(n)$ count the number of\nsolutions to $$n=\\sum_{u\\leq i\\leq v}a_i.$$ such that the sum has at least two terms.\n-/\nnoncomputable def g (A : ℕ → ℕ) (n : ℕ) : ℕ :=\n  Nat.card (intervalRepresentationsNonTrivial A n)\n\n/--\nWhen $A_n = n$, the function $f$ defined above counts the number of odd divisors of $n$.\n-/\n@[category textbook, AMS 5 11]\ntheorem f_id : f id = fun n ↦ #{d ∈ n.divisors | Odd d} := by\n  sorry\n\nset_option linter.style.formal_proof_palomar false in\n/--\nLet $A=\\{a_1 < \\cdots\\}$ be an infinite sequence of integers. Let $f(n)$ count the number of\nsolutions to $$n=\\sum_{u\\leq i\\leq v}a_i.$$\nIs there such an $A$ for which $f(n)\\to \\infty$ as $n\\to \\infty$?\n\nTao [Ta26] constructed such a sequence with $f(n) \\gg \\log n$ for all sufficiently large $n$.\n-/\n@[category research solved, question, AMS 5 11, formal_proof using lean4 at \"https://github.com/plby/lean-proofs/blob/1268917deaaaa0d674f651287027baa26cea9920/src/latest/ErdosProblems/Erdos358.lean#L9111\"]\ntheorem erdos_358.parts.i :\n    ∃ A, StrictMono A ∧ atTop.Tendsto (f A) atTop := by\n  sorry\n\nset_option linter.style.formal_proof_palomar false in\n/--\nLet $A=\\{a_1 < \\cdots\\}$ be an infinite sequence of integers. Let $f(n)$ count the number of\nsolutions to $$n=\\sum_{u\\leq i\\leq v}a_i.$$\nIs there an $A$ such that $f(n)\\geq 2$ for all large $n$?\n\nThis also follows from Tao's construction with $f(n) \\gg \\log n$ [Ta26].\n-/\n@[category research solved, question, AMS 5 11, formal_proof using lean4 at \"https://github.com/plby/lean-proofs/blob/1268917deaaaa0d674f651287027baa26cea9920/src/latest/ErdosProblems/Erdos358.lean#L9115\"]\ntheorem erdos_358.parts.ii :\n    ∃ A, StrictMono A ∧ ∀ᶠ n in atTop, 2 ≤ f A n := by\n  sorry\n\n/--\nWhen $A =\\{a_1 < \\cdots\\}$ corresponds to the set of primes, it is conjectured that the\n$\\limsup$ of the number of representations $$n=\\sum_{u\\leq i\\leq v}a_i$$ is infinite.\n-/\n@[category research open, AMS 5 11]\ntheorem erdos_358.variants.prime_set :\n    atTop.limsup (fun n ↦ (f (Nat.nth Nat.Prime) n : ℕ∞)) = ⊤ := by\n  sorry\n\n/--\nWhen $A =\\{a_1 < \\cdots\\}$ corresponds to the set of primes, it is conjectured that the set of\nnumbers $n$ that have representations $$n=\\sum_{u\\leq i\\leq v}a_i$$ has positive upper density.\n-/\n@[category research open, AMS 5 11]\ntheorem erdos_358.variants.prime_set_density_representation :\n    0 < {n : ℕ | intervalRepresentations (Nat.nth Nat.Prime) n |>.Nonempty}.upperDensity := by\n  sorry\n\n/--\nIf $A$ is strictly increasing then any $n > 0$ has at most one representation\n$$n=\\sum_{u\\leq i\\leq v}a_i$$ with a single term, so discarding the single-term representations\nloses at most one solution.\n-/\n@[category API, AMS 5 11]\ntheorem one_le_g_of_two_le_f {A : ℕ → ℕ} (hA : StrictMono A) {n : ℕ} (hn : 0 < n)\n    (hf : 2 ≤ f A n) : 1 ≤ g A n := by\n  classical\n  have hfin : (intervalRepresentations A n).Finite := by\n    rcases Set.finite_or_infinite (intervalRepresentations A n) with h | h\n    · exact h\n    · rw [f, @Nat.card_eq_zero_of_infinite _ h.to_subtype] at hf\n      omega\n  have hsub : intervalRepresentationsNonTrivial A n ⊆ intervalRepresentations A n := by\n    rintro ⟨u, v⟩ hr\n    simp only [intervalRepresentationsNonTrivial, Set.mem_ofPred_eq] at hr\n    simp only [intervalRepresentations, Set.mem_ofPred_eq]\n    exact ⟨hr.1, hr.2.1, hr.2.2.2⟩\n  refine (Set.ncard_pos (hfin.subset hsub)).mpr ?_\n  by_contra hempty\n  rw [Set.not_nonempty_iff_eq_empty] at hempty\n  -- Without a representation of length at least two, every representation is a single term.\n  have key : ∀ r ∈ intervalRepresentations A n, r.1 = r.2 ∧ A r.1 = n := by\n    rintro ⟨u, v⟩ hr\n    simp only [intervalRepresentations, Set.mem_ofPred_eq] at hr\n    obtain ⟨hu, hv, hsum⟩ := hr\n    have hle : u ≤ v := by\n      by_contra hc\n      rw [Finset.Icc_eq_empty hc, Finset.sum_empty] at hsum\n      omega\n    have huv : u = v := by\n      rcases eq_or_lt_of_le hle with h | h\n      · exact h\n      · exact absurd (Set.eq_empty_iff_forall_notMem.mp hempty (u, v)\n          (by simp only [intervalRepresentationsNonTrivial, Set.mem_ofPred_eq]\n              exact ⟨hu, hv, h, hsum⟩)) (by simp)\n    subst huv\n    exact ⟨rfl, by simpa using hsum.symm⟩\n  -- Injectivity of `A` then makes that single term unique, contradicting `2 ≤ f A n`.\n  have := hfin.to_subtype\n  obtain ⟨p, hp, q, hq, hpq⟩ := Set.one_lt_ncard_iff_nontrivial.mp hf\n  obtain ⟨hp₁, hpn⟩ := key p hp\n  obtain ⟨hq₁, hqn⟩ := key q hq\n  exact hpq (Prod.ext (hA.injective (hpn.trans hqn.symm))\n    (by rw [← hp₁, ← hq₁]; exact hA.injective (hpn.trans hqn.symm)))\n\n/--\nIn [ErGr80] Erdős and Graham further asked whether there is an $A$ with $f(n)\\geq 1$ for all\nlarge $n$. Egami observed that this holds trivially for $a_n=n$, so they may have intended to\ncount only those representations $$n=\\sum_{u\\leq i\\leq v}a_i$$ that use at least two consecutive\nterms, which is what $g$ counts.\n\nThis follows from Tao's construction [Ta26], which gives $f(n)\\gg\\log n$: see\n`erdos_358.parts.ii` and `one_le_g_of_two_le_f`.\n-/\n@[category research solved, AMS 5 11]\ntheorem erdos_358.variants.one_le :\n    ∃ A, StrictMono A ∧ ∀ᶠ n in atTop, 1 ≤ g A n := by\n  obtain ⟨A, hA, hf⟩ := erdos_358.parts.ii\n  refine ⟨A, hA, ?_⟩\n  filter_upwards [hf, eventually_gt_atTop 0] with n hn hn₀\n  exact one_le_g_of_two_le_f hA hn₀ hn\n\n\nend Erdos358\n",
  "statement_hash": "bec1c01f25e29f5c6cbb0ac8ae5fa5562e6506b4077004101a84f3eae60d4299",
  "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."
}