AFTD Auto-Formalizing Theoretical Domains

op861_crossing_ordered_pairs_double

theoremverified

In a linearly ordered abelian group of exponent three, the number of ordered pairs in a finite subset whose zero-sum third point lies outside the subset is twice the number of such pairs in increasing order.

Statement

theorem op861_crossing_ordered_pairs_double (α : Type*) [AddCommGroup α]
    [DecidableEq α] [LinearOrder α] (h3 : ∀ t : α, t+t+t = 0) (S : Finset α) :
    ((S.product S).filter (fun xy => -(xy.1+xy.2) ∉ S)).card =
      2 * ((S.product S).filter (fun xy => xy.1 < xy.2 ∧ -(xy.1+xy.2) ∉ S)).card
Source
Converts op861_ternary_crossing_pairs_dense to a lower bound on crossing-triangle graph edges.
Verified
18 Nov 2026
Axioms
Classical.choiceQuot.soundpropext
Built on 2
  • 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

We partition the set E of pairs (x, y) ∈ S × S whose zero-sum third point -(x + y) lies outside S into pairs with x < y (set A) and pairs with y < x (set B). Crucially, no pair in E has equal coordinates: if x = y, the exponent-three relation x + x + x = 0 forces -(x + x) = x ∈ S, which contradicts the defining condition of E. Coordinate swapping gives a bijection between A and B, so |A| = |B|, and since A and B form a disjoint partition of E, |E| = |A| + |B| = 2|A|.

  1. Define the subsets A, B, and E of S × S and restate the theorem as |E| = 2|A|.

    We define A as the set of pairs (x, y) ∈ S × S with x < y and -(x + y) ∉ S, B as the set of pairs with y < x and -(x + y) ∉ S, and E as the set of all pairs with -(x + y) ∉ S. The goal is to prove that |E| = 2|A|.

    lines 5–8

      let A := (S.product S).filter (fun xy => xy.1 < xy.2 ∧ -(xy.1+xy.2) ∉ S)
      let B := (S.product S).filter (fun xy => xy.2 < xy.1 ∧ -(xy.1+xy.2) ∉ S)
      let E := (S.product S).filter (fun xy => -(xy.1+xy.2) ∉ S)
      change E.card = 2 * A.card
  2. The sets A and B have the same cardinality.

    We establish a bijection between A and B via coordinate swapping (x, y) ↦ (y, x) using Finset.card_bij'. If (x, y) ∈ A, then x < y and -(x + y) ∉ S; commutativity of addition (add_comm) ensures -(y + x) = -(x + y) ∉ S, so the swapped pair belongs to B. The reverse direction is identical, and swapping coordinates twice is the identity on pairs.

    lines 9–24

    uses Finset.card_bij', add_comm

      have hAB_card : A.card = B.card := by
        refine Finset.card_bij' (fun xy _ => Prod.swap xy) (fun yx _ => Prod.swap yx) ?_ ?_ ?_ ?_
        · intro ⟨x, y⟩ h
          simp only [A, B, Finset.mem_filter, Finset.product_eq_sprod, Finset.mem_product, Prod.swap] at h ⊢
          refine ⟨⟨h.1.2, h.1.1⟩, ?_⟩
          rw [add_comm]
          exact h.2
        · intro ⟨x, y⟩ h
          simp only [A, B, Finset.mem_filter, Finset.product_eq_sprod, Finset.mem_product, Prod.swap] at h ⊢
          refine ⟨⟨h.1.2, h.1.1⟩, ?_⟩
          rw [add_comm]
          exact h.2
        · intro ⟨x, y⟩ _
          rfl
        · intro ⟨x, y⟩ _
          rfl
  3. The sets A and B are disjoint.

    By Finset.disjoint_filter, A and B are disjoint if no pair satisfies both defining conditions. A pair in both would have x < y and y < x, which is impossible by the asymmetry of strict inequality (lt_asymm).

    lines 25–28

    uses Finset.disjoint_filter, lt_asymm

      have h_disj : Disjoint A B := by
        rw [Finset.disjoint_filter]
        intro xy _ hA hB
        exact lt_asymm hA.1 hB.1
  4. E is the union of A and B.

    Clearly every pair in A or B belongs to E. Conversely, for any (x, y) ∈ E, the elements cannot be equal: if x = y, the exponent-three identity x + x + x = 0 implies -(x + x) = x (by neg_eq_of_add_eq_zero_right), so -(x + y) = x ∈ S, contradicting the definition of E. Since x ≠ y, the linear order guarantees x < y or y < x (by lt_or_gt_of_ne), placing (x, y) in A or B.

    lines 29–44

    uses neg_eq_of_add_eq_zero_right, lt_or_gt_of_ne

      have hE_eq : E = A ∪ B := by
        ext ⟨x, y⟩
        simp only [E, A, B, Finset.mem_filter, Finset.mem_union, Finset.product_eq_sprod, Finset.mem_product]
        constructor
        · rintro ⟨⟨hx, hy⟩, hneg⟩
          have hne : x ≠ y := by
            rintro rfl
            have h_neg_two : -(x + x) = x := neg_eq_of_add_eq_zero_right (h3 x)
            rw [h_neg_two] at hneg
            exact hneg hx
          rcases lt_or_gt_of_ne hne with hlt | hgt
          · exact Or.inl ⟨⟨hx, hy⟩, hlt, hneg⟩
          · exact Or.inr ⟨⟨hx, hy⟩, hgt, hneg⟩
        · rintro (⟨hxy, _, hneg⟩ | ⟨hxy, _, hneg⟩)
          · exact ⟨hxy, hneg⟩
          · exact ⟨hxy, hneg⟩
  5. The cardinality of E is twice that of A.

    Since E = A ∪ B and A and B are disjoint, the cardinality of E is |A| + |B| (Finset.card_union_of_disjoint). Substituting |B| = |A| yields |A| + |A| = 2|A| (two_mul).

    line 45

    uses Finset.card_union_of_disjoint, two_mul

      rw [hE_eq, Finset.card_union_of_disjoint h_disj, hAB_card, two_mul]
add_comm
Addition in an abelian group is commutative: a + b = b + a.
Finset.card_bij'
Two finite sets have the same cardinality if there is a pair of maps between them that are mutual inverses on those sets.
Finset.disjoint_filter
Two filtered subsets of a finite set are disjoint if and only if no element satisfies both predicates.
Finset.card_union_of_disjoint
The cardinality of the union of two disjoint finite sets is the sum of their cardinalities.
lt_asymm
Strict inequality is asymmetric: if a < b, then b < a is false.
lt_or_gt_of_ne
In a linear order, two distinct elements satisfy a < b or b < a.
neg_eq_of_add_eq_zero_right
If a + b = 0, then -a = b.
two_mul
Multiplication by 2 is equivalent to adding an element to itself: 2 * n = n + n.

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

theorem op861_crossing_ordered_pairs_double (α : Type*) [AddCommGroup α]    [DecidableEq α] [LinearOrder α] (h3 : ∀ t : α, t+t+t = 0) (S : Finset α) :    ((S.product S).filter (fun xy => -(xy.1+xy.2) ∉ S)).card =      2 * ((S.product S).filter (fun xy => xy.1 < xy.2 ∧ -(xy.1+xy.2) ∉ S)).card := by  let A := (S.product S).filter (fun xy => xy.1 < xy.2 ∧ -(xy.1+xy.2) ∉ S)  let B := (S.product S).filter (fun xy => xy.2 < xy.1 ∧ -(xy.1+xy.2) ∉ S)  let E := (S.product S).filter (fun xy => -(xy.1+xy.2) ∉ S)  change E.card = 2 * A.card  have hAB_card : A.card = B.card := by    refine Finset.card_bij' (fun xy _ => Prod.swap xy) (fun yx _ => Prod.swap yx) ?_ ?_ ?_ ?_    · intro ⟨x, y⟩ h      simp only [A, B, Finset.mem_filter, Finset.product_eq_sprod, Finset.mem_product, Prod.swap] at h ⊢      refine ⟨⟨h.1.2, h.1.1⟩, ?_⟩      rw [add_comm]      exact h.2    · intro ⟨x, y⟩ h      simp only [A, B, Finset.mem_filter, Finset.product_eq_sprod, Finset.mem_product, Prod.swap] at h ⊢      refine ⟨⟨h.1.2, h.1.1⟩, ?_⟩      rw [add_comm]      exact h.2    · intro ⟨x, y⟩ _      rfl    · intro ⟨x, y⟩ _      rfl  have h_disj : Disjoint A B := by    rw [Finset.disjoint_filter]    intro xy _ hA hB    exact lt_asymm hA.1 hB.1  have hE_eq : E = A ∪ B := by    ext ⟨x, y⟩    simp only [E, A, B, Finset.mem_filter, Finset.mem_union, Finset.product_eq_sprod, Finset.mem_product]    constructor    · rintro ⟨⟨hx, hy⟩, hneg⟩      have hne : x ≠ y := by        rintro rfl        have h_neg_two : -(x + x) = x := neg_eq_of_add_eq_zero_right (h3 x)        rw [h_neg_two] at hneg        exact hneg hx      rcases lt_or_gt_of_ne hne with hlt | hgt      · exact Or.inl ⟨⟨hx, hy⟩, hlt, hneg⟩      · exact Or.inr ⟨⟨hx, hy⟩, hgt, hneg⟩    · rintro (⟨hxy, _, hneg⟩ | ⟨hxy, _, hneg⟩)      · exact ⟨hxy, hneg⟩      · exact ⟨hxy, hneg⟩  rw [hE_eq, Finset.card_union_of_disjoint h_disj, hAB_card, two_mul]
See it in the graphDiscuss this resultChallenge it