AFTD Auto-Formalizing Theoretical Domains

odd_groups_single_non_block_component_count

theoremverified

For pairwise-disjoint odd finite groups indexed by a finite set, if all groups except one lie inside B, the number whose intersection with B has odd size is the number of groups minus one, plus one precisely when the union outside B has even size.

Statement

theorem odd_groups_single_non_block_component_count
    {ι V : Type*} [DecidableEq ι] [DecidableEq V]
    (I : Finset ι) (T : ι → Finset V) (B : Finset V) (j : ι)
    (hj : j ∈ I)
    (hdis : ∀ i ∈ I, ∀ l ∈ I, i ≠ l → Disjoint (T i) (T l))
    (hodd : ∀ i ∈ I, Odd (T i).card)
    (hother : ∀ i ∈ I, i ≠ j → T i ⊆ B) :
    let R := I.biUnion T;
    (I.filter (fun i => Odd ((T i) ∩ B).card)).card + 1 =
      I.card + (if Even (R \ B).card then 1 else 0)
Source
OP-1957: uniform odd-component barrier count compression.
Verified
27 Nov 2026
Axioms
Classical.choiceQuot.soundpropext
Used by 2

The proof, explained

Every group T_i with i ≠ j is entirely contained in B, so its intersection with B has odd size, and the complement of B in the union R reduces to T_j \ B. Because |T_j| is odd, |T_j ∩ B| is odd if and only if |T_j \ B| is even. A case split on the parity of |T_j ∩ B| finishes the proof: if it is odd, all |I| groups qualify and |R \ B| is even, giving |I| + 1 = |I| + 1; if not, exactly |I| - 1 groups qualify and |R \ B| is odd, giving (|I| - 1) + 1 = |I| + 0.

  1. The elements of the union R = ⋃_{i ∈ I} T_i that lie outside B come exclusively from T_j, so R \ B = T_j \ B.

    Any element v ∈ R \ B belongs to T_i for some i ∈ I and satisfies v ∉ B. For every i ≠ j, the hypothesis T_i ⊆ B guarantees that all elements of T_i lie inside B, which would contradict v ∉ B; hence i must equal j, showing R \ B ⊆ T_j \ B. The reverse inclusion holds immediately because j ∈ I.

    lines 13–24

    uses Finset.mem_sdiff, Finset.mem_biUnion, False.elim

      classical
      dsimp only
      have hRdiff : I.biUnion T \ B = T j \ B := by
        ext v
        simp only [Finset.mem_sdiff,Finset.mem_biUnion]
        constructor
        · rintro ⟨⟨i,hi,hvi⟩,hvB⟩
          by_cases hij : i=j
          · subst i; exact ⟨hvi,hvB⟩
          · exact False.elim (hvB (hother i hi hij hvi))
        · rintro ⟨hv,hvB⟩
          exact ⟨⟨j,hj,hv⟩,hvB⟩
  2. The intersection T_j ∩ B has odd cardinality if and only if T_j \ B has even cardinality.

    Because T_j partitions into T_j ∩ B and T_j \ B, their cardinalities satisfy |T_j ∩ B| + |T_j \ B| = |T_j|. By assumption, |T_j| is odd. A sum of two natural numbers is odd if and only if one summand is odd and the other is even, which gives the equivalence.

    lines 25–42

    uses Finset.card_inter_add_card_sdiff, Nat.even_or_odd

      have hparity : Odd ((T j) ∩ B).card ↔ Even ((T j) \ B).card := by
        have hcard := Finset.card_inter_add_card_sdiff (T j) B
        have ho := hodd j hj
        constructor
        · intro ha
          rcases Nat.even_or_odd ((T j) \ B).card with hb | hb
          · exact hb
          · obtain ⟨a,ha⟩ := ha
            obtain ⟨b,hb⟩ := hb
            obtain ⟨d,hd⟩ := ho
            omega
        · intro hb
          rcases Nat.even_or_odd ((T j) ∩ B).card with ha | ha
          · obtain ⟨a,ha⟩ := ha
            obtain ⟨b,hb⟩ := hb
            obtain ⟨d,hd⟩ := ho
            omega
          · exact ha
  3. For every index i ∈ I with i ≠ j, the intersection T_i ∩ B has odd cardinality.

    When i ≠ j, the hypothesis gives T_i ⊆ B, which implies T_i ∩ B = T_i. Since |T_i| is odd by assumption, |T_i ∩ B| is odd as well.

    lines 43–46

    uses Finset.inter_eq_left.mpr

      have hotherodd : ∀ i ∈ I, i ≠ j → Odd ((T i) ∩ B).card := by
        intro i hi hij
        rw [Finset.inter_eq_left.mpr (hother i hi hij)]
        exact hodd i hi
  4. The identity holds in the case where |T_j ∩ B| is odd.

    In this case, |T_i ∩ B| is odd for every i ∈ I (holding for j by the case assumption and for all other indices by the previous step). Thus the filtered set of such indices is all of I, and the left-hand side is |I| + 1. By the parity equivalence, |T_j \ B| is even, so |R \ B| is even; the conditional term on the right-hand side evaluates to 1, giving |I| + 1 as well.

    lines 47–55

    uses Finset.filter_eq_self.mpr

      by_cases hjodd : Odd ((T j) ∩ B).card
      · have hf : I.filter (fun i => Odd ((T i) ∩ B).card) = I := by
          apply Finset.filter_eq_self.mpr
          intro i hi
          by_cases hij : i=j
          · simpa [hij] using hjodd
          · exact hotherodd i hi hij
        rw [hf,hRdiff]
        simp [hparity.mp hjodd]
  5. The identity holds in the case where |T_j ∩ B| is not odd.

    Here, j is the unique index in I whose group does not intersect B with odd size, so the filtered set equals I \ {j}. Its cardinality is |I| - 1, making the left-hand side (|I| - 1) + 1 = |I|. By the parity equivalence, |R \ B| = |T_j \ B| cannot be even, so the conditional term evaluates to 0, leaving |I| on the right-hand side.

    lines 56–67

    uses Finset.mem_filter, Finset.mem_erase, Finset.card_erase_add_one

      · have hf : I.filter (fun i => Odd ((T i) ∩ B).card) = I.erase j := by
          ext i
          simp only [Finset.mem_filter,Finset.mem_erase]
          constructor
          · rintro ⟨hi,ho⟩
            refine ⟨?_,hi⟩
            intro hij; subst i; exact hjodd ho
          · rintro ⟨hij,hi⟩
            exact ⟨hi,hotherodd i hi hij⟩
        have hneven : ¬ Even ((T j) \ B).card := fun h => hjodd (hparity.mpr h)
        rw [hf,hRdiff]
        simp [hneven,Finset.card_erase_add_one hj]
Finset.mem_sdiff
An element belongs to the difference s \ t if and only if it belongs to s and not to t.
Finset.mem_biUnion
An element belongs to the union of a family of sets ⋃_{a ∈ s} t(a) if and only if it belongs to t(a) for some a ∈ s.
False.elim
From a contradiction (False), any conclusion follows.
Finset.card_inter_add_card_sdiff
For any finite sets s and t, |s ∩ t| + |s \ t| = |s|.
Nat.even_or_odd
Every natural number is either even or odd.
Finset.inter_eq_left.mpr
If s ⊆ t, then s ∩ t = s.
Finset.filter_eq_self.mpr
Filtering a finite set by a predicate that holds for all of its elements returns the set itself.
Finset.mem_filter
An element belongs to {x ∈ s | p x} if and only if it belongs to s and satisfies p.
Finset.mem_erase
An element belongs to s.erase b if and only if it is distinct from b and belongs to s.
Finset.card_erase_add_one
For any element a ∈ s, |s \ {a}| + 1 = |s|.

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

set_option maxHeartbeats 1000000theorem odd_groups_single_non_block_component_count    {ι V : Type*} [DecidableEq ι] [DecidableEq V]    (I : Finset ι) (T : ι → Finset V) (B : Finset V) (j : ι)    (hj : j ∈ I)    (hdis : ∀ i ∈ I, ∀ l ∈ I, i ≠ l → Disjoint (T i) (T l))    (hodd : ∀ i ∈ I, Odd (T i).card)    (hother : ∀ i ∈ I, i ≠ j → T i ⊆ B) :    let R := I.biUnion T;    (I.filter (fun i => Odd ((T i) ∩ B).card)).card + 1 =      I.card + (if Even (R \ B).card then 1 else 0) := by  classical  dsimp only  have hRdiff : I.biUnion T \ B = T j \ B := by    ext v    simp only [Finset.mem_sdiff,Finset.mem_biUnion]    constructor    · rintro ⟨⟨i,hi,hvi⟩,hvB⟩      by_cases hij : i=j      · subst i; exact ⟨hvi,hvB⟩      · exact False.elim (hvB (hother i hi hij hvi))    · rintro ⟨hv,hvB⟩      exact ⟨⟨j,hj,hv⟩,hvB⟩  have hparity : Odd ((T j) ∩ B).card ↔ Even ((T j) \ B).card := by    have hcard := Finset.card_inter_add_card_sdiff (T j) B    have ho := hodd j hj    constructor    · intro ha      rcases Nat.even_or_odd ((T j) \ B).card with hb | hb      · exact hb      · obtain ⟨a,ha⟩ := ha        obtain ⟨b,hb⟩ := hb        obtain ⟨d,hd⟩ := ho        omega    · intro hb      rcases Nat.even_or_odd ((T j) ∩ B).card with ha | ha      · obtain ⟨a,ha⟩ := ha        obtain ⟨b,hb⟩ := hb        obtain ⟨d,hd⟩ := ho        omega      · exact ha  have hotherodd : ∀ i ∈ I, i ≠ j → Odd ((T i) ∩ B).card := by    intro i hi hij    rw [Finset.inter_eq_left.mpr (hother i hi hij)]    exact hodd i hi  by_cases hjodd : Odd ((T j) ∩ B).card  · have hf : I.filter (fun i => Odd ((T i) ∩ B).card) = I := by      apply Finset.filter_eq_self.mpr      intro i hi      by_cases hij : i=j      · simpa [hij] using hjodd      · exact hotherodd i hi hij    rw [hf,hRdiff]    simp [hparity.mp hjodd]  · have hf : I.filter (fun i => Odd ((T i) ∩ B).card) = I.erase j := by      ext i      simp only [Finset.mem_filter,Finset.mem_erase]      constructor      · rintro ⟨hi,ho⟩        refine ⟨?_,hi⟩        intro hij; subst i; exact hjodd ho      · rintro ⟨hij,hi⟩        exact ⟨hi,hotherodd i hi hij⟩    have hneven : ¬ Even ((T j) \ B).card := fun h => hjodd (hparity.mpr h)    rw [hf,hRdiff]    simp [hneven,Finset.card_erase_add_one hj]
See it in the graphDiscuss this resultChallenge it