matroid_hidden_rainbow_partition_cover_lower
Fix natural numbers n, k and m, including zero. For each output l in Fin m, let part(l) assign each row of Fin n a block index in Fin n, and let label(l) assign it a prescribed color in Fin k. Assume label(l) is injective on each fiber of part(l). Assume further that for every coloring f from Fin n to Fin k, some output l and a permutation of each fiber realize f by assigning row x the prescribed label of its permuted row in the same fiber. Then the nth power of the rational harmonic sum of the reciprocals of 1 through k is at most the natural number m viewed as a rational.
Statement
theorem matroid_hidden_rainbow_partition_cover_lower (n k m : ℕ) (part : Fin m → Fin n → Fin n) (label : Fin m → Fin n → Fin k) (hrainbow : ∀ l x y, part l x = part l y → label l x = label l y → x = y) (hcover : ∀ f : Fin n → Fin k, ∃ l : Fin m, ∃ p : (c : Fin n) → Equiv.Perm {x : Fin n // part l x = c}, ∀ x, f x = label l ((p (part l x) ⟨x,rfl⟩).val)) : (∑ i : Fin k, (i.val+1 : ℚ)⁻¹)^n ≤ m
- Related work
- Hidden full-fiber route to OP-1998, based on https://arxiv.org/abs/2611.23624. The certificate model and harmonic counting argument are developed in state/campaigns/matroid-in1302/rainbow.md. For the different exact counting objective with ordinary pooled tests see https://arxiv.org/abs/2001.00441.
- Verified
- 28 Nov 2026
- Axioms
Classical.choiceQuot.soundpropext- Built on 1
- g$g(S,M) = \dim_{\mathbb{F}_p}(S^{\perp}_M) - \dim_{\mathbb{F}_p}(S_M)$.
Read back from the Lean
Given natural numbers $n$, $k$, and $m$, a family of partition functions part : Fin m → Fin n → Fin n, and a family of labeling functions label : Fin m → Fin n → Fin k, assume:
1. hrainbow: For all $l \in \text{Fin } m$ and all $x, y \in \text{Fin } n$, if $\text{part } l\ x = \text{part } l\ y$ and $\text{label } l\ x = \text{label } l\ y$, then $x = y$ (i.e., on each part/fiber of $\text{part } l$, the labeling function $\text{label } l$ is injective).
2. hcover: For every function $f : \text{Fin } n \to \text{Fin } k$, there exists an index $l \in \text{Fin } m$ and a family of permutations $p$ indexed by $c \in \text{Fin } n$, where each $p(c)$ is a permutation of the fiber $\{x : \text{Fin } n \mid \text{part } l\ x = c\}$, such that for all $x \in \text{Fin } n$, $f(x)$ is equal to $\text{label } l$ applied to the image of $x$ under the permutation $p(\text{part } l\ x)$.
Then:
$$\left(\sum_{i \in \text{Fin } k} \frac{1}{i.val + 1}\right)^n \le m$$
holds in the rational numbers $\mathbb{Q}$ (that is, the $n$-th power of the $k$-th harmonic sum $H_k = \sum_{j=1}^k \frac{1}{j}$ is less than or equal to $m$).
Written by a model that saw only the Lean, never the English above. If the two disagree, that is worth a challenge.
The proof, explained
We assign each color i ∈ {0, ..., k-1} the weight w(i) = 1/(i+1) and each coloring f the product weight W(f) = ∏_x w(f(x)), so that the total weight of all colorings equals the nth power of the harmonic sum H_k^n. By hypothesis, every coloring is generated by choosing an output l ∈ Fin m and permuting elements within the fibers of part(l). Because permuting within fibers preserves the multiset of labels and hence the weight W, and because the labeling is injective on each fiber, an auxiliary factorial inequality (rainbow_block) shows that all permutations for any single output l contribute at most 1 in total. Surjectivity of the generator then implies that H_k^n is bounded by the sum of contributions over all m outputs, yielding H_k^n ≤ m.
The inequality |s|! ≤ ∏_{i ∈ s} (i + 1) holds in the base case s = ∅.
We proceed by strong induction on the finite set s. When s is empty, |s|! = 0! = 1 and the empty product is 1, so the inequality simplifies to 1 ≤ 1.
uses
Finset.strongInductionOn,Finset.not_nonempty_iff_eq_empty.mpclassical induction s using Finset.strongInductionOn with | _ s ih => by_cases hs : s.Nonempty swap · simp [Finset.not_nonempty_iff_eq_empty.mp hs]
When s is nonempty with maximum element z, we have |s| ≤ z + 1 and the induction hypothesis applies to s \ {z}.
Let z = max(s) ∈ s. Every element i ∈ s satisfies i ≤ z < z + 1, so s ⊆ {0, ..., z}, which gives |s| ≤ z + 1. Removing z yields a strict subset s \ {z} ⊂ s with cardinality |s| - 1, to which the induction hypothesis applies.
uses
Finset.mem_range.mpr,Nat.lt_succ_of_le,Finset.card_le_card,Finset.erase_ssubset,Finset.card_erase_add_onelet z := s.max' hs have hz : z ∈ s := s.max'_mem hs have hle : s.card ≤ z+1 := by have hsub : s ⊆ Finset.range (z+1) := fun i hi => Finset.mem_range.mpr (Nat.lt_succ_of_le (s.le_max' i hi)) simpa using Finset.card_le_card hsub have hsmall := ih (s.erase z) (Finset.erase_ssubset hz) have hcard := Finset.card_erase_add_one hz
The inequality |s|! ≤ ∏_{i ∈ s} (i + 1) holds for any nonempty finite set of natural numbers s.
We express |s|! as (|s \ {z}| + 1) * |s \ {z}|!. Using |s \ {z}| + 1 = |s| ≤ z + 1 and the induction hypothesis, we multiply the two inequalities to obtain |s|! ≤ (z + 1) * ∏_{i ∈ s \ {z}} (i + 1). Recombining z + 1 into the product completes the induction step.
uses
Nat.factorial_succ,Nat.mul_le_mul,Finset.mul_prod_erasecalc s.card.factorial = ((s.erase z).card+1) * (s.erase z).card.factorial := by conv_lhs => rw [← hcard,Nat.factorial_succ] _ ≤ (z+1) * (∏ i ∈ s.erase z, (i+1)) := Nat.mul_le_mul (by omega) hsmall _ = ∏ i ∈ s, (i+1) := Finset.mul_prod_erase _ _ hz
For any injective function h : α → Fin k, (|α|!) * ∏_{x ∈ α} (h(x) + 1)⁻¹ ≤ 1.
The map g sending x to the natural value of h(x) is injective. Applying rainbow_factorial to the image g(α) yields |g(α)|! ≤ ∏_{i ∈ g(α)} (i + 1). Injectivity identifies |g(α)| with |α| and the product over the image with the product over α. Inverting the product and clearing denominators over the rationals yields the claimed upper bound of 1.
uses
rainbow_factorial,Finset.card_image_of_injective,Finset.card_univ,Finset.prod_image,Finset.prod_inv_distrib,mul_inv_le_iff₀,one_mulclassical let g : α → ℕ := fun x => (h x).val have hg : Function.Injective g := Fin.val_injective.comp hinj have hnat := rainbow_factorial (Finset.univ.image g) rw [Finset.card_image_of_injective _ hg,Finset.card_univ,Finset.prod_image hg.injOn] at hnat rw [Finset.prod_inv_distrib, mul_inv_le_iff₀ (by positivity), one_mul] exact_mod_cast hnat
The assignment map gen, sending an output l and fiber permutations p to the realized coloring, is surjective.
We assign each color i the weight w(i) = 1/(i+1) and each coloring f the product weight W(f) = ∏_x w(f(x)). For each output l, let P(l) be the permutations preserving the fibers of part(l). The cover assumption states that every coloring f is realized by some output l and fiber permutations p, which shows that gen is surjective.
classical let w (i : Fin k) : ℚ := (i.val+1 : ℚ)⁻¹ let W (f : Fin n → Fin k) := ∏ x, w (f x) let F (l : Fin m) (c : Fin n) := {x : Fin n // part l x = c} let P (l : Fin m) := (c : Fin n) → Equiv.Perm (F l c) let gen (y : (l : Fin m) × P l) (x : Fin n) := label y.1 ((y.2 (part y.1 x) ⟨x,rfl⟩).val) have hgen : Function.Surjective gen := by intro f obtain ⟨l,p,h⟩ := hcover f exact ⟨⟨l,p⟩,(funext h).symm⟩
Fiber permutations preserve coloring weights: W(gen(l, p)) = W(label(l)).
Permuting elements within each fiber of part(l) induces a bijection of Fin n via the canonical fiber decomposition Equiv.sigmaFiberEquiv. Because a product of weights over a finite type is invariant under reordering by a bijection, the total weight of the generated coloring is identical to that of label(l).
uses
Equiv.sigmaFiberEquiv,Equiv.sigmaCongrRight,Equiv.prod_comphave heq (l : Fin m) (p : P l) : W (gen ⟨l,p⟩) = W (label l) := by let e := Equiv.sigmaFiberEquiv (part l) let perm := e.symm.trans ((Equiv.sigmaCongrRight p).trans e) exact Equiv.prod_comp perm (fun x => w (label l x))
For each output l, the sum of weights over all fiber permutations satisfies ∑_{p ∈ P(l)} W(gen(l, p)) ≤ 1.
Since the weight is constant over all p ∈ P(l), the sum equals |P(l)| * W(label(l)). The size |P(l)| is the product of factorials of the fiber sizes. Factoring W(label(l)) fiberwise, the whole expression becomes a product over all fiber blocks c of (|F(l, c)|!) * ∏_{x ∈ F(l, c)} w(label(l, x)). The rainbow hypothesis ensures label(l) is injective on each fiber, so rainbow_block bounds each factor by 1, making the overall product at most 1.
uses
Finset.sum_const,Finset.card_univ,nsmul_eq_mul,Fintype.card_pi,Fintype.card_perm,Nat.cast_prod,Fintype.prod_fiberwise,Finset.prod_mul_distrib,Finset.prod_le_one,rainbow_block,Subtype.exthave hleaf (l : Fin m) : (∑ p : P l, W (gen ⟨l,p⟩)) ≤ 1 := by simp only [heq,Finset.sum_const,Finset.card_univ,nsmul_eq_mul] have hcard : Fintype.card (P l) = ∏ c, (Fintype.card (F l c)).factorial := by simp [P,Fintype.card_pi,Fintype.card_perm] rw [hcard,Nat.cast_prod] change (∏ c : Fin n, ((Fintype.card (F l c)).factorial : ℚ)) * (∏ x, w (label l x)) ≤ 1 rw [← Fintype.prod_fiberwise (part l) (fun x => w (label l x)),← Finset.prod_mul_distrib] apply Finset.prod_le_one · intro c _; dsimp [w]; positivity · intro c _ apply rainbow_block (fun x : F l c => label l x.val) intro x y hxy exact Subtype.ext (hrainbow l _ _ (x.property.trans y.property.symm) hxy)
The nth power of the harmonic sum is at most m: (∑_{i ∈ Fin k} (i + 1)⁻¹)^n ≤ m.
Expanding the nth power of the harmonic sum produces the sum of W(f) over all colorings f. Since gen is surjective, each fiber has cardinality at least 1, so W(f) is bounded by the sum of W(f) over all preimages of f. Summing over all f and re-indexing over pairs (l, p) converts this to a sum over outputs l of the fiber-permutation sums. Applying the leaf bound to each of the m outputs bounds the entire sum by ∑_{l ∈ Fin m} 1 = m.
uses
Fintype.sum_pow,Finset.sum_le_sum,Nat.succ_le_of_lt,Fintype.card_pos,nsmul_eq_mul,mul_le_mul_of_nonneg_right,Fintype.sum_fiberwise',Fintype.sum_sigmacalc (∑ i : Fin k, (i.val+1 : ℚ)⁻¹)^n = ∑ f : Fin n → Fin k, W f := Fintype.sum_pow w n _ ≤ ∑ f : Fin n → Fin k, ∑ _y : {y // gen y = f}, W f := by apply Finset.sum_le_sum intro f _ obtain ⟨y,hy⟩ := hgen f haveI : Nonempty {y // gen y = f} := ⟨⟨y,hy⟩⟩ have hcard : (1 : ℚ) ≤ Fintype.card {y // gen y = f} := by exact_mod_cast Nat.succ_le_of_lt (Fintype.card_pos) have hw : 0 ≤ W f := by dsimp [W,w]; positivity simpa [nsmul_eq_mul] using mul_le_mul_of_nonneg_right hcard hw _ = ∑ y, W (gen y) := Fintype.sum_fiberwise' gen W _ = ∑ l : Fin m, ∑ p : P l, W (gen ⟨l,p⟩) := Fintype.sum_sigma _ _ ≤ ∑ _l : Fin m, (1 : ℚ) := Finset.sum_le_sum fun l _ => hleaf l _ = m := by simp
Finset.strongInductionOn- A principle of strong induction on finite sets: a property holds for a finite set if, whenever it holds for all strict subsets, it holds for the set itself.
Finset.not_nonempty_iff_eq_empty.mp- If a finite set is not nonempty, it is equal to the empty set.
Finset.mem_range.mpr- A natural number i is in Finset.range k if and only if i < k.
Nat.lt_succ_of_le- If n ≤ m, then n < m + 1.
Finset.card_le_card- If s is a subset of t, then the cardinality of s is at most the cardinality of t.
Finset.erase_ssubset- Removing an element belonging to a finite set yields a strictly smaller subset.
Finset.card_erase_add_one- Removing an element from a finite set s decreases its cardinality by 1.
Nat.factorial_succ- For any natural number n, (n + 1)! = (n + 1) * n!.
Nat.mul_le_mul- Multiplication of natural numbers preserves inequalities: if a ≤ b and c ≤ d, then ac ≤ bd.
Finset.mul_prod_erase- Multiplying f(a) by the product of f over s \ {a} reconstructs the product of f over s.
rainbow_factorial- For any finite set of natural numbers s, |s|! is at most the product of i + 1 over i ∈ s.
Finset.card_image_of_injective- An injective function preserves the cardinality of the image of a finite set.
Finset.card_univ- The cardinality of the universal finset on a finite type equals the cardinality of the type.
Finset.prod_image- The product of a function over the image of a set under an injective map equals the product of their composition over the original set.
Finset.prod_inv_distrib- The product of inverses over a finite set equals the inverse of the product.
mul_inv_le_iff₀- For a positive element c in a linearly ordered group with zero, b * c⁻¹ ≤ a if and only if b ≤ a * c.
one_mul- Multiplying 1 by any element leaves it unchanged.
Equiv.sigmaFiberEquiv- A type is canonically equivalent to the sigma type of the fibers of any map defined on it.
Equiv.sigmaCongrRight- A family of equivalences between fibers induces an equivalence between the total sigma types.
Equiv.prod_comp- Reindexing a finite product by a bijection does not change the product.
Finset.sum_const- Summing a constant value over a finite set equals the cardinality of the set times that constant.
nsmul_eq_mul- Scalar multiplication by a natural number n in a semiring is equal to multiplication by n.
Fintype.card_pi- The cardinality of a dependent function type over a finite domain is the product of the cardinalities of the codomains.
Fintype.card_perm- The number of permutations of a finite type is the factorial of its cardinality.
Nat.cast_prod- The natural cast into a semiring commutes with finite products.
Fintype.prod_fiberwise- A finite product over a domain factors as the product over the codomain of the products over each fiber.
Finset.prod_mul_distrib- The product of pairwise products is the product of the first factors times the product of the second factors.
Finset.prod_le_one- If every term in a finite product is non-negative and at most 1, the product is at most 1.
rainbow_block- For any injective map from a finite type to Fin k, the factorial of the domain size times the product of reciprocals of (h(x) + 1) is at most 1.
Subtype.ext- Two elements of a subtype are equal if their underlying values are equal.
Fintype.sum_pow- The nth power of a sum over a finite type expands as the sum over all functions of the product of terms.
Finset.sum_le_sum- If f(i) ≤ g(i) for all elements in a finite set, then the sum of f is at most the sum of g.
Nat.succ_le_of_lt- If n < m for natural numbers, then n + 1 ≤ m.
Fintype.card_pos- A nonempty finite type has strictly positive cardinality.
mul_le_mul_of_nonneg_right- Multiplying an inequality on the right by a non-negative element preserves the inequality.
Fintype.sum_fiberwise'- Summing a function over the fibers of a map reconstructs the sum over the domain.
Fintype.sum_sigma- A sum over a sigma type equals the iterated sum over the index and the fiber.
- The proof relies on two private helper lemmas: `rainbow_factorial`, which proves |s|! ≤ ∏_{i ∈ s} (i+1) for any finite subset of natural numbers, and `rainbow_block`, which uses this bound to show that an injective labeling on a block contributes at most 1 to the product.
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.
open scoped BigOperatorsprivate theorem rainbow_factorial (s : Finset ℕ) : s.card.factorial ≤ ∏ i ∈ s, (i+1) := by classical induction s using Finset.strongInductionOn with | _ s ih => by_cases hs : s.Nonempty swap · simp [Finset.not_nonempty_iff_eq_empty.mp hs] let z := s.max' hs have hz : z ∈ s := s.max'_mem hs have hle : s.card ≤ z+1 := by have hsub : s ⊆ Finset.range (z+1) := fun i hi => Finset.mem_range.mpr (Nat.lt_succ_of_le (s.le_max' i hi)) simpa using Finset.card_le_card hsub have hsmall := ih (s.erase z) (Finset.erase_ssubset hz) have hcard := Finset.card_erase_add_one hz calc s.card.factorial = ((s.erase z).card+1) * (s.erase z).card.factorial := by conv_lhs => rw [← hcard,Nat.factorial_succ] _ ≤ (z+1) * (∏ i ∈ s.erase z, (i+1)) := Nat.mul_le_mul (by omega) hsmall _ = ∏ i ∈ s, (i+1) := Finset.mul_prod_erase _ _ hzprivate theorem rainbow_block {α : Type*} [Fintype α] {k : ℕ} (h : α → Fin k) (hinj : Function.Injective h) : (Fintype.card α).factorial * (∏ x, ((h x).val+1 : ℚ)⁻¹) ≤ 1 := by classical let g : α → ℕ := fun x => (h x).val have hg : Function.Injective g := Fin.val_injective.comp hinj have hnat := rainbow_factorial (Finset.univ.image g) rw [Finset.card_image_of_injective _ hg,Finset.card_univ,Finset.prod_image hg.injOn] at hnat rw [Finset.prod_inv_distrib, mul_inv_le_iff₀ (by positivity), one_mul] exact_mod_cast hnattheorem matroid_hidden_rainbow_partition_cover_lower (n k m : ℕ) (part : Fin m → Fin n → Fin n) (label : Fin m → Fin n → Fin k) (hrainbow : ∀ l x y, part l x = part l y → label l x = label l y → x = y) (hcover : ∀ f : Fin n → Fin k, ∃ l : Fin m, ∃ p : (c : Fin n) → Equiv.Perm {x : Fin n // part l x = c}, ∀ x, f x = label l ((p (part l x) ⟨x,rfl⟩).val)) : (∑ i : Fin k, (i.val+1 : ℚ)⁻¹)^n ≤ m := by classical let w (i : Fin k) : ℚ := (i.val+1 : ℚ)⁻¹ let W (f : Fin n → Fin k) := ∏ x, w (f x) let F (l : Fin m) (c : Fin n) := {x : Fin n // part l x = c} let P (l : Fin m) := (c : Fin n) → Equiv.Perm (F l c) let gen (y : (l : Fin m) × P l) (x : Fin n) := label y.1 ((y.2 (part y.1 x) ⟨x,rfl⟩).val) have hgen : Function.Surjective gen := by intro f obtain ⟨l,p,h⟩ := hcover f exact ⟨⟨l,p⟩,(funext h).symm⟩ have heq (l : Fin m) (p : P l) : W (gen ⟨l,p⟩) = W (label l) := by let e := Equiv.sigmaFiberEquiv (part l) let perm := e.symm.trans ((Equiv.sigmaCongrRight p).trans e) exact Equiv.prod_comp perm (fun x => w (label l x)) have hleaf (l : Fin m) : (∑ p : P l, W (gen ⟨l,p⟩)) ≤ 1 := by simp only [heq,Finset.sum_const,Finset.card_univ,nsmul_eq_mul] have hcard : Fintype.card (P l) = ∏ c, (Fintype.card (F l c)).factorial := by simp [P,Fintype.card_pi,Fintype.card_perm] rw [hcard,Nat.cast_prod] change (∏ c : Fin n, ((Fintype.card (F l c)).factorial : ℚ)) * (∏ x, w (label l x)) ≤ 1 rw [← Fintype.prod_fiberwise (part l) (fun x => w (label l x)),← Finset.prod_mul_distrib] apply Finset.prod_le_one · intro c _; dsimp [w]; positivity · intro c _ apply rainbow_block (fun x : F l c => label l x.val) intro x y hxy exact Subtype.ext (hrainbow l _ _ (x.property.trans y.property.symm) hxy) calc (∑ i : Fin k, (i.val+1 : ℚ)⁻¹)^n = ∑ f : Fin n → Fin k, W f := Fintype.sum_pow w n _ ≤ ∑ f : Fin n → Fin k, ∑ _y : {y // gen y = f}, W f := by apply Finset.sum_le_sum intro f _ obtain ⟨y,hy⟩ := hgen f haveI : Nonempty {y // gen y = f} := ⟨⟨y,hy⟩⟩ have hcard : (1 : ℚ) ≤ Fintype.card {y // gen y = f} := by exact_mod_cast Nat.succ_le_of_lt (Fintype.card_pos) have hw : 0 ≤ W f := by dsimp [W,w]; positivity simpa [nsmul_eq_mul] using mul_le_mul_of_nonneg_right hcard hw _ = ∑ y, W (gen y) := Fintype.sum_fiberwise' gen W _ = ∑ l : Fin m, ∑ p : P l, W (gen ⟨l,p⟩) := Fintype.sum_sigma _ _ ≤ ∑ _l : Fin m, (1 : ℚ) := Finset.sum_le_sum fun l _ => hleaf l _ = m := by simp