AFTD Auto-Formalizing Theoretical Domains

finset_card_eq_sum_four_block_inter

theoremverified

If four pairwise disjoint finite sets cover a finite type, every finite set has size equal to the sum of the sizes of its intersections with the four sets.

Statement

theorem finset_card_eq_sum_four_block_inter {V : Type*} [Fintype V] [DecidableEq V] (A B C D P : Finset V)
    (hAB : Disjoint A B) (hAC : Disjoint A C) (hAD : Disjoint A D)
    (hBC : Disjoint B C) (hBD : Disjoint B D) (hCD : Disjoint C D)
    (hcover : A ∪ B ∪ C ∪ D = Finset.univ) :
    P.card = (P ∩ A).card + (P ∩ B).card + (P ∩ C).card + (P ∩ D).card
Source
OP-1957: graph-to-count transfer for the size-five block forced-edge route (IN-1126).
Verified
22 Nov 2026
Axioms
Classical.choiceQuot.soundpropext
Built on 1
Used by 17

The proof, explained

The theorem is proved by sandwiching the size of P between two matching bounds. Because the sets A, B, C, D cover the universal set, their intersections with P cover P, giving |P| ≤ |P ∩ A| + |P ∩ B| + |P ∩ C| + |P ∩ D| by subadditivity of the cardinality of unions. Conversely, because A, B, C, D are pairwise disjoint, their intersections with P are pairwise disjoint subsets of P, which implies the reverse inequality; together the two bounds force equality.

  1. (P ∩ A) ∪ (P ∩ B) ∪ (P ∩ C) ∪ (P ∩ D) = P

    Factoring out P ∩ using the left distributivity of intersection over union (Finset.inter_union_distrib_left), the union simplifies to P ∩ (A ∪ B ∪ C ∪ D). Since A ∪ B ∪ C ∪ D covers the universal set by hypothesis (hcover), this becomes P ∩ univ, which equals P by Finset.inter_univ.

    lines 6–8

    uses Finset.inter_union_distrib_left, Finset.inter_univ

      have hP : P ∩ A ∪ P ∩ B ∪ P ∩ C ∪ P ∩ D = P := by
        rw [← Finset.inter_union_distrib_left, ← Finset.inter_union_distrib_left,
          ← Finset.inter_union_distrib_left, hcover, Finset.inter_univ]
  2. (P ∩ A).card + (P ∩ B).card + (P ∩ C).card + (P ∩ D).card ≤ P.card

    The four intersections P ∩ A, P ∩ B, P ∩ C, and P ∩ D are subsets of P by Finset.inter_subset_left. Furthermore, since P ∩ X ⊆ X by Finset.inter_subset_right and the four sets A, B, C, D are pairwise disjoint, the intersections are also pairwise disjoint (using Finset.disjoint_of_subset_left and Finset.disjoint_of_subset_right). Applying four_disjoint_subsets_card_sum_le shows that the sum of their cardinalities is at most the cardinality of P.

    lines 9–23

    uses four_disjoint_subsets_card_sum_le, Finset.inter_subset_left, Finset.disjoint_of_subset_left, Finset.inter_subset_right, Finset.disjoint_of_subset_right

      have h := four_disjoint_subsets_card_sum_le (P ∩ A) (P ∩ B) (P ∩ C) (P ∩ D) P
        Finset.inter_subset_left Finset.inter_subset_left Finset.inter_subset_left
        Finset.inter_subset_left
        (Finset.disjoint_of_subset_left Finset.inter_subset_right
          (Finset.disjoint_of_subset_right Finset.inter_subset_right hAB))
        (Finset.disjoint_of_subset_left Finset.inter_subset_right
          (Finset.disjoint_of_subset_right Finset.inter_subset_right hAC))
        (Finset.disjoint_of_subset_left Finset.inter_subset_right
          (Finset.disjoint_of_subset_right Finset.inter_subset_right hAD))
        (Finset.disjoint_of_subset_left Finset.inter_subset_right
          (Finset.disjoint_of_subset_right Finset.inter_subset_right hBC))
        (Finset.disjoint_of_subset_left Finset.inter_subset_right
          (Finset.disjoint_of_subset_right Finset.inter_subset_right hBD))
        (Finset.disjoint_of_subset_left Finset.inter_subset_right
          (Finset.disjoint_of_subset_right Finset.inter_subset_right hCD))
  3. P.card ≤ (P ∩ A).card + (P ∩ B).card + (P ∩ C).card + (P ∩ D).card

    Since P equals the union of the four intersections (established in step 1), repeatedly applying the subadditivity of finite set cardinality (Finset.card_union_le) to each block shows that the size of P is bounded above by the sum of the sizes of the four intersections.

    lines 24–29

    uses Finset.card_union_le

      have h2 : P.card ≤ (P ∩ A).card + (P ∩ B).card + (P ∩ C).card + (P ∩ D).card := by
        calc P.card = (P ∩ A ∪ P ∩ B ∪ P ∩ C ∪ P ∩ D).card := by rw [hP]
          _ ≤ (P ∩ A ∪ P ∩ B ∪ P ∩ C).card + (P ∩ D).card := Finset.card_union_le _ _
          _ ≤ (P ∩ A ∪ P ∩ B).card + (P ∩ C).card + (P ∩ D).card := by
              have := Finset.card_union_le (P ∩ A ∪ P ∩ B) (P ∩ C); omega
          _ ≤ _ := by have := Finset.card_union_le (P ∩ A) (P ∩ B); omega
  4. P.card = (P ∩ A).card + (P ∩ B).card + (P ∩ C).card + (P ∩ D).card

    The two inequalities from steps 2 and 3 bound P.card from above and below by the same sum; linear arithmetic (omega) concludes that they are equal.

    line 30

      omega
Finset.card_union_le
The cardinality of the union of two finite sets is at most the sum of their cardinalities: |s ∪ t| ≤ |s| + |t|.
Finset.disjoint_of_subset_left
If s ⊆ u and u is disjoint from t, then s is disjoint from t.
Finset.disjoint_of_subset_right
If t ⊆ u and s is disjoint from u, then s is disjoint from t.
Finset.inter_subset_left
An intersection of two finite sets is a subset of the first set: s₁ ∩ s₂ ⊆ s₁.
Finset.inter_subset_right
An intersection of two finite sets is a subset of the second set: s₁ ∩ s₂ ⊆ s₂.
Finset.inter_union_distrib_left
Intersection distributes over union on the left: s ∩ (t ∪ u) = (s ∩ t) ∪ (s ∩ u).
Finset.inter_univ
The intersection of any finite set with the universal set is the set itself: s ∩ univ = s.
four_disjoint_subsets_card_sum_le
The sum of cardinalities of four pairwise disjoint subsets of a finite set is at most the cardinality of that set.

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 finset_card_eq_sum_four_block_inter {V : Type*} [Fintype V] [DecidableEq V] (A B C D P : Finset V)    (hAB : Disjoint A B) (hAC : Disjoint A C) (hAD : Disjoint A D)    (hBC : Disjoint B C) (hBD : Disjoint B D) (hCD : Disjoint C D)    (hcover : A ∪ B ∪ C ∪ D = Finset.univ) :    P.card = (P ∩ A).card + (P ∩ B).card + (P ∩ C).card + (P ∩ D).card := by  have hP : P ∩ A ∪ P ∩ B ∪ P ∩ C ∪ P ∩ D = P := by    rw [← Finset.inter_union_distrib_left, ← Finset.inter_union_distrib_left,      ← Finset.inter_union_distrib_left, hcover, Finset.inter_univ]  have h := four_disjoint_subsets_card_sum_le (P ∩ A) (P ∩ B) (P ∩ C) (P ∩ D) P    Finset.inter_subset_left Finset.inter_subset_left Finset.inter_subset_left    Finset.inter_subset_left    (Finset.disjoint_of_subset_left Finset.inter_subset_right      (Finset.disjoint_of_subset_right Finset.inter_subset_right hAB))    (Finset.disjoint_of_subset_left Finset.inter_subset_right      (Finset.disjoint_of_subset_right Finset.inter_subset_right hAC))    (Finset.disjoint_of_subset_left Finset.inter_subset_right      (Finset.disjoint_of_subset_right Finset.inter_subset_right hAD))    (Finset.disjoint_of_subset_left Finset.inter_subset_right      (Finset.disjoint_of_subset_right Finset.inter_subset_right hBC))    (Finset.disjoint_of_subset_left Finset.inter_subset_right      (Finset.disjoint_of_subset_right Finset.inter_subset_right hBD))    (Finset.disjoint_of_subset_left Finset.inter_subset_right      (Finset.disjoint_of_subset_right Finset.inter_subset_right hCD))  have h2 : P.card ≤ (P ∩ A).card + (P ∩ B).card + (P ∩ C).card + (P ∩ D).card := by    calc P.card = (P ∩ A ∪ P ∩ B ∪ P ∩ C ∪ P ∩ D).card := by rw [hP]      _ ≤ (P ∩ A ∪ P ∩ B ∪ P ∩ C).card + (P ∩ D).card := Finset.card_union_le _ _      _ ≤ (P ∩ A ∪ P ∩ B).card + (P ∩ C).card + (P ∩ D).card := by          have := Finset.card_union_le (P ∩ A ∪ P ∩ B) (P ∩ C); omega      _ ≤ _ := by have := Finset.card_union_le (P ∩ A) (P ∩ B); omega  omega
See it in the graphDiscuss this resultChallenge it