op1525_equal_block_color_profiles_match
If two Boolean colorings of the same finite collection of equally sized blocks have the same number of blocks containing exactly k true vertices for each possible k, then one coloring is obtained from the other by permuting blocks and independently permuting vertices inside every block.
Statement
theorem op1525_equal_block_color_profiles_match (m r : ℕ) (f g : Fin m → Fin r → Bool) (hprofile : ∀ k : Fin (r + 1), ((Finset.univ : Finset (Fin m)).filter (fun i => ((Finset.univ : Finset (Fin r)).filter (fun j => f i j = true)).card = k.val)).card = ((Finset.univ : Finset (Fin m)).filter (fun i => ((Finset.univ : Finset (Fin r)).filter (fun j => g i j = true)).card = k.val)).card) : ∃ σ : Equiv.Perm (Fin m), ∃ τ : Fin m → Equiv.Perm (Fin r), ∀ i j, f (σ i) (τ i j) = g i j
- Source
- The final profile-to-permutation step in the multipartite coloring-reconstruction route for OP-1525.
- Verified
- 17 Nov 2026
- Axioms
Classical.choiceQuot.soundpropext
The proof, explained
The proof constructs the block permutation σ and the per-block vertex permutations τ(i) by gluing fiberwise bijections using Equiv.ofFiberEquiv. First, because f and g have the same number of blocks with k true entries for each k, matching these fibers yields a block permutation σ that aligns blocks with identical counts of true vertices. Second, for each block i, block i under g and block σ(i) under f have identical numbers of true (and hence false) vertices, so matching their boolean fibers yields an inner permutation τ(i) on vertices. By construction, these permutations satisfy f(σ(i), τ(i)(j)) = g(i, j) everywhere.
For any coloring h, each block i has a well-defined profile P(h, i) in Fin (r + 1) counting its true vertices.
Working classically, we define P(h, i) as the number of vertices j in block i with h(i, j) = true. Since a block has r vertices, the number of true vertices is at most r (by Finset.card_filter_le), hence strictly less than r + 1 (by Nat.lt_succ_of_le), making it a valid index in Fin (r + 1).
uses
Nat.lt_succ_of_le,Finset.card_filter_leclassical let P (h : Fin m → Fin r → Bool) (i : Fin m) : Fin (r + 1) := ⟨((Finset.univ : Finset (Fin r)).filter (fun j => h i j = true)).card, Nat.lt_succ_of_le (by simpa using Finset.card_filter_le (Finset.univ : Finset (Fin r)) (fun j => h i j = true))⟩
For every profile k in Fin (r + 1), the number of blocks with profile k under g equals the number of blocks with profile k under f.
Using Fintype.card_subtype, the subtype cardinality of blocks having profile k is rewritten as the cardinality of the corresponding filtered finset. By the hypothesis that f and g share the same profile distribution, these cardinalities are equal.
uses
Fintype.card_subtype,Fin.ext_iff,Fin.val_mkhave hcard (k : Fin (r + 1)) : Fintype.card {i // P g i = k} = Fintype.card {i // P f i = k} := by simp only [Fintype.card_subtype] simpa only [P, Fin.ext_iff, Fin.val_mk] using (hprofile k).symm
There exists a permutation σ of blocks such that every block i under g has the same profile as block σ(i) under f.
Because each profile fiber under g has the same size as the corresponding profile fiber under f, Fintype.equivOfCardEq provides an equivalence between each pair of fibers. Equiv.ofFiberEquiv glues these fiber equivalences into a block permutation σ, and Equiv.ofFiberEquiv_map confirms that P(f, σ(i)) = P(g, i) for all blocks i.
uses
Equiv.ofFiberEquiv,Fintype.equivOfCardEq,Equiv.ofFiberEquiv_maplet σ : Equiv.Perm (Fin m) := Equiv.ofFiberEquiv (fun k => Fintype.equivOfCardEq (hcard k)) have hσ (i : Fin m) : P f (σ i) = P g i := Equiv.ofFiberEquiv_map _ i
For each block i, the number of true vertices in block i under g equals the number of true vertices in block σ(i) under f.
Applying the projection Fin.val via congrArg to the profile equality P(f, σ(i)) = P(g, i) shows that the counts of true vertices in these two blocks are identical.
uses
congrArg,Fin.valhave hc (i : Fin m) : ((Finset.univ : Finset (Fin r)).filter (fun j => g i j = true)).card = ((Finset.univ : Finset (Fin r)).filter (fun j => f (σ i) j = true)).card := by exact (congrArg Fin.val (hσ i)).symm
For each block i and each boolean color b, the number of vertices with color b in block i under g equals the number in block σ(i) under f.
We distinguish cases on the boolean value b. For b = true, the counts are equal by the previous step. For b = false, the number of false vertices in a block of size r is r minus the number of true vertices, using Finset.card_filter_add_card_filter_not and Bool.not_eq_true; since both blocks have size r and matching true counts, their false counts are equal by linear arithmetic.
uses
Fintype.card_subtype,Finset.card_filter_add_card_filter_not,Bool.not_eq_truehave hbool (i : Fin m) (b : Bool) : Fintype.card {j // g i j = b} = Fintype.card {j // f (σ i) j = b} := by simp only [Fintype.card_subtype] cases b with | true => exact hc i | false => have hg := Finset.card_filter_add_card_filter_not (s := (Finset.univ : Finset (Fin r))) (fun j => g i j = true) have hf := Finset.card_filter_add_card_filter_not (s := (Finset.univ : Finset (Fin r))) (fun j => f (σ i) j = true) simp only [Bool.not_eq_true] at hg hf have hh := hc i omega
For each block i, there is a permutation τ(i) of the vertices inside the block.
Since block i under g and block σ(i) under f have matching counts for both true and false vertices, Fintype.equivOfCardEq gives an equivalence between their respective color fibers. Gluing these with Equiv.ofFiberEquiv produces a vertex permutation τ(i) for each block i.
uses
Equiv.ofFiberEquiv,Fintype.equivOfCardEqlet τ (i : Fin m) : Equiv.Perm (Fin r) := Equiv.ofFiberEquiv (fun b => Fintype.equivOfCardEq (hbool i b))
The permutations σ and τ satisfy f(σ(i), τ(i)(j)) = g(i, j) for all blocks i and vertices j.
We supply σ and τ as the existential witnesses. By Equiv.ofFiberEquiv_map, the vertex permutation τ(i) preserves the color of every vertex j, yielding f(σ(i), τ(i)(j)) = g(i, j).
uses
Equiv.ofFiberEquiv_maprefine ⟨σ, τ, ?_⟩ intro i j exact Equiv.ofFiberEquiv_map _ j
Bool.not_eq_true- For a boolean b, not (b = true) is equivalent to b = false.
congrArg- Applying a function to equal inputs yields equal outputs.
Equiv.ofFiberEquiv- Given maps f : α → γ and g : β → γ, a family of bijections between their fibers f⁻¹(c) ≃ g⁻¹(c) for all c induces an equivalence α ≃ β.
Equiv.ofFiberEquiv_map- The equivalence constructed by Equiv.ofFiberEquiv maps each fiber f⁻¹(c) to the fiber g⁻¹(c), so g(e(a)) = f(a).
Fin.ext_iff- Two elements of Fin n are equal if and only if their underlying natural numbers are equal.
Fin.val_mk- The underlying natural number of a bounded index ⟨m, h⟩ in Fin n is m.
Fin.val- The projection mapping an element of Fin n to its underlying natural number.
Finset.card_filter_add_card_filter_not- The number of elements of a finite set s satisfying a predicate p plus the number of elements in s satisfying ¬p equals the cardinality of s.
Finset.card_filter_le- The cardinality of a subset obtained by filtering a finite set is at most the cardinality of the original set.
Fintype.card_subtype- The cardinality of a subtype {x // p x} equals the cardinality of the filtered finset of elements satisfying p.
Fintype.equivOfCardEq- Any two finite types with the same cardinality are equivalent (there is a bijection between them).
Nat.lt_succ_of_le- If n ≤ m, then n < m + 1.
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
Choose a tactic — a marked line — to see the goals Lean had before and after it, as in Lean’s infoview. Step with ← → or j k.
theorem op1525_equal_block_color_profiles_match (m r : ℕ) (f g : Fin m → Fin r → Bool) (hprofile : ∀ k : Fin (r + 1), ((Finset.univ : Finset (Fin m)).filter (fun i => ((Finset.univ : Finset (Fin r)).filter (fun j => f i j = true)).card = k.val)).card = ((Finset.univ : Finset (Fin m)).filter (fun i => ((Finset.univ : Finset (Fin r)).filter (fun j => g i j = true)).card = k.val)).card) : ∃ σ : Equiv.Perm (Fin m), ∃ τ : Fin m → Equiv.Perm (Fin r), ∀ i j, f (σ i) (τ i j) = g i j := by classical let P (h : Fin m → Fin r → Bool) (i : Fin m) : Fin (r + 1) := ⟨((Finset.univ : Finset (Fin r)).filter (fun j => h i j = true)).card, Nat.lt_succ_of_le (by simpa using Finset.card_filter_le (Finset.univ : Finset (Fin r)) (fun j => h i j = true))⟩ have hcard (k : Fin (r + 1)) : Fintype.card {i // P g i = k} = Fintype.card {i // P f i = k} := by simp only [Fintype.card_subtype] simpa only [P, Fin.ext_iff, Fin.val_mk] using (hprofile k).symm let σ : Equiv.Perm (Fin m) := Equiv.ofFiberEquiv (fun k => Fintype.equivOfCardEq (hcard k)) have hσ (i : Fin m) : P f (σ i) = P g i := Equiv.ofFiberEquiv_map _ i have hc (i : Fin m) : ((Finset.univ : Finset (Fin r)).filter (fun j => g i j = true)).card = ((Finset.univ : Finset (Fin r)).filter (fun j => f (σ i) j = true)).card := by exact (congrArg Fin.val (hσ i)).symm have hbool (i : Fin m) (b : Bool) : Fintype.card {j // g i j = b} = Fintype.card {j // f (σ i) j = b} := by simp only [Fintype.card_subtype] cases b with | true => exact hc i | false => have hg := Finset.card_filter_add_card_filter_not (s := (Finset.univ : Finset (Fin r))) (fun j => g i j = true) have hf := Finset.card_filter_add_card_filter_not (s := (Finset.univ : Finset (Fin r))) (fun j => f (σ i) j = true) simp only [Bool.not_eq_true] at hg hf have hh := hc i omega let τ (i : Fin m) : Equiv.Perm (Fin r) := Equiv.ofFiberEquiv (fun b => Fintype.equivOfCardEq (hbool i b)) refine ⟨σ, τ, ?_⟩ intro i j exact Equiv.ofFiberEquiv_map _ j