AFTD Auto-Formalizing Theoretical Domains

wild_joint_first_block_fiber_mass

theoremverified

For any three-element T on Fin(3q), q>=3, the number of vertex permutations with first block T times choose(3q,3) equals the number of all vertex permutations.

Statement

theorem wild_joint_first_block_fiber_mass
    (q : ℕ) (hq : 3 ≤ q) (T : Finset (Fin (3*q))) (hT : T.card = 3) :
    (univ.filter fun σ : Equiv.Perm (Fin (3*q)) => wild_joint_first_block q σ = T).card *
      (3*q).choose 3 = Fintype.card (Equiv.Perm (Fin (3*q)))
Source
IN-382 / OP-306 campaign9. Explicit residual finite-counting tasks for wild_joint_expected_ID_eq_alpha_sum; no wild-number advance is claimed.
Verified
30 Oct 2026
Axioms
Classical.choiceQuot.soundpropext
Built on 1
  • wild_joint_first_blockThe first block: the set of vertices placed in positions 0,1,2 by σ (= {σ 0, σ 1, σ 2}).
Used by 1
  • wild_joint_expected_ID_eq_alpha_sumCore reduction: E[I*D] = q/C(n,3) * sum over 3-sets T of mu(T) * sum_i alpha_of_color_type(T,i), where alpha_of_color_type is the alpha of…

The proof, explained

The theorem is proved by a double-counting partition over the fibers of the first-block map. Each permutation σ of Fin(3q) has a first block σ({0, 1, 2}) of size 3. For any two 3-element subsets S and T, an ambient permutation e mapping S to T induces a bijection σ ↦ σ ∘ e between their respective fibers, showing that all fibers have equal cardinality. Summing this constant fiber size over all choose(3q, 3) subsets of size 3 yields the total number of permutations of Fin(3q).

  1. For any two equicardinal subsets s and t of a finite type α, there exists an ambient permutation mapping s to t, constructed by combining bijections s ≃ t and sᶜ ≃ tᶜ.

    Because |s| = |t|, Fintype.equivOfCardEq gives a bijection e₁ : s ≃ t. Their complements also have equal cardinality by Fintype.card_compl_set since |sᶜ| = |α| - |s| = |α| - |t| = |tᶜ|, yielding a bijection e₂ : sᶜ ≃ tᶜ. Decomposing α as s ⊕ sᶜ and t ⊕ tᶜ via Equiv.Set.sumCompl, the sum equivalence e₁ ⊕ e₂ produces a permutation of α.

    lines 3–14

    uses Fintype.equivOfCardEq, Fintype.card_compl_set, Equiv.Set.sumCompl

    noncomputable def wild_joint_first_block_fiber_mass_equiv_of_card_eq {α : Type*} [DecidableEq α] [Fintype α]
        (s t : Finset α) (h : s.card = t.card) : Equiv.Perm α :=
      let e1 : (s : Set α) ≃ (t : Set α) :=
        Fintype.equivOfCardEq (by simp [h])
      have hcompl : Fintype.card ((s : Set α)ᶜ : Set α) = Fintype.card ((t : Set α)ᶜ : Set α) := by
        rw [Fintype.card_compl_set, Fintype.card_compl_set]
        simp [h]
      let e2 : ((s : Set α)ᶜ : Set α) ≃ ((t : Set α)ᶜ : Set α) :=
        Fintype.equivOfCardEq hcompl
      (Equiv.Set.sumCompl (s : Set α)).symm.trans
        ((e1.sumCongr e2).trans (Equiv.Set.sumCompl (t : Set α)))
    
  2. The image of s under the constructed permutation is contained in t.

    Any element in the image has the form of the permutation applied to some y ∈ s. Under the decomposition α ≃ s ⊕ sᶜ, y corresponds to Sum.inl y by Equiv.Set.sumCompl_symm_apply_of_mem. The sum equivalence applies e₁ to this left summand via Sum.map_inl, and the inverse sum decomposition Equiv.Set.sumCompl_apply_inl embeds e₁(y) back into α, which lies in t by Subtype.mem.

    lines 15–26

    uses wild_joint_first_block_fiber_mass_equiv_of_card_eq, Equiv.trans_apply, Equiv.sumCongr_apply, Equiv.Set.sumCompl_symm_apply_of_mem, Sum.map_inl, Equiv.Set.sumCompl_apply_inl, Subtype.mem

    lemma wild_joint_first_block_fiber_mass_equiv_of_card_eq_image {α : Type*} [DecidableEq α] [Fintype α]
        (s t : Finset α) (h : s.card = t.card) :
        s.image (wild_joint_first_block_fiber_mass_equiv_of_card_eq s t h) = t := by
      ext x
      simp only [wild_joint_first_block_fiber_mass_equiv_of_card_eq, Equiv.trans_apply, Equiv.sumCongr_apply, mem_image]
      constructor
      · rintro ⟨y, hy, rfl⟩
        have hy' : y ∈ (s : Set α) := hy
        rw [Equiv.Set.sumCompl_symm_apply_of_mem hy']
        simp only [Sum.map_inl]
        rw [Equiv.Set.sumCompl_apply_inl]
        exact Subtype.mem _
  3. Conversely, every element of t is in the image of s under the permutation, so the image of s equals t.

    Given x ∈ t, its preimage under e₁ is y = e₁⁻¹(x) ∈ s. Computing the action of the permutation on y sends it to Sum.inl y, then to Sum.inl (e₁(y)) = Sum.inl x via Equiv.apply_symm_apply, and finally to x. Thus x is in the image of s.

    lines 27–40

    uses Fintype.equivOfCardEq, Subtype.ext, Equiv.Set.sumCompl_symm_apply_of_mem, Sum.map_inl, Equiv.Set.sumCompl_apply_inl, Equiv.apply_symm_apply

      · intro hx
        have hx' : x ∈ (t : Set α) := hx
        let e1 : (s : Set α) ≃ (t : Set α) :=
          Fintype.equivOfCardEq (by simp [h])
        let y_sub := e1.symm ⟨x, hx'⟩
        refine ⟨y_sub.val, y_sub.property, ?_⟩
        have hy' : y_sub.val ∈ (s : Set α) := y_sub.property
        have hy_eq : (⟨y_sub.val, hy'⟩ : (s : Set α)) = y_sub := Subtype.ext rfl
        rw [Equiv.Set.sumCompl_symm_apply_of_mem hy']
        simp only [Sum.map_inl]
        rw [Equiv.Set.sumCompl_apply_inl]
        change (e1 ⟨y_sub.val, hy'⟩).val = x
        rw [hy_eq, Equiv.apply_symm_apply]
    
  4. The set of indices in Fin(3q) less than 3 is exactly {0, 1, 2}, and has cardinality 3.

    Since q ≥ 3, 3q ≥ 9, so 0, 1, 2 < 3q. The condition i.val < 3 over Fin(3q) is equivalent to i ∈ {0, 1, 2}. Computing the cardinality of this 3-element set with card_insert_of_notMem and card_singleton shows its cardinality is 3.

    lines 41–54

    uses card_insert_of_notMem, card_singleton

    lemma wild_joint_first_block_fiber_mass_card (q : ℕ) (hq : 3 ≤ q) (σ : Equiv.Perm (Fin (3*q))) :
        (wild_joint_first_block q σ).card = 3 := by
      have h0 : 0 < 3 * q := by omega
      have h1 : 1 < 3 * q := by omega
      have h2 : 2 < 3 * q := by omega
      have heq : univ.filter (fun (i : Fin (3*q)) => i.val < 3) =
          {⟨0, h0⟩, ⟨1, h1⟩, ⟨2, h2⟩} := by
        ext ⟨x, hx⟩
        simp only [mem_filter, mem_univ, true_and, mem_insert, mem_singleton, Fin.ext_iff]
        omega
      have hcard : (univ.filter (fun (i : Fin (3*q)) => i.val < 3)).card = 3 := by
        rw [heq, card_insert_of_notMem, card_insert_of_notMem, card_singleton]
        · simp [Fin.ext_iff]
        · simp [Fin.ext_iff]
  5. The first block of any permutation σ is the image under σ of {0, 1, 2}, and therefore has cardinality 3.

    By definition, x ∈ wild_joint_first_block q σ means σ⁻¹(x) < 3, which is equivalent to x = σ(y) for some y with y.val < 3. Hence the first block is the image under σ of the initial 3-element segment. Since σ is injective, card_image_of_injective shows that the image also has cardinality 3.

    lines 55–65

    uses card_image_of_injective

      have himage : wild_joint_first_block q σ =
          (univ.filter (fun (i : Fin (3*q)) => i.val < 3)).image σ := by
        ext x
        simp only [wild_joint_first_block, mem_filter, mem_univ, true_and, mem_image]
        constructor
        · intro hx
          exact ⟨σ.symm x, hx, σ.apply_symm_apply x⟩
        · rintro ⟨y, hy, rfl⟩
          simpa using hy
      rw [himage, card_image_of_injective _ σ.injective, hcard]
    
  6. The first block of σ ∘ e is the image under e of the first block of σ, so σ ∘ e has first block T if and only if σ has first block S.

    An element x is in the first block of σ ∘ e if (σ ∘ e)⁻¹(x) < 3, which means e⁻¹(x) is in the first block of σ, or equivalently x is in the image under e of the first block of σ. Since e maps S to T and is injective, taking images under e is injective by Finset.image_injective, establishing the equivalence.

    lines 66–85

    uses Finset.image_injective

    lemma wild_joint_first_block_fiber_mass_fiber_card_eq
        (q : ℕ) (S T : Finset (Fin (3*q))) (e : Equiv.Perm (Fin (3*q)))
        (heT : S.image e = T) :
        (univ.filter fun σ : Equiv.Perm (Fin (3*q)) => wild_joint_first_block q σ = S).card =
        (univ.filter fun σ : Equiv.Perm (Fin (3*q)) => wild_joint_first_block q σ = T).card := by
      have hfirst : ∀ σ : Equiv.Perm (Fin (3*q)),
          wild_joint_first_block q (σ.trans e) = (wild_joint_first_block q σ).image e := by
        intro σ
        ext x
        simp only [wild_joint_first_block, mem_filter, mem_univ, true_and, mem_image]
        constructor
        · intro hx
          exact ⟨e.symm x, hx, e.apply_symm_apply x⟩
        · rintro ⟨y, hy, rfl⟩
          simpa using hy
      have hfirstiff : ∀ σ : Equiv.Perm (Fin (3*q)),
          wild_joint_first_block q (σ.trans e) = T ↔ wild_joint_first_block q σ = S := by
        intro σ
        rw [hfirst, ← heT]
        exact Finset.image_injective e.injective |>.eq_iff
  7. Post-composition with e is a bijection between the fiber over S and the fiber over T, so both fibers have equal cardinality.

    We apply card_bij with the map σ ↦ σ ∘ e. It maps the fiber over S to the fiber over T by the previous equivalence. It is injective because σ₁ ∘ e = σ₂ ∘ e implies σ₁ = σ₂ via e.injective and Equiv.ext. It is surjective because any τ with first block T has preimage τ ∘ e⁻¹ with first block S.

    lines 86–102

    uses card_bij, Equiv.ext, congrArg

      apply card_bij (fun σ _ => σ.trans e)
      · intro σ hσ
        simp only [mem_filter, mem_univ, true_and] at hσ ⊢
        exact (hfirstiff σ).mpr hσ
      · intro σ₁ _ σ₂ _ h
        apply Equiv.ext
        intro x
        have hh := congrArg (fun a : Equiv.Perm (Fin (3*q)) => a x) h
        exact e.injective hh
      · intro τ hτ
        have hc : (τ.trans e.symm).trans e = τ := by ext x; simp
        refine ⟨τ.trans e.symm, ?_, hc⟩
        simp only [mem_filter, mem_univ, true_and] at hτ ⊢
        apply (hfirstiff _).mp
        rw [hc]
        exact hτ
    
  8. The first block map sends permutations to 3-element subsets, so the total number of permutations equals the sum of fiber cardinalities over all 3-element subsets.

    By wild_joint_first_block_fiber_mass_card, the first block of any permutation has size 3, so the map lands in powersetCard 3 univ. Applying card_eq_sum_card_fiberwise partitions the universe of permutations into fibers over all 3-element subsets.

    lines 103–114

    uses wild_joint_first_block_fiber_mass_card, card_eq_sum_card_fiberwise

    theorem wild_joint_first_block_fiber_mass
        (q : ℕ) (hq : 3 ≤ q) (T : Finset (Fin (3*q))) (hT : T.card = 3) :
        (univ.filter fun σ : Equiv.Perm (Fin (3*q)) => wild_joint_first_block q σ = T).card *
          (3*q).choose 3 = Fintype.card (Equiv.Perm (Fin (3*q))) := by
      classical
      have hmaps : Set.MapsTo (wild_joint_first_block q) (↑(univ : Finset (Equiv.Perm (Fin (3*q)))))
          (↑(powersetCard 3 (univ : Finset (Fin (3*q))))) := by
        intro σ _
        simp only [mem_coe, mem_powersetCard_univ]
        exact wild_joint_first_block_fiber_mass_card q hq σ
      have hsum := card_eq_sum_card_fiberwise (f := wild_joint_first_block q)
        (s := (univ : Finset (Equiv.Perm (Fin (3*q))))) (t := powersetCard 3 univ) hmaps
  9. Every 3-element subset b has a fiber of the same cardinality as the fiber over T.

    For any 3-element subset b, since |b| = |T| = 3, wild_joint_first_block_fiber_mass_equiv_of_card_eq gives a permutation mapping b to T via wild_joint_first_block_fiber_mass_equiv_of_card_eq_image. Applying wild_joint_first_block_fiber_mass_fiber_card_eq shows that the fibers over b and T have the same size.

    lines 115–126

    uses wild_joint_first_block_fiber_mass_equiv_of_card_eq, wild_joint_first_block_fiber_mass_equiv_of_card_eq_image, wild_joint_first_block_fiber_mass_fiber_card_eq

      have hterm : ∀ b ∈ powersetCard 3 (univ : Finset (Fin (3*q))),
          {a ∈ (univ : Finset (Equiv.Perm (Fin (3*q)))) | wild_joint_first_block q a = b}.card =
          (univ.filter fun σ : Equiv.Perm (Fin (3*q)) => wild_joint_first_block q σ = T).card := by
        intro b hb
        rw [mem_powersetCard_univ] at hb
        have he : b.image (wild_joint_first_block_fiber_mass_equiv_of_card_eq b T (by rw [hb, hT])) = T :=
          wild_joint_first_block_fiber_mass_equiv_of_card_eq_image b T (by rw [hb, hT])
        have heq := wild_joint_first_block_fiber_mass_fiber_card_eq q b T _ he
        have hfilter : {a ∈ (univ : Finset (Equiv.Perm (Fin (3*q)))) | wild_joint_first_block q a = b} =
            univ.filter (fun σ => wild_joint_first_block q σ = b) := by
          ext; simp
        rw [hfilter, heq]
  10. Summing the constant fiber size over all choose(3q, 3) subsets yields the theorem.

    Replacing each fiber size in the partition sum with the fiber size over T using sum_congr turns the sum into a constant sum. By sum_const, card_powersetCard, and Fintype.card_fin, there are choose(3q, 3) such subsets, so the sum equals the fiber size times choose(3q, 3), which equals the total number of permutations.

    lines 127–129

    uses sum_congr, sum_const, card_powersetCard, Fintype.card_fin, mul_comm

      rw [sum_congr rfl hterm] at hsum
      simp only [sum_const, card_powersetCard, card_univ, Fintype.card_fin, smul_eq_mul] at hsum
      rw [mul_comm, hsum]
Fintype.equivOfCardEq
Two finite types with the same cardinality are equivalent (there exists a bijection between them).
Fintype.card_compl_set
For a subset s of a finite type α, the cardinality of its complement sᶜ equals |α| - |s|.
Equiv.Set.sumCompl
A type α is canonically equivalent to the disjoint sum of any subset s and its complement sᶜ.
wild_joint_first_block_fiber_mass_equiv_of_card_eq
Given two equicardinal finsets s and t, constructs a permutation of the ambient type mapping s to t.
Equiv.trans_apply
The composition of equivalences satisfies (f.trans g)(a) = g(f(a)).
Equiv.sumCongr_apply
The sum of two equivalences ea ⊕ eb acts componentwise on a disjoint sum.
Equiv.Set.sumCompl_symm_apply_of_mem
Under the equivalence α ≃ s ⊕ sᶜ, an element x ∈ s maps to Sum.inl x.
Sum.map_inl
Applying Sum.map f g to Sum.inl x yields Sum.inl (f x).
Equiv.Set.sumCompl_apply_inl
Under the equivalence s ⊕ sᶜ ≃ α, the element Sum.inl x maps to x in α.
Subtype.mem
An element of a subtype satisfies the subtype's membership predicate.
Subtype.ext
Two subtype elements are equal if their underlying values are equal.
Equiv.apply_symm_apply
Applying an equivalence to its inverse value recovers the original element: e(e.symm x) = x.
card_insert_of_notMem
Inserting an element a ∉ s into a finset s increments its cardinality by 1.
card_singleton
The cardinality of a singleton set {a} is 1.
card_image_of_injective
The image of a finset under an injective function has the same cardinality as the finset.
Finset.image_injective
If a function f is injective, the map sending a finset s to its image f(s) is also injective.
card_bij
A function between two finsets that is well-defined, injective, and surjective establishes that the finsets have equal cardinality.
Equiv.ext
Two equivalences are equal if they agree on all elements.
congrArg
Functions respect equality: if a₁ = a₂, then f(a₁) = f(a₂).
wild_joint_first_block_fiber_mass_card
For any q ≥ 3 and permutation σ of Fin(3q), the first block wild_joint_first_block q σ has cardinality 3.
card_eq_sum_card_fiberwise
If f maps a finset s into t, the cardinality of s equals the sum over b ∈ t of the fiber sizes |{a ∈ s | f(a) = b}|.
wild_joint_first_block_fiber_mass_equiv_of_card_eq_image
The permutation constructed between equicardinal finsets s and t maps s to t.
wild_joint_first_block_fiber_mass_fiber_card_eq
If two sets S and T satisfy e(S) = T for a permutation e, the fibers of the first block map over S and T have equal cardinality.
sum_congr
Two sums are equal if their domains are equal and their summands agree on all domain elements.
sum_const
The sum of a constant value b over a finset s equals |s| • b.
card_powersetCard
The number of size-n subsets of a finset s equals choose(|s|, n).
Fintype.card_fin
The cardinality of the finite type Fin n is n.
mul_comm
Multiplication in a commutative magma satisfies a * b = b * a.

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 Finsetnoncomputable def wild_joint_first_block_fiber_mass_equiv_of_card_eq {α : Type*} [DecidableEq α] [Fintype α]    (s t : Finset α) (h : s.card = t.card) : Equiv.Perm α :=  let e1 : (s : Set α) ≃ (t : Set α) :=    Fintype.equivOfCardEq (by simp [h])  have hcompl : Fintype.card ((s : Set α)ᶜ : Set α) = Fintype.card ((t : Set α)ᶜ : Set α) := by    rw [Fintype.card_compl_set, Fintype.card_compl_set]    simp [h]  let e2 : ((s : Set α)ᶜ : Set α) ≃ ((t : Set α)ᶜ : Set α) :=    Fintype.equivOfCardEq hcompl  (Equiv.Set.sumCompl (s : Set α)).symm.trans    ((e1.sumCongr e2).trans (Equiv.Set.sumCompl (t : Set α)))lemma wild_joint_first_block_fiber_mass_equiv_of_card_eq_image {α : Type*} [DecidableEq α] [Fintype α]    (s t : Finset α) (h : s.card = t.card) :    s.image (wild_joint_first_block_fiber_mass_equiv_of_card_eq s t h) = t := by  ext x  simp only [wild_joint_first_block_fiber_mass_equiv_of_card_eq, Equiv.trans_apply, Equiv.sumCongr_apply, mem_image]  constructor  · rintro ⟨y, hy, rfl⟩    have hy' : y ∈ (s : Set α) := hy    rw [Equiv.Set.sumCompl_symm_apply_of_mem hy']    simp only [Sum.map_inl]    rw [Equiv.Set.sumCompl_apply_inl]    exact Subtype.mem _  · intro hx    have hx' : x ∈ (t : Set α) := hx    let e1 : (s : Set α) ≃ (t : Set α) :=      Fintype.equivOfCardEq (by simp [h])    let y_sub := e1.symm ⟨x, hx'⟩    refine ⟨y_sub.val, y_sub.property, ?_⟩    have hy' : y_sub.val ∈ (s : Set α) := y_sub.property    have hy_eq : (⟨y_sub.val, hy'⟩ : (s : Set α)) = y_sub := Subtype.ext rfl    rw [Equiv.Set.sumCompl_symm_apply_of_mem hy']    simp only [Sum.map_inl]    rw [Equiv.Set.sumCompl_apply_inl]    change (e1 ⟨y_sub.val, hy'⟩).val = x    rw [hy_eq, Equiv.apply_symm_apply]lemma wild_joint_first_block_fiber_mass_card (q : ℕ) (hq : 3 ≤ q) (σ : Equiv.Perm (Fin (3*q))) :    (wild_joint_first_block q σ).card = 3 := by  have h0 : 0 < 3 * q := by omega  have h1 : 1 < 3 * q := by omega  have h2 : 2 < 3 * q := by omega  have heq : univ.filter (fun (i : Fin (3*q)) => i.val < 3) =      {⟨0, h0⟩, ⟨1, h1⟩, ⟨2, h2⟩} := by    ext ⟨x, hx⟩    simp only [mem_filter, mem_univ, true_and, mem_insert, mem_singleton, Fin.ext_iff]    omega  have hcard : (univ.filter (fun (i : Fin (3*q)) => i.val < 3)).card = 3 := by    rw [heq, card_insert_of_notMem, card_insert_of_notMem, card_singleton]    · simp [Fin.ext_iff]    · simp [Fin.ext_iff]  have himage : wild_joint_first_block q σ =      (univ.filter (fun (i : Fin (3*q)) => i.val < 3)).image σ := by    ext x    simp only [wild_joint_first_block, mem_filter, mem_univ, true_and, mem_image]    constructor    · intro hx      exact ⟨σ.symm x, hx, σ.apply_symm_apply x⟩    · rintro ⟨y, hy, rfl⟩      simpa using hy  rw [himage, card_image_of_injective _ σ.injective, hcard]lemma wild_joint_first_block_fiber_mass_fiber_card_eq    (q : ℕ) (S T : Finset (Fin (3*q))) (e : Equiv.Perm (Fin (3*q)))    (heT : S.image e = T) :    (univ.filter fun σ : Equiv.Perm (Fin (3*q)) => wild_joint_first_block q σ = S).card =    (univ.filter fun σ : Equiv.Perm (Fin (3*q)) => wild_joint_first_block q σ = T).card := by  have hfirst : ∀ σ : Equiv.Perm (Fin (3*q)),      wild_joint_first_block q (σ.trans e) = (wild_joint_first_block q σ).image e := by    intro σ    ext x    simp only [wild_joint_first_block, mem_filter, mem_univ, true_and, mem_image]    constructor    · intro hx      exact ⟨e.symm x, hx, e.apply_symm_apply x⟩    · rintro ⟨y, hy, rfl⟩      simpa using hy  have hfirstiff : ∀ σ : Equiv.Perm (Fin (3*q)),      wild_joint_first_block q (σ.trans e) = T ↔ wild_joint_first_block q σ = S := by    intro σ    rw [hfirst, ← heT]    exact Finset.image_injective e.injective |>.eq_iff  apply card_bij (fun σ _ => σ.trans e)  · intro σ hσ    simp only [mem_filter, mem_univ, true_and] at hσ ⊢    exact (hfirstiff σ).mpr hσ  · intro σ₁ _ σ₂ _ h    apply Equiv.ext    intro x    have hh := congrArg (fun a : Equiv.Perm (Fin (3*q)) => a x) h    exact e.injective hh  · intro τ hτ    have hc : (τ.trans e.symm).trans e = τ := by ext x; simp    refine ⟨τ.trans e.symm, ?_, hc⟩    simp only [mem_filter, mem_univ, true_and] at hτ ⊢    apply (hfirstiff _).mp    rw [hc]    exact hτtheorem wild_joint_first_block_fiber_mass    (q : ℕ) (hq : 3 ≤ q) (T : Finset (Fin (3*q))) (hT : T.card = 3) :    (univ.filter fun σ : Equiv.Perm (Fin (3*q)) => wild_joint_first_block q σ = T).card *      (3*q).choose 3 = Fintype.card (Equiv.Perm (Fin (3*q))) := by  classical  have hmaps : Set.MapsTo (wild_joint_first_block q) (↑(univ : Finset (Equiv.Perm (Fin (3*q)))))      (↑(powersetCard 3 (univ : Finset (Fin (3*q))))) := by    intro σ _    simp only [mem_coe, mem_powersetCard_univ]    exact wild_joint_first_block_fiber_mass_card q hq σ  have hsum := card_eq_sum_card_fiberwise (f := wild_joint_first_block q)    (s := (univ : Finset (Equiv.Perm (Fin (3*q))))) (t := powersetCard 3 univ) hmaps  have hterm : ∀ b ∈ powersetCard 3 (univ : Finset (Fin (3*q))),      {a ∈ (univ : Finset (Equiv.Perm (Fin (3*q)))) | wild_joint_first_block q a = b}.card =      (univ.filter fun σ : Equiv.Perm (Fin (3*q)) => wild_joint_first_block q σ = T).card := by    intro b hb    rw [mem_powersetCard_univ] at hb    have he : b.image (wild_joint_first_block_fiber_mass_equiv_of_card_eq b T (by rw [hb, hT])) = T :=      wild_joint_first_block_fiber_mass_equiv_of_card_eq_image b T (by rw [hb, hT])    have heq := wild_joint_first_block_fiber_mass_fiber_card_eq q b T _ he    have hfilter : {a ∈ (univ : Finset (Equiv.Perm (Fin (3*q)))) | wild_joint_first_block q a = b} =        univ.filter (fun σ => wild_joint_first_block q σ = b) := by      ext; simp    rw [hfilter, heq]  rw [sum_congr rfl hterm] at hsum  simp only [sum_const, card_powersetCard, card_univ, Fintype.card_fin, smul_eq_mul] at hsum  rw [mul_comm, hsum]
See it in the graphDiscuss this resultChallenge it