/-
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 FormalConjecturesUtilErdős Problem 540
[Er65b] Erdős, Paul,
[Er73] Erdős, P.,
[ErGr80] Erdős, P. and Graham, R.,
[Ol68] Olson, John E.,
[Ba12] Balandraud, Éric,
[HaZe96] Hamidoune, Yahya Ould and Zémor, Gilles,
[Gu04] Guy, Richard K.,
[ErHe64] Erdős, P. and Heilbronn, H.,
[Sz70] Szemerédi, E.,
namespace Erdos540A finite set has a non-empty subset whose sum is zero.
def HasZeroSubsetSum {G : Type*} [AddCommMonoid G] (A : Finset G) : Prop :=
∃ S : Finset G, S ⊆ A ∧ S.Nonempty ∧ S.sum id = 0
Is it true that if $A\subseteq \mathbb{Z}/N\mathbb{Z}$ has size $\gg N^{1/2}$ then there exists some non-empty $S\subseteq A$ such that $\sum_{n\in S}n\equiv 0\pmod{N}$?
Szemerédi proved the answer is yes, in fact for arbitrary finite abelian groups.
@[category research solved, AMS 5 11, formal_proof using lean4 at "https://github.com/plby/lean-proofs/blob/main/src/v4.29.1/ErdosProblems/Erdos540.lean"]
theorem erdos_540 : answer(True) ↔
∃ C : ℝ, 0 < C ∧
∀ (N : ℕ), 0 < N → ∀ A : Finset (ZMod N),
C * Real.sqrt N ≤ A.card →
HasZeroSubsetSum A := ⊢ True ↔ ∃ C, 0 < C ∧ ∀ (N : ℕ), 0 < N → ∀ (A : Finset (ZMod N)), C * √↑N ≤ ↑A.card → HasZeroSubsetSum A
All goals completed! 🐙
end Erdos540