AFTD Auto-Formalizing Theoretical Domains

op861_order_three_zero_sum_upper

theoremverified

In a finite abelian group where three times every element is zero, for every finite subset S, three times the group order times the number of ordered pairs x,y in S with −x−y in S is at most three times the cube of the size of S plus the group order times (the group order times the size of S minus its square).

Statement

theorem op861_order_three_zero_sum_upper (G : Type*) [AddCommGroup G]
    [Fintype G] [DecidableEq G] (h3 : ∀ t : G, t+t+t = 0) (S : Finset G) :
    3 * (Fintype.card G : ℝ) *
      (((S.product S).filter (fun xy => -(xy.1+xy.2) ∈ S)).card : ℝ) ≤
      3 * (S.card : ℝ)^3 + (Fintype.card G : ℝ) *
        ((Fintype.card G : ℝ) * S.card - (S.card : ℝ)^2)
Source
A Fourier upper bound on zero-sum triples, used for op861_ternary_crossing_pairs_dense.
Verified
18 Nov 2026
Axioms
Classical.choiceQuot.soundpropext
Built on 4
  • op861_fourier_cube_identityFor a complex-valued function on a finite abelian group, the sum over all additive characters of the cube of its Fourier sum equals the…
  • op861_fourier_indicator_norm_identityFor a finite abelian group and a finite subset, the sum over additive characters of the squared norm of the character sum over the subset…
  • op861_cubic_norm_sum_boundFor a finite family of complex numbers whose norms satisfy three times each norm at most n, three times the norm of the sum of their cubes…
  • op861_order_three_character_sum_boundIn a finite abelian group in which three times every element is zero, every nontrivial complex additive character has a sum of norm at…
Used by 1
  • op861_ternary_crossing_pairs_denseFor every positive d and every subset S of the d-dimensional ternary vector space with twice its size equal to 3^d+1, there are at least…

The proof, explained

The proof uses Fourier analysis on the finite abelian group G, which is an elementary abelian 3-group. The count T of zero-sum triples in S is expressed through the cubic Fourier identity as |G| T = |S|³ + ∑_{χ ≠ 0} F(χ)³. The 3-torsion condition ensures the uniform character bound 3 ‖F(χ)‖ ≤ |G| for all non-trivial χ, which bounds the cubic sum in terms of the L²-energy ∑_{χ ≠ 0} ‖F(χ)‖² = |G||S| - |S|² computed via Parseval's identity. Bounding the real part by the complex norm and rearranging yields the theorem.

  1. Define the indicator function, character sums, non-trivial characters, and zero-sum pair count, establishing their basic properties.

    We define the indicator function f = 1_S, the character sum F(χ) = ∑_{x ∈ S} χ(x), the set U of non-trivial characters (the universal finset minus 0), and T as the count of pairs (x, y) ∈ S × S such that -(x+y) ∈ S. We verify that ∑_{x ∈ G} f(x) χ(x) = F(χ), that the trivial character gives F(0) = |S|, and that every character χ ∈ U is non-zero.

    lines 10–19

    uses Finset.mem_erase.mp

      classical
      let f : G → ℂ := fun x => if x ∈ S then 1 else 0
      let F : AddChar G ℂ → ℂ := fun χ => ∑ x ∈ S, χ x
      let U : Finset (AddChar G ℂ) := Finset.univ.erase 0
      let T : ℕ := ((S.product S).filter (fun xy => -(xy.1+xy.2) ∈ S)).card
      have hF (χ : AddChar G ℂ) : (∑ x : G, f x * χ x) = F χ := by
        simp [f, F]
      have hF0 : F 0 = (S.card : ℂ) := by simp [F]
      have hne (χ : AddChar G ℂ) (hχ : χ ∈ U) : χ ≠ 0 := by
        exact (Finset.mem_erase.mp hχ).1
  2. The sum of squared norms of non-trivial character sums is ∑_{χ ∈ U} ‖F(χ)‖² = |G| |S| - |S|².

    By Parseval's identity for the indicator function (op861_fourier_indicator_norm_identity), the total sum of squared norms over all characters is ∑_χ ‖F(χ)‖² = |G| |S|. Separating the trivial character χ = 0, where F(0) = |S| and thus ‖F(0)‖² = |S|², linear arithmetic yields ∑_{χ ∈ U} ‖F(χ)‖² = |G| |S| - |S|².

    lines 20–30

    uses op861_fourier_indicator_norm_identity, Finset.add_sum_erase, Finset.mem_univ, Complex.norm_natCast

      have hnorm : (∑ χ : AddChar G ℂ, ‖F χ‖^2) =
          (Fintype.card G : ℝ) * S.card := by
        simpa [F] using op861_fourier_indicator_norm_identity G S
      have hUsq : (∑ χ ∈ U, ‖F χ‖^2) =
          (Fintype.card G : ℝ) * S.card - (S.card : ℝ)^2 := by
        have hs := Finset.add_sum_erase (Finset.univ : Finset (AddChar G ℂ))
          (fun χ => ‖F χ‖^2) (Finset.mem_univ (0 : AddChar G ℂ))
        rw [← hs] at hnorm
        simp only [hF0, Complex.norm_natCast] at hnorm
        dsimp [U]
        linarith
  3. The convolution sum ∑_{x, y ∈ G} f(x) f(y) f(-x-y) equals the zero-sum pair count T.

    Because f is the indicator function of S, the product f(x) f(y) f(-x-y) is 1 when x ∈ S, y ∈ S, and -(x+y) ∈ S, and 0 otherwise. Rewriting the double sum over G × G as a sum over the Cartesian product S × S shows that it equals the cardinality T of the filtered product set.

    lines 31–53

    uses Finset.sum_congr, Finset.natCast_card_filter, Finset.sum_filter, Finset.sum_boole, and_comm, Finset.sum_product, sub_eq_add_neg, neg_add_rev, add_comm

      have htri : (∑ x : G, ∑ y : G, f x * f y * f (-x-y)) = (T : ℂ) := by
        calc
          _ = ∑ x : G, if x ∈ S then ∑ y ∈ S, f (-x-y) else 0 := by
            apply Finset.sum_congr rfl
            intro x hx
            by_cases hmem : x ∈ S
            · simp [f, hmem]
              rw [Finset.natCast_card_filter]
              rw [← Finset.sum_filter]
              simp [Finset.sum_boole]
              congr 1
              ext y
              simp [and_comm]
            · simp [f, hmem]
          _ = ∑ x ∈ S, ∑ y ∈ S, f (-x-y) := by simp
          _ = (T : ℂ) := by
            dsimp [T]
            rw [Finset.natCast_card_filter, Finset.sum_product]
            apply Finset.sum_congr rfl
            intro x hx
            apply Finset.sum_congr rfl
            intro y hy
            simp [f, sub_eq_add_neg, neg_add_rev, add_comm]
  4. |S|³ + ∑_{χ ∈ U} F(χ)³ = |G| T.

    The cubic Fourier identity (op861_fourier_cube_identity) relates the sum of cubes of Fourier coefficients ∑_χ F(χ)³ to |G| ∑_{x, y} f(x) f(y) f(-x-y) = |G| T. Isolating the trivial character χ = 0 (which contributes F(0)³ = |S|³) leaves the sum over U, establishing |S|³ + ∑_{χ ∈ U} F(χ)³ = |G| T.

    lines 54–62

    uses op861_fourier_cube_identity, Finset.add_sum_erase, Finset.mem_univ

      have hCube : (S.card : ℂ)^3 + ∑ χ ∈ U, (F χ)^3 =
          (Fintype.card G : ℂ) * T := by
        have hc := op861_fourier_cube_identity G f
        simp_rw [hF] at hc
        rw [htri] at hc
        have hs := Finset.add_sum_erase (Finset.univ : Finset (AddChar G ℂ))
          (fun χ => (F χ)^3) (Finset.mem_univ (0 : AddChar G ℂ))
        rw [← hs, hF0] at hc
        simpa [U] using hc
  5. The real part of the non-trivial cubic character sum is Re(∑_{χ ∈ U} F(χ)³) = |G| T - |S|³.

    Taking the real part of both sides of |S|³ + ∑_{χ ∈ U} F(χ)³ = |G| T, and noting that |S|³ and |G| T are real numbers whose imaginary parts vanish, linear arithmetic gives Re(∑_{χ ∈ U} F(χ)³) = |G| T - |S|³.

    lines 63–71

    uses Complex.ofReal_pow, Complex.ofReal_re, congrArg, Complex.add_re, Complex.mul_re, Complex.natCast_re, Complex.natCast_im, zero_mul, sub_zero

      have hRe : (∑ χ ∈ U, (F χ)^3).re =
          (Fintype.card G : ℝ) * T - (S.card : ℝ)^3 := by
        have hsimp : ((S.card : ℂ)^3).re = (S.card : ℝ)^3 := by
          change (((S.card : ℝ) : ℂ)^3).re = (S.card : ℝ)^3
          rw [← Complex.ofReal_pow, Complex.ofReal_re]
        have hc := congrArg Complex.re hCube
        simp only [Complex.add_re, hsimp, Complex.mul_re, Complex.natCast_re,
          Complex.natCast_im, zero_mul, sub_zero] at hc
        linarith
  6. 3 ‖∑_{χ ∈ U} F(χ)³‖ ≤ |G| ∑_{χ ∈ U} ‖F(χ)‖².

    Since 3t = 0 for every t ∈ G, each non-trivial character χ ∈ U satisfies 3 ‖F(χ)‖ ≤ |G| by op861_order_three_character_sum_bound. Applying the general bound op861_cubic_norm_sum_bound with n = |G| then bounds 3 times the norm of the cubic sum by |G| times the sum of squared norms.

    lines 72–76

    uses op861_cubic_norm_sum_bound, op861_order_three_character_sum_bound

      have hbound : 3 * ‖∑ χ ∈ U, (F χ)^3‖ ≤
          (Fintype.card G : ℝ) * ∑ χ ∈ U, ‖F χ‖^2 := by
        apply op861_cubic_norm_sum_bound (AddChar G ℂ) U F (Fintype.card G : ℝ)
        intro χ hχ
        simpa [F] using op861_order_three_character_sum_bound G h3 χ (hne χ hχ) S
  7. 3 |G| T ≤ 3 |S|³ + |G| (|G| |S| - |S|²).

    Using Re(z) ≤ ‖z‖ for the cubic sum, we have 3 Re(∑_{χ ∈ U} F(χ)³) ≤ 3 ‖∑_{χ ∈ U} F(χ)³‖. Substituting the formula for the real part on the left and the cubic norm bound on the right gives 3 (|G| T - |S|³) ≤ |G| (|G| |S| - |S|²), which rearranges directly to the desired inequality.

    lines 77–83

    uses Complex.re_le_norm

      have hR := Complex.re_le_norm (∑ χ ∈ U, (F χ)^3)
      rw [hRe] at hR
      rw [hUsq] at hbound
      change 3 * (Fintype.card G : ℝ) * (T : ℝ) ≤
          3 * (S.card : ℝ)^3 + (Fintype.card G : ℝ) *
            ((Fintype.card G : ℝ) * S.card - (S.card : ℝ)^2)
      nlinarith
Finset.mem_erase.mp
An element of s \ {a} is not equal to a and belongs to s.
op861_fourier_indicator_norm_identity
For any finite subset S of G, the sum over all characters χ of ‖∑_{x ∈ S} χ(x)‖² equals |G| |S| (Parseval's identity for the indicator function).
Finset.add_sum_erase
For any element a ∈ s, the sum of f over s equals f(a) plus the sum of f over s \ {a}.
Finset.mem_univ
Every element of a finite type belongs to the universal finset.
Complex.norm_natCast
The complex norm of a natural number cast to ℂ is itself as a real number.
Finset.sum_congr
Two sums over finsets are equal if their index sets are equal and their summands agree on all elements.
Finset.natCast_card_filter
The cardinality of a filtered subset {x ∈ s | p(x)} equals the sum over s of the indicator of p.
Finset.sum_filter
The sum of f over {a ∈ s | p(a)} equals the sum over all a ∈ s of f(a) when p(a) holds and 0 otherwise.
Finset.sum_boole
The sum over s of the indicator of p equals the cardinality of {x ∈ s | p(x)}.
and_comm
Conjunction is commutative: a ∧ b ↔ b ∧ a.
Finset.sum_product
A sum over a Cartesian product s × t equals the iterated sum over s and t.
sub_eq_add_neg
Subtraction is addition of the negation: a - b = a + (-b).
neg_add_rev
The negation of a sum is the sum of the negations in reverse order: -(a + b) = -b + -a.
add_comm
Addition is commutative: a + b = b + a.
op861_fourier_cube_identity
The sum over all characters χ of the cubes of the Fourier coefficients (∑_x f(x) χ(x))³ equals |G| ∑_{x, y} f(x) f(y) f(-x-y).
Complex.ofReal_pow
Casting a power of a real number to ℂ equals the power of the cast.
Complex.ofReal_re
The real part of a real number embedded in ℂ is the number itself.
congrArg
Applying a function to equal arguments yields equal values.
Complex.add_re
The real part of a sum of complex numbers is the sum of their real parts.
Complex.mul_re
The real part of a product of complex numbers is z.re * w.re - z.im * w.im.
Complex.natCast_re
The real part of a natural number cast to ℂ is the natural number cast to ℝ.
Complex.natCast_im
The imaginary part of a natural number cast to ℂ is zero.
zero_mul
Zero times any element is zero.
sub_zero
Subtracting zero leaves an element unchanged: a - 0 = a.
op861_cubic_norm_sum_bound
If every term in a finite set satisfies 3 ‖F(i)‖ ≤ n, then 3 ‖∑_{i ∈ s} F(i)³‖ ≤ n ∑_{i ∈ s} ‖F(i)‖².
op861_order_three_character_sum_bound
In an abelian group where 3t = 0 for all t, every non-trivial character χ ≠ 0 satisfies 3 ‖∑_{x ∈ S} χ(x)‖ ≤ |G|.
Complex.re_le_norm
The real part of any complex number is at most its complex norm: z.re ≤ ‖z‖.

Written by a model (gemini-3.8-flash) from the Lean proof and the goal states Lean reported at each step. Lean verified the proof; this explanation is a reading aid and is not itself machine-checked.

Lean source view module on GitHub

open scoped BigOperatorsset_option maxHeartbeats 1000000theorem op861_order_three_zero_sum_upper (G : Type*) [AddCommGroup G]    [Fintype G] [DecidableEq G] (h3 : ∀ t : G, t+t+t = 0) (S : Finset G) :    3 * (Fintype.card G : ℝ) *      (((S.product S).filter (fun xy => -(xy.1+xy.2) ∈ S)).card : ℝ) ≤      3 * (S.card : ℝ)^3 + (Fintype.card G : ℝ) *        ((Fintype.card G : ℝ) * S.card - (S.card : ℝ)^2) := by  classical  let f : G → ℂ := fun x => if x ∈ S then 1 else 0  let F : AddChar G ℂ → ℂ := fun χ => ∑ x ∈ S, χ x  let U : Finset (AddChar G ℂ) := Finset.univ.erase 0  let T : ℕ := ((S.product S).filter (fun xy => -(xy.1+xy.2) ∈ S)).card  have hF (χ : AddChar G ℂ) : (∑ x : G, f x * χ x) = F χ := by    simp [f, F]  have hF0 : F 0 = (S.card : ℂ) := by simp [F]  have hne (χ : AddChar G ℂ) (hχ : χ ∈ U) : χ ≠ 0 := by    exact (Finset.mem_erase.mp hχ).1  have hnorm : (∑ χ : AddChar G ℂ, ‖F χ‖^2) =      (Fintype.card G : ℝ) * S.card := by    simpa [F] using op861_fourier_indicator_norm_identity G S  have hUsq : (∑ χ ∈ U, ‖F χ‖^2) =      (Fintype.card G : ℝ) * S.card - (S.card : ℝ)^2 := by    have hs := Finset.add_sum_erase (Finset.univ : Finset (AddChar G ℂ))      (fun χ => ‖F χ‖^2) (Finset.mem_univ (0 : AddChar G ℂ))    rw [← hs] at hnorm    simp only [hF0, Complex.norm_natCast] at hnorm    dsimp [U]    linarith  have htri : (∑ x : G, ∑ y : G, f x * f y * f (-x-y)) = (T : ℂ) := by    calc      _ = ∑ x : G, if x ∈ S then ∑ y ∈ S, f (-x-y) else 0 := by        apply Finset.sum_congr rfl        intro x hx        by_cases hmem : x ∈ S        · simp [f, hmem]          rw [Finset.natCast_card_filter]          rw [← Finset.sum_filter]          simp [Finset.sum_boole]          congr 1          ext y          simp [and_comm]        · simp [f, hmem]      _ = ∑ x ∈ S, ∑ y ∈ S, f (-x-y) := by simp      _ = (T : ℂ) := by        dsimp [T]        rw [Finset.natCast_card_filter, Finset.sum_product]        apply Finset.sum_congr rfl        intro x hx        apply Finset.sum_congr rfl        intro y hy        simp [f, sub_eq_add_neg, neg_add_rev, add_comm]  have hCube : (S.card : ℂ)^3 + ∑ χ ∈ U, (F χ)^3 =      (Fintype.card G : ℂ) * T := by    have hc := op861_fourier_cube_identity G f    simp_rw [hF] at hc    rw [htri] at hc    have hs := Finset.add_sum_erase (Finset.univ : Finset (AddChar G ℂ))      (fun χ => (F χ)^3) (Finset.mem_univ (0 : AddChar G ℂ))    rw [← hs, hF0] at hc    simpa [U] using hc  have hRe : (∑ χ ∈ U, (F χ)^3).re =      (Fintype.card G : ℝ) * T - (S.card : ℝ)^3 := by    have hsimp : ((S.card : ℂ)^3).re = (S.card : ℝ)^3 := by      change (((S.card : ℝ) : ℂ)^3).re = (S.card : ℝ)^3      rw [← Complex.ofReal_pow, Complex.ofReal_re]    have hc := congrArg Complex.re hCube    simp only [Complex.add_re, hsimp, Complex.mul_re, Complex.natCast_re,      Complex.natCast_im, zero_mul, sub_zero] at hc    linarith  have hbound : 3 * ‖∑ χ ∈ U, (F χ)^3‖ ≤      (Fintype.card G : ℝ) * ∑ χ ∈ U, ‖F χ‖^2 := by    apply op861_cubic_norm_sum_bound (AddChar G ℂ) U F (Fintype.card G : ℝ)    intro χ hχ    simpa [F] using op861_order_three_character_sum_bound G h3 χ (hne χ hχ) S  have hR := Complex.re_le_norm (∑ χ ∈ U, (F χ)^3)  rw [hRe] at hR  rw [hUsq] at hbound  change 3 * (Fintype.card G : ℝ) * (T : ℝ) ≤      3 * (S.card : ℝ)^3 + (Fintype.card G : ℝ) *        ((Fintype.card G : ℝ) * S.card - (S.card : ℝ)^2)  nlinarith
See it in the graphDiscuss this resultChallenge it