AFTD Auto-Formalizing Theoretical Domains

op1957_four_shore_aggregate_totals

theoremverified

Four shore aggregate totals.

Statement

theorem op1957_four_shore_aggregate_totals
    {V : Type*} [Fintype V] [DecidableEq V]
    (F B : Fin 4 → Finset V) (E : Finset V)
    (hFdis : ∀ i j : Fin 4, i ≠ j → Disjoint (F i) (F j))
    (hEdis : ∀ i : Fin 4, Disjoint (F i) E)
    (hBdis : ∀ i j : Fin 4, i ≠ j → Disjoint (B i) (B j))
    (hBcover : (Finset.univ : Finset (Fin 4)).biUnion B = Finset.univ)
    (hEB : E ⊆ B 1) :
    let g : Fin 4 → Fin 4 → ℕ := fun i b => (F i ∩ B b).card
    let tot : Fin 4 → ℕ := fun b => (∑ i : Fin 4, g i b) + (if b=1 then E.card else 0)
    let W := (Finset.univ : Finset (Fin 4)).biUnion F ∪ E
    (∀ b, tot b = (W ∩ B b).card) ∧
    (∀ b, tot b ≤ (B b).card) ∧ (∑ b : Fin 4, tot b) = W.card
Source
OP-1957; positive-separator graph-to-count transfer.
Verified
26 Nov 2026
Axioms
Classical.choiceQuot.soundpropext
Used by 4

The proof, explained

We define the combined set W = (⋃ᵢ F i) ∪ E. By decomposing W ∩ B b into the disjoint parts (⋃ᵢ F i) ∩ B b and E ∩ B b, and using the fact that E ⊆ B 1 is disjoint from every other block, we identify the aggregate total tot b with |W ∩ B b|. The bound tot b ≤ |B b| then follows immediately from W ∩ B b ⊆ B b, and the total sum ∑_b tot b equals |W| because the blocks B b partition the ambient space and therefore partition W.

  1. We define W as the union of all four sets F i together with E.

    We enable classical logic, simplify the definitions, and introduce the set W = (⋃ᵢ F i) ∪ E for use throughout the proof.

    lines 16–18

      classical
      dsimp only
      let W : Finset V := (Finset.univ : Finset (Fin 4)).biUnion F ∪ E
  2. For each block B b, |(⋃ᵢ F i) ∩ B b| = ∑ᵢ |F i ∩ B b|.

    By distributivity of intersection over union, (⋃ᵢ F i) ∩ B b = ⋃ᵢ (F i ∩ B b). Since the sets F i are pairwise disjoint by assumption, their intersections with B b are also pairwise disjoint. Thus, by the formula for the cardinality of a disjoint union, the cardinality of the union is the sum of the cardinalities of the individual intersections.

    lines 19–35

    uses Finset.mem_inter, Finset.mem_biUnion, Finset.mem_univ, true_and, Finset.disjoint_of_subset_left, Finset.inter_subset_left, Finset.disjoint_of_subset_right, Finset.card_biUnion

      have hFB : ∀ b, ((Finset.univ : Finset (Fin 4)).biUnion F ∩ B b).card =
          ∑ i : Fin 4, (F i ∩ B b).card := by
        intro b
        have heq : (Finset.univ : Finset (Fin 4)).biUnion F ∩ B b =
            (Finset.univ : Finset (Fin 4)).biUnion (fun i => F i ∩ B b) := by
          ext v
          simp only [Finset.mem_inter,Finset.mem_biUnion,Finset.mem_univ,true_and]
          constructor
          · rintro ⟨⟨i,hi⟩,hb⟩
            exact ⟨i,hi,hb⟩
          · rintro ⟨i,hi,hb⟩
            exact ⟨⟨i,hi⟩,hb⟩
        have hp : ((Finset.univ : Finset (Fin 4)) : Set (Fin 4)).PairwiseDisjoint (fun i => F i ∩ B b) := by
          intro i _ j _ hij
          exact Finset.disjoint_of_subset_left Finset.inter_subset_left
            (Finset.disjoint_of_subset_right Finset.inter_subset_left (hFdis i j hij))
        rw [heq,Finset.card_biUnion hp]
  3. The union ⋃ᵢ F i is disjoint from E.

    Any element in ⋃ᵢ F i belongs to some F i. Since every F i is assumed disjoint from E, no element of ⋃ᵢ F i can belong to E.

    lines 36–40

    uses Finset.disjoint_left.mpr, Finset.mem_biUnion.mp, Finset.disjoint_left.mp

      have hFE : Disjoint ((Finset.univ : Finset (Fin 4)).biUnion F) E := by
        apply Finset.disjoint_left.mpr
        intro v hv he
        obtain ⟨i,_,hvi⟩ := Finset.mem_biUnion.mp hv
        exact Finset.disjoint_left.mp (hEdis i) hvi he
  4. For each block B b, |E ∩ B b| equals |E| when b = 1, and 0 otherwise.

    We split on whether b = 1. If b = 1, since E ⊆ B 1 by hypothesis, E ∩ B 1 = E, so its cardinality is |E|. If b ≠ 1, since E ⊆ B 1 and the blocks B 1 and B b are disjoint, E is disjoint from B b, making E ∩ B b = ∅ with cardinality 0.

    lines 41–49

    uses Finset.inter_eq_left.mpr, Finset.disjoint_of_subset_left, Ne.symm, Finset.disjoint_iff_inter_eq_empty.mp

      have hEtot : ∀ b, (E ∩ B b).card = if b=1 then E.card else 0 := by
        intro b
        by_cases h : b=1
        · subst b
          rw [Finset.inter_eq_left.mpr hEB]
          simp
        · have hd : Disjoint E (B b) := Finset.disjoint_of_subset_left hEB (hBdis 1 b (Ne.symm h))
          rw [Finset.disjoint_iff_inter_eq_empty.mp hd]
          simp [h]
  5. For each b ∈ {0, 1, 2, 3}, tot b = |W ∩ B b|.

    Distributing intersection over union gives W ∩ B b = ((⋃ᵢ F i) ∩ B b) ∪ (E ∩ B b). These two subsets are disjoint because ⋃ᵢ F i and E are disjoint. Therefore, |W ∩ B b| = |(⋃ᵢ F i) ∩ B b| + |E ∩ B b|. Substituting the identities from the previous steps, this sum evaluates precisely to ∑ᵢ |F i ∩ B b| + (if b = 1 then |E| else 0), which is tot b.

    lines 50–58

    uses Finset.disjoint_of_subset_left, Finset.inter_subset_left, Finset.disjoint_of_subset_right, or_and_right, Finset.card_union_of_disjoint

      have hWb : ∀ b, (∑ i : Fin 4, (F i ∩ B b).card) + (if b=1 then E.card else 0) = (W ∩ B b).card := by
        intro b
        have hd : Disjoint (((Finset.univ : Finset (Fin 4)).biUnion F) ∩ B b) (E ∩ B b) :=
          Finset.disjoint_of_subset_left Finset.inter_subset_left
            (Finset.disjoint_of_subset_right Finset.inter_subset_left hFE)
        have heq : W ∩ B b = (((Finset.univ : Finset (Fin 4)).biUnion F) ∩ B b) ∪ (E ∩ B b) := by
          ext v
          simp [W,or_and_right]
        rw [heq,Finset.card_union_of_disjoint hd,hFB,hEtot]
  6. The sum of the block totals ∑_b |W ∩ B b| equals |W|.

    The pieces W ∩ B b for b ∈ Fin 4 partition W: they are pairwise disjoint because the blocks B b are pairwise disjoint, and their union is W because the blocks B b cover the entire universe V. Thus, the sum of their cardinalities equals |W|.

    lines 59–74

    uses Finset.disjoint_of_subset_left, Finset.inter_subset_right, Finset.disjoint_of_subset_right, Finset.mem_biUnion, Finset.mem_univ, true_and, Finset.mem_inter, Finset.mem_biUnion.mp, Finset.card_biUnion

      have htotal : (∑ b : Fin 4, (W ∩ B b).card) = W.card := by
        have hp : ((Finset.univ : Finset (Fin 4)) : Set (Fin 4)).PairwiseDisjoint (fun b => W ∩ B b) := by
          intro i _ j _ hij
          exact Finset.disjoint_of_subset_left Finset.inter_subset_right
            (Finset.disjoint_of_subset_right Finset.inter_subset_right (hBdis i j hij))
        have heq : (Finset.univ : Finset (Fin 4)).biUnion (fun b => W ∩ B b) = W := by
          ext v
          simp only [Finset.mem_biUnion,Finset.mem_univ,true_and,Finset.mem_inter]
          constructor
          · rintro ⟨b,hv,_⟩
            exact hv
          · intro hv
            have hh : v ∈ (Finset.univ : Finset (Fin 4)).biUnion B := by rw [hBcover]; simp
            obtain ⟨b,_,hvb⟩ := Finset.mem_biUnion.mp hh
            exact ⟨b,hv,hvb⟩
        rw [← Finset.card_biUnion hp,heq]
  7. All three conclusions hold: tot b = |W ∩ B b|, tot b ≤ |B b|, and ∑_b tot b = |W|.

    The first conjunct is the identity tot b = |W ∩ B b| established earlier. For the second, since W ∩ B b ⊆ B b, monotonicity of cardinality gives tot b = |W ∩ B b| ≤ |B b|. For the third, replacing tot b with |W ∩ B b| yields ∑_b |W ∩ B b|, which equals |W| by the partition sum identity.

    lines 75–80

    uses Finset.card_le_card, Finset.inter_subset_right

      refine ⟨hWb,?_,?_⟩
      · intro b
        rw [hWb b]
        exact Finset.card_le_card Finset.inter_subset_right
      · simp_rw [hWb]
        exact htotal
Finset.card_biUnion
A finite union of pairwise disjoint sets has cardinality equal to the sum of the cardinalities of the sets.
Finset.card_le_card
If s ⊆ t, then |s| ≤ |t|.
Finset.card_union_of_disjoint
If two finite sets are disjoint, the cardinality of their union is the sum of their cardinalities.
Finset.disjoint_iff_inter_eq_empty.mp
Two sets are disjoint if and only if their intersection is empty.
Finset.disjoint_left.mp
If two sets are disjoint, any element of the first set is not in the second.
Finset.disjoint_left.mpr
If no element of the first set belongs to the second, the two sets are disjoint.
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_eq_left.mpr
If s ⊆ t, then s ∩ t = s.
Finset.inter_subset_left
The intersection s₁ ∩ s₂ is a subset of s₁.
Finset.inter_subset_right
The intersection s₁ ∩ s₂ is a subset of s₂.
Finset.mem_biUnion
An element is in ⋃ a ∈ s, t a if and only if it belongs to t a for some a ∈ s.
Finset.mem_biUnion.mp
If an element is in ⋃ a ∈ s, t a, then there exists a ∈ s containing it.
Finset.mem_inter
An element is in s₁ ∩ s₂ if and only if it is in s₁ and in s₂.
Finset.mem_univ
Every element of a finite type belongs to its universal finset.
Ne.symm
Inequality is symmetric: if a ≠ b, then b ≠ a.
or_and_right
Distributivity of conjunction over disjunction: (a ∨ b) ∧ c ↔ (a ∧ c) ∨ (b ∧ c).
true_and
The proposition True ∧ p is equivalent to p.

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 2000000theorem op1957_four_shore_aggregate_totals    {V : Type*} [Fintype V] [DecidableEq V]    (F B : Fin 4 → Finset V) (E : Finset V)    (hFdis : ∀ i j : Fin 4, i ≠ j → Disjoint (F i) (F j))    (hEdis : ∀ i : Fin 4, Disjoint (F i) E)    (hBdis : ∀ i j : Fin 4, i ≠ j → Disjoint (B i) (B j))    (hBcover : (Finset.univ : Finset (Fin 4)).biUnion B = Finset.univ)    (hEB : E ⊆ B 1) :    let g : Fin 4 → Fin 4 → ℕ := fun i b => (F i ∩ B b).card    let tot : Fin 4 → ℕ := fun b => (∑ i : Fin 4, g i b) + (if b=1 then E.card else 0)    let W := (Finset.univ : Finset (Fin 4)).biUnion F ∪ E    (∀ b, tot b = (W ∩ B b).card) ∧    (∀ b, tot b ≤ (B b).card) ∧ (∑ b : Fin 4, tot b) = W.card := by  classical  dsimp only  let W : Finset V := (Finset.univ : Finset (Fin 4)).biUnion F ∪ E  have hFB : ∀ b, ((Finset.univ : Finset (Fin 4)).biUnion F ∩ B b).card =      ∑ i : Fin 4, (F i ∩ B b).card := by    intro b    have heq : (Finset.univ : Finset (Fin 4)).biUnion F ∩ B b =        (Finset.univ : Finset (Fin 4)).biUnion (fun i => F i ∩ B b) := by      ext v      simp only [Finset.mem_inter,Finset.mem_biUnion,Finset.mem_univ,true_and]      constructor      · rintro ⟨⟨i,hi⟩,hb⟩        exact ⟨i,hi,hb⟩      · rintro ⟨i,hi,hb⟩        exact ⟨⟨i,hi⟩,hb⟩    have hp : ((Finset.univ : Finset (Fin 4)) : Set (Fin 4)).PairwiseDisjoint (fun i => F i ∩ B b) := by      intro i _ j _ hij      exact Finset.disjoint_of_subset_left Finset.inter_subset_left        (Finset.disjoint_of_subset_right Finset.inter_subset_left (hFdis i j hij))    rw [heq,Finset.card_biUnion hp]  have hFE : Disjoint ((Finset.univ : Finset (Fin 4)).biUnion F) E := by    apply Finset.disjoint_left.mpr    intro v hv he    obtain ⟨i,_,hvi⟩ := Finset.mem_biUnion.mp hv    exact Finset.disjoint_left.mp (hEdis i) hvi he  have hEtot : ∀ b, (E ∩ B b).card = if b=1 then E.card else 0 := by    intro b    by_cases h : b=1    · subst b      rw [Finset.inter_eq_left.mpr hEB]      simp    · have hd : Disjoint E (B b) := Finset.disjoint_of_subset_left hEB (hBdis 1 b (Ne.symm h))      rw [Finset.disjoint_iff_inter_eq_empty.mp hd]      simp [h]  have hWb : ∀ b, (∑ i : Fin 4, (F i ∩ B b).card) + (if b=1 then E.card else 0) = (W ∩ B b).card := by    intro b    have hd : Disjoint (((Finset.univ : Finset (Fin 4)).biUnion F) ∩ B b) (E ∩ B b) :=      Finset.disjoint_of_subset_left Finset.inter_subset_left        (Finset.disjoint_of_subset_right Finset.inter_subset_left hFE)    have heq : W ∩ B b = (((Finset.univ : Finset (Fin 4)).biUnion F) ∩ B b) ∪ (E ∩ B b) := by      ext v      simp [W,or_and_right]    rw [heq,Finset.card_union_of_disjoint hd,hFB,hEtot]  have htotal : (∑ b : Fin 4, (W ∩ B b).card) = W.card := by    have hp : ((Finset.univ : Finset (Fin 4)) : Set (Fin 4)).PairwiseDisjoint (fun b => W ∩ B b) := by      intro i _ j _ hij      exact Finset.disjoint_of_subset_left Finset.inter_subset_right        (Finset.disjoint_of_subset_right Finset.inter_subset_right (hBdis i j hij))    have heq : (Finset.univ : Finset (Fin 4)).biUnion (fun b => W ∩ B b) = W := by      ext v      simp only [Finset.mem_biUnion,Finset.mem_univ,true_and,Finset.mem_inter]      constructor      · rintro ⟨b,hv,_⟩        exact hv      · intro hv        have hh : v ∈ (Finset.univ : Finset (Fin 4)).biUnion B := by rw [hBcover]; simp        obtain ⟨b,_,hvb⟩ := Finset.mem_biUnion.mp hh        exact ⟨b,hv,hvb⟩    rw [← Finset.card_biUnion hp,heq]  refine ⟨hWb,?_,?_⟩  · intro b    rw [hWb b]    exact Finset.card_le_card Finset.inter_subset_right  · simp_rw [hWb]    exact htotal
See it in the graphDiscuss this resultChallenge it