AFTD Auto-Formalizing Theoretical Domains

op861_ternary_crossing_pairs_dense

theoremverified

For 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 3^(2d)/24 ordered pairs of points x,y in S whose third point −x−y lies outside S.

Statement

theorem op861_ternary_crossing_pairs_dense (d : ℕ) (hd : 0 < d)
    (S : Finset (Fin d → ZMod 3)) (hS : 2 * S.card = 3^d + 1) :
    (3^d)^2 ≤ 24 * ((S.product S).filter (fun xy => -(xy.1 + xy.2) ∉ S)).card
Source
A ternary affine triangle crossing estimate for the probabilistic tournament construction of OP-861.
Verified
18 Nov 2026
Axioms
Classical.choiceQuot.soundpropext
Built on 7
  • 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_pair_identityFor complex-valued functions f and g on a finite abelian group, the sum over additive characters of the Fourier sum of f times the…
  • 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…
  • op861_order_three_zero_sum_upperIn a finite abelian group where three times every element is zero, for every finite subset S, three times the group order times the number…
  • op861_crossing_estimate_arithmeticFor real n, k, p and t, if n is at least three, 2k=n+1, t+p=k squared, and 3nt is at most 3k cubed plus n times (nk minus k squared), then…
  • LinearOrder.toTotalPreorderEvery LinearOrder is a TotalPreorder.
  • TotalPreorderA total preorder: a preorder where ≤ is total (complete). This is weaker than LinearOrder — it does NOT require antisymmetry or…
Used by 1

The proof, explained

The proof views the ternary vector space G = (ℤ/3ℤ)^d as a finite abelian group of exponent 3 with size n = 3^d. It partitions all ordered pairs (x, y) ∈ S × S into zero-sum pairs T whose third point -(x+y) belongs to S, and crossing pairs P where -(x+y) ∉ S, so T + P = |S|^2. A Fourier-analytic bound (op861_order_three_zero_sum_upper) provides an upper bound on T in terms of n and |S|. An algebraic lemma (op861_crossing_estimate_arithmetic) then combines this bound with the density condition 2|S| = n + 1 to conclude that n^2 ≤ 24 * P.

  1. The ambient ternary vector space G = (ℤ/3ℤ)^d has cardinality 3^d

    We work classically and define G = (ℤ/3ℤ)^d. The cardinality of this function space is |ℤ/3ℤ|^d = 3^d.

    lines 7–9

      classical
      let G := (Fin d → ZMod 3)
      have hcard : Fintype.card G = 3^d := by simp [G]
  2. 3 ≤ 3^d holds for any dimension d ≥ 1

    We split on d. The case d = 0 contradicts the hypothesis d > 0 (handled by omega). For d = e + 1, we rewrite 3^(e+1) = 3^e * 3 using pow_succ, and since 3^e > 0, nonlinear arithmetic concludes 3 ≤ 3^(e+1).

    lines 10–16

    uses pow_succ

      have hthree : 3 ≤ 3^d := by
        cases d with
        | zero => omega
        | succ e =>
          have hp : 0 < (3:ℕ)^e := by positivity
          rw [pow_succ]
          nlinarith
  3. Every element t ∈ G satisfies t + t + t = 0

    By function extensionality, it suffices to check the identity coordinatewise for each coordinate i. In ℤ/3ℤ, t(i) + t(i) + t(i) = 3 * t(i). Since 3 = 0 in ℤ/3ℤ, multiplying by 0 yields 0 by zero_mul.

    lines 17–24

    uses zero_mul

      have h3 (t : G) : t+t+t = 0 := by
        funext i
        change t i + t i + t i = 0
        calc
          _ = (3 : ZMod 3) * t i := by ring
          _ = 0 := by
            have h : (3 : ZMod 3) = 0 := by decide
            rw [h, zero_mul]
  4. The pairs in S × S partition into internal pairs and crossing pairs, satisfying T + P = |S|^2 over ℕ and ℝ

    Let T count pairs (x, y) ∈ S × S with -(x+y) ∈ S, and P count pairs with -(x+y) ∉ S. Finset.card_filter_add_card_filter_not partitions S × S into these two sets. Since |S × S| = |S|^2 by Finset.card_product and pow_two, we get T + P = |S|^2, which casts directly to ℝ.

    lines 25–32

    uses Finset.card_filter_add_card_filter_not, Finset.card_product, pow_two

      let T : ℕ := ((S.product S).filter (fun xy => -(xy.1+xy.2) ∈ S)).card
      let P : ℕ := ((S.product S).filter (fun xy => -(xy.1+xy.2) ∉ S)).card
      have hcountN : T + P = S.card^2 := by
        dsimp [T,P]
        simpa [Finset.card_product, pow_two] using
          (Finset.card_filter_add_card_filter_not (s := S.product S)
            (fun xy => -(xy.1+xy.2) ∈ S))
      have hcountR : (T:ℝ) + P = (S.card:ℝ)^2 := by exact_mod_cast hcountN
  5. The density condition 2|S| = |G| + 1 and the bound 3 ≤ |G| hold over ℝ

    Substituting |G| = 3^d, the theorem assumption 2|S| = 3^d + 1 and the inequality 3 ≤ 3^d are cast from ℕ to ℝ.

    lines 33–36

      have hk : 2 * (S.card:ℝ) = (Fintype.card G:ℝ) + 1 := by
        rw [hcard]
        exact_mod_cast hS
      have hn : 3 ≤ (Fintype.card G : ℝ) := by rw [hcard]; exact_mod_cast hthree
  6. The Fourier upper bound 3|G|T ≤ 3|S|^3 + |G|(|G||S| - |S|^2) holds

    Applying op861_order_three_zero_sum_upper to the elementary abelian group G (which has exponent 3) and the subset S provides the upper bound on the number of zero-sum triples T.

    lines 37–40

    uses op861_order_three_zero_sum_upper

      have hfourier : 3 * (Fintype.card G : ℝ) * (T:ℝ) ≤
          3 * (S.card:ℝ)^3 + (Fintype.card G:ℝ) *
            ((Fintype.card G:ℝ)*(S.card:ℝ) - (S.card:ℝ)^2) := by
        simpa [T, G] using op861_order_three_zero_sum_upper G h3 S
  7. (3^d)^2 ≤ 24 * P, completing the proof

    The algebraic lemma op861_crossing_estimate_arithmetic combines the four real relations—3 ≤ |G|, 2|S| = |G| + 1, T + P = |S|^2, and the Fourier bound on T—to deduce |G|^2 ≤ 24 * P. Replacing |G| by 3^d, unfolding P, and casting back to ℕ completes the proof.

    lines 41–45

    uses op861_crossing_estimate_arithmetic

      have hf := op861_crossing_estimate_arithmetic (Fintype.card G : ℝ)
        (S.card:ℝ) (P:ℝ) (T:ℝ) hn hk hcountR hfourier
      rw [hcard] at hf
      dsimp [P] at hf
      exact_mod_cast hf
pow_succ
For any element a in a monoid and n ∈ ℕ, a^(n+1) = a^n * a
zero_mul
In any structure with multiplication and zero, 0 * a = 0
Finset.card_filter_add_card_filter_not
For any finite set s and predicate p, the number of elements in s satisfying p plus the number satisfying ¬p equals |s|
Finset.card_product
The cardinality of the Cartesian product s × t of two finite sets is |s| * |t|
pow_two
For any element a in a monoid, a^2 = a * a
op861_order_three_zero_sum_upper
In a finite abelian group G of exponent 3, the number T of pairs (x, y) ∈ S × S such that -(x+y) ∈ S satisfies 3|G|T ≤ 3|S|^3 + |G|(|G||S| - |S|^2)
op861_crossing_estimate_arithmetic
For real numbers n, k, p, t, if 3 ≤ n, 2k = n + 1, t + p = k^2, and 3nt ≤ 3k^3 + n(nk - k^2), then n^2 ≤ 24p

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_ternary_crossing_pairs_dense (d : ℕ) (hd : 0 < d)    (S : Finset (Fin d → ZMod 3)) (hS : 2 * S.card = 3^d + 1) :    (3^d)^2 ≤ 24 * ((S.product S).filter (fun xy => -(xy.1 + xy.2) ∉ S)).card := by  classical  let G := (Fin d → ZMod 3)  have hcard : Fintype.card G = 3^d := by simp [G]  have hthree : 3 ≤ 3^d := by    cases d with    | zero => omega    | succ e =>      have hp : 0 < (3:ℕ)^e := by positivity      rw [pow_succ]      nlinarith  have h3 (t : G) : t+t+t = 0 := by    funext i    change t i + t i + t i = 0    calc      _ = (3 : ZMod 3) * t i := by ring      _ = 0 := by        have h : (3 : ZMod 3) = 0 := by decide        rw [h, zero_mul]  let T : ℕ := ((S.product S).filter (fun xy => -(xy.1+xy.2) ∈ S)).card  let P : ℕ := ((S.product S).filter (fun xy => -(xy.1+xy.2) ∉ S)).card  have hcountN : T + P = S.card^2 := by    dsimp [T,P]    simpa [Finset.card_product, pow_two] using      (Finset.card_filter_add_card_filter_not (s := S.product S)        (fun xy => -(xy.1+xy.2) ∈ S))  have hcountR : (T:ℝ) + P = (S.card:ℝ)^2 := by exact_mod_cast hcountN  have hk : 2 * (S.card:ℝ) = (Fintype.card G:ℝ) + 1 := by    rw [hcard]    exact_mod_cast hS  have hn : 3 ≤ (Fintype.card G : ℝ) := by rw [hcard]; exact_mod_cast hthree  have hfourier : 3 * (Fintype.card G : ℝ) * (T:ℝ) ≤      3 * (S.card:ℝ)^3 + (Fintype.card G:ℝ) *        ((Fintype.card G:ℝ)*(S.card:ℝ) - (S.card:ℝ)^2) := by    simpa [T, G] using op861_order_three_zero_sum_upper G h3 S  have hf := op861_crossing_estimate_arithmetic (Fintype.card G : ℝ)    (S.card:ℝ) (P:ℝ) (T:ℝ) hn hk hcountR hfourier  rw [hcard] at hf  dsimp [P] at hf  exact_mod_cast hf
See it in the graphDiscuss this resultChallenge it