/- Copyright 2025 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. -/ module public import FormalConjecturesUtil

Erdős Problem 357

References:

    erdosproblems.com/357

    [He86] Hegyvári, Norbert, On consecutive sums in sequences. Acta Math. Hungar. (1986), 193--200.

@[expose] public sectionnamespace Erdos357open Filter Asymptoticsdef HasDistinctSums {ι α : Type*} [Preorder ι] [AddCommMonoid α] (a : ι → α) : Prop := {J : Finset ι | (J : Set ι).OrdConnected}.InjOn (fun J ↦ ∑ x ∈ J, a x)

Let $f(n)$ be the maximal $k$ such that there exist integers $1 \le a_1 < \dotsc < a_k \le n$ such that all sums of the shape $\sum_{u \le i \le v} a_i$ are distinct.

noncomputable def f (n : ℕ) : ℕ := sSup {k : ℕ | ∃ a : Fin k → ℤ, Set.range a ⊆ Set.Icc 1 n ∧ StrictMono a ∧ HasDistinctSums a}

Let $f(n)$ be the maximal $k$ such that there exist integers $1 \le a_1 < \dotsc < a_k \le n$ such that all sums of the shape $\sum_{u \le i \le v} a_i$ are distinct. Is $f(n)=o(n)$?

@[category research open, AMS 11] theorem erdos_357.parts.i : (fun n ↦ (f n : ℝ)) =o[atTop] (fun n ↦ (n : ℝ)) := ⊢ (fun n ↦ ↑(f n)) =o[atTop] fun n ↦ ↑n All goals completed! 🐙/- Formalisation note: the next 5 formalisations are an attempt at capturing the question "how does $f(n)$ grow?". In addition to trivial solutions (e.g. setting the `answer` to `0` in some of these), it is possible that some of these admit easy solutions that shouldn't count as genuine solutions. As usual in this repo, solving this problem is not simply filling in the `answer` definition together with a proof of the theorem, but providing a *mathematically interesting* answer. Note also that there might be other reasonable (and non equivalent) formal statements that capture this question. Similar remarks hold for the `variants.monotone` formalisations later in this file. -/ def erdos_357.parts.ii.bigO_version.answer : ℕ → ℝ := sorry

Let $f(n)$ be the maximal $k$ such that there exist integers $1 \le a_1 < \dotsc < a_k \le n$ such that all sums of the shape $\sum_{u \le i \le v} a_i$ are distinct. How does $f(n)$ grow? Can we find a (good) explicit function $g$ such that $g = O(f)$ ?

@[category research open, question value, AMS 11] theorem erdos_357.parts.ii.bigO_version : erdos_357.parts.ii.bigO_version.answer =O[atTop] (fun n ↦ (f n : ℝ)) := ⊢ bigO_version.answer =O[atTop] fun n ↦ ↑(f n) All goals completed! 🐙def erdos_357.parts.ii.bigO_version_symm.answer : ℕ → ℝ := sorry

Let $f(n)$ be the maximal $k$ such that there exist integers $1 \le a_1 < \dotsc < a_k \le n$ such that all sums of the shape $\sum_{u \le i \le v} a_i$ are distinct. How does $f(n)$ grow? Can we find a (good) explicit function $g$ such that $f = O(g)$ ?

@[category research open, question value, AMS 11] theorem erdos_357.parts.ii.bigO_version_symm : (fun n ↦ (f n : ℝ)) =O[atTop] erdos_357.parts.ii.bigO_version_symm.answer := ⊢ (fun n ↦ ↑(f n)) =O[atTop] bigO_version_symm.answer All goals completed! 🐙def erdos_357.parts.ii.bigTheta_version.answer : ℕ → ℝ := sorry

Let $f(n)$ be the maximal $k$ such that there exist integers $1 \le a_1 < \dotsc < a_k \le n$ such that all sums of the shape $\sum_{u \le i \le v} a_i$ are distinct. How does $f(n)$ grow? Can we find a (good) explicit function $g$ such that $f = \Theta(g)$ ?

@[category research open, question value, AMS 11] theorem erdos_357.parts.ii.bigTheta_version : (fun n ↦ (f n : ℝ)) =Θ[atTop] erdos_357.parts.ii.bigTheta_version.answer := ⊢ (fun n ↦ ↑(f n)) =Θ[atTop] bigTheta_version.answer All goals completed! 🐙def erdos_357.parts.ii.littleO_version.answer : ℕ → ℝ := sorry

Let $f(n)$ be the maximal $k$ such that there exist integers $1 \le a_1 < \dotsc < a_k \le n$ such that all sums of the shape $\sum_{u \le i \le v} a_i$ are distinct. How does $f(n)$ grow? Can we find a (good) explicit function $g$ such that $g = o(f)$ ?

@[category research open, question value, AMS 11] theorem erdos_357.parts.ii.littleO_version : erdos_357.parts.ii.littleO_version.answer =o[atTop] (fun n ↦ (f n : ℝ)) := ⊢ littleO_version.answer =o[atTop] fun n ↦ ↑(f n) All goals completed! 🐙def erdos_357.parts.ii.littleO_version_symm.answer : ℕ → ℝ := sorry

Let $f(n)$ be the maximal $k$ such that there exist integers $1 \le a_1 < \dotsc < a_k \le n$ such that all sums of the shape $\sum_{u \le i \le v} a_i$ are distinct. How does $f(n)$ grow? Can we find a (good) explicit function $g$ such that $f = o(g)$ ?

@[category research open, question value, AMS 11] theorem erdos_357.parts.ii.littleO_version_symm : (fun n ↦ (f n : ℝ)) =o[atTop] erdos_357.parts.ii.littleO_version_symm.answer := ⊢ (fun n ↦ ↑(f n)) =o[atTop] littleO_version_symm.answer All goals completed! 🐙

Let $f(n)$ be the maximal $k$ such that there exist integers $1 \le a_1 < \dotsc < a_k \le n$ such that all sums of the shape $\sum_{u \le i \le v} a_i$ are distinct. It is known that $f(n) \geq (2+o(1))\sqrt{n}$. Source: See comment by Desmond Weisenberg here: https://www.erdosproblems.com/forum/thread/357.

@[category research solved, AMS 11] theorem erdos_357.variants.weisenberg : ∃ o : ℕ → ℝ, o =o[atTop] (1 : ℕ → ℝ) ∧ ∀ᶠ n in atTop, (2 + o n) * √n ≤ f n := ⊢ ∃ o, o =o[atTop] 1 ∧ ∀ᶠ (n : ℕ) in atTop, (2 + o n) * √↑n ≤ ↑(f n) All goals completed! 🐙

Suppose $A$ is an infinite set such that all finite sums of consecutive terms of $A$ are distinct. Then $A$ has lower density 0.

@[category research solved, AMS 11] theorem erdos_357.variants.infinite_set_lower_density (A : ℕ → ℕ) (hA : StrictMono A) (hA : HasDistinctSums A) : (Set.range A).lowerDensity = 0 := A:ℕ → ℕhA✝:StrictMono AhA:HasDistinctSums A⊢ (Set.range A).lowerDensity = 0 All goals completed! 🐙

Suppose $A$ is an infinite set such that all finite sums of consecutive terms of $A$ are distinct. Then it is conjectured that $A$ has density 0.

@[category research open, AMS 11] theorem erdos_357.variants.infinite_set_density (A : ℕ → ℕ) (hA : StrictMono A) (hA : HasDistinctSums A) : (Set.range A).HasDensity 0 := A:ℕ → ℕhA✝:StrictMono AhA:HasDistinctSums A⊢ (Set.range A).HasDensity 0 All goals completed! 🐙

Suppose $A$ is an infinite set such that all finite sums of consecutive terms of $A$ are distinct. Then it is conjectured that the sum $\sum_k \frac{1}{a_k}$ converges.

@[category research open, AMS 11] theorem erdos_357.variants.infinite_set_sum (A : ℕ → ℕ) (hA : StrictMono A) (hA : HasDistinctSums A) : Summable (fun i ↦ (1 : ℝ) / A i) := A:ℕ → ℕhA✝:StrictMono AhA:HasDistinctSums A⊢ Summable fun i ↦ 1 / ↑(A i) All goals completed! 🐙

Let $g(n)$ be the maximal $k$ such that there exist integers $1 \le a_1, \dotsc, a_k \le n$ such that all sums of the shape $\sum_{u \le i \le v} a_i$ are distinct.

noncomputable def g (n : ℕ) : ℕ := sSup {k : ℕ | ∃ a : Fin k → ℕ, (Set.range a ⊆ Set.Icc 1 n) ∧ HasDistinctSums a}

Let $g(n)$ be the maximal $k$ such that there exist integers $1 \le a_1, \dotsc, a_k \le n$ such that all sums of the shape $\sum_{u \le i \le v} a_i$ are distinct. Hegyvári [He86] proved that $$\left(\frac 1 3 + o(1) \right)n \leq g(n) \leq \left(\frac 2 3 + o(1) \right)n.$$

@[category research solved, AMS 11] theorem erdos_357.variants.hegyvari : ∃ (o o' : ℕ → ℝ), o =o[atTop] (1 : ℕ → ℝ) ∧ o' =o[atTop] (1 : ℕ → ℝ) ∧ ∀ᶠ n in atTop, (g n : ℝ) ∈ Set.Icc ((1 / 3 + o n) * n) ((2 / 3 + o' n)*n) := ⊢ ∃ o o', o =o[atTop] 1 ∧ o' =o[atTop] 1 ∧ ∀ᶠ (n : ℕ) in atTop, ↑(g n) ∈ Set.Icc ((1 / 3 + o n) * ↑n) ((2 / 3 + o' n) * ↑n) All goals completed! 🐙

Let $h(n)$ be the maximal $k$ such that there exist integers $1 \le a_1 \leq \dotsc \leq a_k \le n$ such that all sums of the shape $\sum_{u \le i \le v} a_i$ are distinct.

noncomputable def h (n : ℕ) : ℕ := sSup {k : ℕ | ∃ a : Fin k → ℤ, Set.range a ⊆ Set.Icc 1 n ∧ Monotone a ∧ HasDistinctSums a}

Let $h(n)$ be the maximal $k$ such that there exist integers $1 \le a_1 \leq \dotsc \leq a_k \le n$ such that all sums of the shape $\sum_{u \le i \le v} a_i$ are distinct. Is $h(n)=o(n)$?

@[category research open, AMS 11] theorem erdos_357.variants.monotone.parts.i : (fun n ↦ (h n : ℝ)) =o[atTop] (fun n ↦ (n : ℝ)) := ⊢ (fun n ↦ ↑(h n)) =o[atTop] fun n ↦ ↑n All goals completed! 🐙def erdos_357.variants.monotone.parts.ii.bigO_version.answer : ℕ → ℝ := sorry

Let $h(n)$ be the maximal $k$ such that there exist integers $1 \le a_1 \leq \dotsc \leq a_k \le n$ such that all sums of the shape $\sum_{u \le i \le v} a_i$ are distinct. How does $h(n)$ grow? Can we find a (good) explicit function $g$ such that $g = O(h)$ ?

@[category research open, question value, AMS 11] theorem erdos_357.variants.monotone.parts.ii.bigO_version : erdos_357.variants.monotone.parts.ii.bigO_version.answer =O[atTop] (fun n ↦ (h n : ℝ)) := ⊢ bigO_version.answer =O[atTop] fun n ↦ ↑(h n) All goals completed! 🐙def erdos_357.variants.monotone.parts.ii.bigO_version_symm.answer : ℕ → ℝ := sorry

Let $h(n)$ be the maximal $k$ such that there exist integers $1 \le a_1 \leq \dotsc \leq a_k \le n$ such that all sums of the shape $\sum_{u \le i \le v} a_i$ are distinct. How does $h(n)$ grow? Can we find a (good) explicit function $g$ such that $h = O(g)$ ?

@[category research open, question value, AMS 11] theorem erdos_357.variants.monotone.parts.ii.bigO_version_symm : (fun n ↦ (h n : ℝ)) =O[atTop] erdos_357.variants.monotone.parts.ii.bigO_version_symm.answer := ⊢ (fun n ↦ ↑(h n)) =O[atTop] bigO_version_symm.answer All goals completed! 🐙def erdos_357.variants.monotone.parts.ii.bigTheta_version.answer : ℕ → ℝ := sorry

Let $h(n)$ be the maximal $k$ such that there exist integers $1 \le a_1 \leq \dotsc \leq a_k \le n$ such that all sums of the shape $\sum_{u \le i \le v} a_i$ are distinct. How does $h(n)$ grow? Can we find a (good) explicit function $g$ such that $h = \Theta(g)$ ?

@[category research open, question value, AMS 11] theorem erdos_357.variants.monotone.parts.ii.bigTheta_version : (fun n ↦ (h n : ℝ)) =Θ[atTop] erdos_357.variants.monotone.parts.ii.bigTheta_version.answer := ⊢ (fun n ↦ ↑(h n)) =Θ[atTop] bigTheta_version.answer All goals completed! 🐙def erdos_357.variants.monotone.parts.ii.littleO_version.answer : ℕ → ℝ := sorry

Let $h(n)$ be the maximal $k$ such that there exist integers $1 \le a_1 \leq \dotsc \leq a_k \le n$ such that all sums of the shape $\sum_{u \le i \le v} a_i$ are distinct. How does $h(n)$ grow? Can we find a (good) explicit function $g$ such that $g = o(h)$ ?

@[category research open, question value, AMS 11] theorem erdos_357.variants.monotone.parts.ii.littleO_version : erdos_357.variants.monotone.parts.ii.littleO_version.answer =o[atTop] (fun n ↦ (h n : ℝ)) := ⊢ littleO_version.answer =o[atTop] fun n ↦ ↑(h n) All goals completed! 🐙def erdos_357.variants.monotone.parts.ii.littleO_version_symm.answer : ℕ → ℝ := sorry

Let $h(n)$ be the maximal $k$ such that there exist integers $1 \le a_1 \leq \dotsc \leq a_k \le n$ such that all sums of the shape $\sum_{u \le i \le v} a_i$ are distinct. How does $h(n)$ grow? Can we find a (good) explicit function $g$ such that $h = o(g)$ ?

@[category research open, question value, AMS 11] theorem erdos_357.variants.monotone.parts.ii.littleO_version_symm : (fun n ↦ (h n : ℝ)) =o[atTop] erdos_357.variants.monotone.parts.ii.littleO_version_symm.answer := ⊢ (fun n ↦ ↑(h n)) =o[atTop] littleO_version_symm.answer All goals completed! 🐙-- TODO(Paul-Lez): add results from last paragraph of the page. end Erdos357