/-Copyright (c) 2026 Carles MarΓn. All rights reserved.Released under Apache 2.0 license as described in the file LICENSE.Authors: Carles MarΓn, Claude (AI assistant)-/module public import Mathlib.LinearAlgebra.Matrix.Permanentpublic import Mathlib.Analysis.SpecialFunctions.Pow.Realpublic import Mathlib.Analysis.SpecialFunctions.Log.NegMulLogpublic import Mathlib.Analysis.Convex.Jensenpublic import Mathlib.Data.Nat.Factorial.Basicpublic import Mathlib.Logic.Equiv.Optionpublic import Mathlib.Algebra.BigOperators.Group.Finset.Basicpublic import Mathlib.Algebra.BigOperators.Group.Finset.Lemmaspublic import Mathlib.Algebra.BigOperators.Fieldpublic import Mathlib.Algebra.Order.BigOperators.Group.Finsetpublic import Mathlib.Tactic.Ringpublic import Mathlib.Tactic.Linarithpublic import Mathlib.Tactic.Positivitypublic import Mathlib.Tactic.FieldSimp /-!# BrΓ©gman's theorem on permanents of (0,1)-matrices For an `n Γ n` `(0,1)`-matrix with non-zero row sums `rα΅’`, `per A β€ βα΅’ (rα΅’!)^(1/rα΅’)` (BrΓ©gman 1973,conjectured by Minc; Theorem of the Day). Proof: Schrijver's induction in logarithmic form,`P log P β€ P Ξ£α΅’ log(rα΅’!)/rα΅’` for `P = per A` (zero rows allowed), from a single Jensen inequalityfor `x log x`, the fibres of `Ο β¦ Ο(i)` (permanents of minors), the counts `r_k β 1` and `n β r_k`over a fixed permutation, and `log r + (n β r)F(r) + (r β 1)F(r β 1) = nF(r)`. ## Main results * `Bregman.log_bound`: P log P β€ P Ξ£α΅’ log(rα΅’!)/rα΅’ for every (0,1)-matrix (zero rows allowed)* `Bregman.permanent_le`: BrΓ©gman: per A β€ βα΅’ (rα΅’!)^(1/rα΅’) ## References * R. Whitty, Theorem of the Day, Β«Bregman's TheoremΒ» (CombinatorialTheory/Bregman).* L. M. BrΓ©gman, Some properties of nonnegative matrices and their permanents, Soviet Math. Dokl. 14 (1973); A. Schrijver, A short proof of Minc's conjecture, J. Combin. Theory Ser. A 25 (1978) 80β83.-/ @[expose] public section namespace Bregman open Finset /-! ### Fibres of `Ο β¦ Ο i` and minors -/ section Fibre variable {I J : Type*} [Fintype I] [Fintype J] [DecidableEq I] [DecidableEq J] /-- The admissible bijections of a `(0,1)`-matrix. -/def adm (A : I β J β β) : Finset (I β J) := univ.filter fun Ο => β i, A i (Ο i) = 1 /-- The minor of `A` obtained by deleting row `i` and column `j`. -/def minor (A : I β J β β) (i : I) (j : J) : {k // k β i} β {l // l β j} β β := fun k l => A k l omit [Fintype I] [Fintype J] in/-- Extend a bijection of the minors to a bijection sending `i` to `j`. -/def extendEquiv (i : I) (j : J) (Ο : {k // k β i} β {l // l β j}) : I β J := (Equiv.optionSubtypeNe i).symm.trans ((Equiv.optionCongr Ο).trans (Equiv.optionSubtypeNe j)) omit [Fintype I] [Fintype J] inlemma extendEquiv_self (i : I) (j : J) (Ο : {k // k β i} β {l // l β j}) : extendEquiv i j Ο i = j := by simp [extendEquiv] omit [Fintype I] [Fintype J] inlemma extendEquiv_of_ne (i : I) (j : J) (Ο : {k // k β i} β {l // l β j}) (k : I) (hk : k β i) : extendEquiv i j Ο k = (Ο β¨k, hkβ©).1 := by simp [extendEquiv, Equiv.optionSubtypeNe_symm_of_ne hk] omit [Fintype I] [Fintype J] [DecidableEq I] [DecidableEq J] in/-- Restrict a bijection with `Ο i = j` to the minors. -/def restrictEquiv (Ο : I β J) (i : I) (j : J) (h : Ο i = j) : {k // k β i} β {l // l β j} := Ο.subtypeEquiv (fun k => by rw [β h]; simp) /-- (F1) The fibre `{Ο admissible | Ο i = j}` has `a_{ij} * per(minor)` elements. -/lemma fiber_card (A : I β J β β) (hA : β i j, A i j β€ 1) (i : I) (j : J) : ((adm A).filter fun Ο => Ο i = j).card = A i j * (adm (minor A i j)).card := by rcases Nat.le_one_iff_eq_zero_or_eq_one.1 (hA i j) with h0 | h1 Β· rw [h0, zero_mul, Finset.card_eq_zero, Finset.filter_eq_empty_iff] intro Ο hΟ hΟi have := (mem_filter.1 hΟ).2 i rw [hΟi, h0] at this omega Β· rw [h1, one_mul] refine Finset.card_bij (fun Ο hΟ => restrictEquiv Ο i j (mem_filter.1 hΟ).2) ?_ ?_ ?_ Β· intro Ο hΟ have h := (mem_filter.1 (mem_filter.1 hΟ).1).2 simp only [adm, mem_filter, mem_univ, true_and] intro k exact h k.1 Β· intro Ο hΟ Ο' hΟ' he have h1 := (mem_filter.1 hΟ).2 have h2 := (mem_filter.1 hΟ').2 ext k by_cases hk : k = i Β· subst hk; rw [h1, h2] Β· have := congrArg (fun e => (e β¨k, hkβ©).1) he exact this Β· intro Ο hΟ have hex : extendEquiv i j Ο β (adm A).filter fun Ο => Ο i = j := by simp only [adm, mem_filter, mem_univ, true_and] at hΟ β’ refine β¨fun k => ?_, extendEquiv_self i j Οβ© by_cases hk : k = i Β· subst hk; rw [extendEquiv_self]; exact h1 Β· rw [extendEquiv_of_ne i j Ο k hk]; exact hΟ β¨k, hkβ© refine β¨extendEquiv i j Ο, hex, ?_β© ext k exact extendEquiv_of_ne i j Ο k.1 k.2 /-- (F3) Summing over admissible `Ο` a function of `Ο i`: group by the fibres. -/lemma sum_adm_eq (A : I β J β β) (hA : β i j, A i j β€ 1) (i : I) (G : J β β) : β Ο β adm A, G (Ο i) = β j, ((A i j : β) * ((adm (minor A i j)).card : β)) * G j := by rw [β Finset.sum_fiberwise_of_maps_to (s := adm A) (t := univ) (g := fun Ο => Ο i) (fun _ _ => mem_univ _)] refine Finset.sum_congr rfl fun j _ => ?_ rw [Finset.sum_congr rfl (g := fun _ => G j) (fun Ο hΟ => by rw [(mem_filter.1 hΟ).2]), Finset.sum_const, nsmul_eq_mul, fiber_card A hA i j] push_cast ring /-- (F2) The number of admissible bijections splits along row `i`. -/lemma card_adm_eq (A : I β J β β) (hA : β i j, A i j β€ 1) (i : I) : ((adm A).card : β) = β j, (A i j : β) * ((adm (minor A i j)).card : β) := by have := sum_adm_eq A hA i (fun _ => 1) simpa using this omit [Fintype J] [DecidableEq J] inlemma card_subtype_ne (i : I) : Fintype.card {k // k β i} = Fintype.card I - 1 := by rw [Fintype.card_subtype, Finset.filter_ne', Finset.card_erase_of_mem (mem_univ i), Finset.card_univ] end Fibre /-! ### Analytic lemmas -/ /-- `Ξ¦(x) = x log x`. -/noncomputable def Phi (x : β) : β := x * Real.log x /-- `F(m) = log(m!) / m`. -/noncomputable def F (m : β) : β := Real.log (m.factorial : β) / m lemma mul_F (m : β) : (m : β) * F m = Real.log (m.factorial : β) := by rcases Nat.eq_zero_or_pos m with rfl | hm Β· simp [F] Β· unfold F have : (m : β) β 0 := by positivity field_simp /-- (L2) `log r + (N - r) F(r) + (r - 1) F(r - 1) = N F(r)`. -/lemma L2 (r : β) (hr : 1 β€ r) (N : β) : Real.log r + (N - r) * F r + ((r : β) - 1) * F (r - 1) = N * F r := by have h1 : ((r - 1 : β) : β) = (r : β) - 1 := by rw [Nat.cast_sub hr]; simp have h2 : (r : β) * F r = Real.log r + ((r : β) - 1) * F (r - 1) := by rw [β h1, mul_F, mul_F] obtain β¨s, rflβ© : β s, r = s + 1 := β¨r - 1, by omegaβ© simp only [Nat.add_sub_cancel, Nat.factorial_succ] push_cast rw [Real.log_mul (by positivity) (by positivity)] linear_combination (-1 : β) * h2 /-- (J) Jensen for `x log x` with weights `a_j / r`. -/lemma jensen {ΞΉ : Type*} (t : Finset ΞΉ) (a c : ΞΉ β β) (ha : β j β t, 0 β€ a j) (hc : β j β t, 0 β€ c j) (r : β) (hr : 0 < r) (hsum : β j β t, a j = r) (hP : 0 < β j β t, a j * c j) : Phi (β j β t, a j * c j) β€ (β j β t, a j * c j) * Real.log r + β j β t, a j * Phi (c j) := by set P := β j β t, a j * c j with hPdef set S := β j β t, a j * Phi (c j) with hSdef have hJ := Real.convexOn_mul_log.map_sum_le (t := t) (w := fun j => a j / r) (p := c) (fun j hj => div_nonneg (ha j hj) hr.le) (by rw [β Finset.sum_div, hsum, div_self hr.ne']) (fun j hj => Set.mem_Ici.2 (hc j hj)) simp only [smul_eq_mul] at hJ have e1 : β j β t, a j / r * c j = P / r := by rw [hPdef, Finset.sum_div] exact Finset.sum_congr rfl fun j _ => by ring have e2 : β j β t, a j / r * (c j * Real.log (c j)) = S / r := by rw [hSdef, Finset.sum_div] exact Finset.sum_congr rfl fun j _ => by unfold Phi; ring rw [e1, e2, Real.log_div hP.ne' hr.ne'] at hJ have h3 : P * Real.log P - P * Real.log r β€ S := by calc P * Real.log P - P * Real.log r = r * (P / r * (Real.log P - Real.log r)) := by field_simp _ β€ r * (S / r) := mul_le_mul_of_nonneg_left hJ hr.le _ = S := by field_simp unfold Phi linarith /-! ### Row counts -/ section Rows variable {I J : Type*} [Fintype I] [Fintype J] [DecidableEq I] [DecidableEq J] omit [DecidableEq J] in/-- (C2) For an admissible `Ο` and a row `k`:`Ξ£_{i β k} F(r_k - a_{k,Ο i}) = (N - r_k) F(r_k) + (r_k - 1) F(r_k - 1)`. -/lemma row_count (A : I β J β β) (hA : β i j, A i j β€ 1) (Ο : I β J) (hΟ : β i, A i (Ο i) = 1) (k : I) : β i β univ.erase k, F (β j, A k j - A k (Ο i)) = ((Fintype.card I : β) - (β j, A k j : β)) * F (β j, A k j) + (((β j, A k j : β) : β) - 1) * F (β j, A k j - 1) := by set r : β := β j, A k j with hr have hs : 1 + β i β univ.erase k, A k (Ο i) = r := by have h := Finset.add_sum_erase univ (fun i => A k (Ο i)) (mem_univ k) have h2 : β i, A k (Ο i) = r := Equiv.sum_comp Ο (A k) rw [hΟ k] at h rw [β h2, β h] have hterm : β i β univ.erase k, F (r - A k (Ο i)) = F r + (A k (Ο i) : β) * (F (r - 1) - F r) := by intro i _ rcases Nat.le_one_iff_eq_zero_or_eq_one.1 (hA k (Ο i)) with h0 | h1 Β· rw [h0]; simp Β· rw [h1]; simp rw [Finset.sum_congr rfl hterm, Finset.sum_add_distrib, Finset.sum_const, β Finset.sum_mul, Finset.card_erase_of_mem (mem_univ k), Finset.card_univ, nsmul_eq_mul] have hcard : 1 β€ Fintype.card I := Fintype.card_pos_iff.2 β¨kβ© have hS : ((β i β univ.erase k, A k (Ο i) : β) : β) = (r : β) - 1 := by have : β i β univ.erase k, A k (Ο i) = r - 1 := by omega rw [this, Nat.cast_sub (by omega)]; simp rw [β Nat.cast_sum, hS, Nat.cast_sub hcard] push_cast ring /-- Sum of `F` over the rows of a minor. -/lemma minor_sum_F (A : I β J β β) (i : I) (j : J) : β k : {k // k β i}, F (β l, minor A i j k l) = β k β univ.erase i, F (β l, A k l - A k j) := by have hsub : β k β univ.erase i, F (β l, A k l - A k j) = β k : {k // k β i}, F (β l, A k l - A k j) := Finset.sum_subtype (univ.erase i) (p := fun k => k β i) (by simp) (fun k => F (β l, A k l - A k j)) rw [hsub] refine Finset.sum_congr rfl fun k _ => ?_ congr 1 have h1 : β l : {l // l β j}, minor A i j k l = β l β univ.erase j, A k l := by exact (Finset.sum_subtype (univ.erase j) (p := fun l => l β j) (by simp) (fun l => A k.1 l)).symm have h2 := Finset.add_sum_erase univ (fun l => A k l) (mem_univ j) rw [h1] omega /-- The `i`-th row bound after the induction hypothesis. -/noncomputable def Gfun (A : I β J β β) (i : I) (j : J) : β := β k β univ.erase i, F (β l, A k l - A k j) /-- The double sum over admissible bijections and rows. -/lemma double_sum (A : I β J β β) (hA : β i j, A i j β€ 1) : β i, β Ο β adm A, Gfun A i (Ο i) = ((adm A).card : β) * β k, (((Fintype.card I : β) - (β j, A k j : β)) * F (β j, A k j) + (((β j, A k j : β) : β) - 1) * F (β j, A k j - 1)) := by rw [Finset.sum_comm] have : β Ο β adm A, β i, Gfun A i (Ο i) = β k, (((Fintype.card I : β) - (β j, A k j : β)) * F (β j, A k j) + (((β j, A k j : β) : β) - 1) * F (β j, A k j - 1)) := by intro Ο hΟ have hΟ' : β i, A i (Ο i) = 1 := (mem_filter.1 hΟ).2 unfold Gfun rw [Finset.sum_comm' (t' := univ) (s' := fun k => univ.erase k) (f := fun i k => F (β l, A k l - A k (Ο i))) (by intro x y; simp [mem_erase, ne_comm])] exact Finset.sum_congr rfl fun k _ => row_count A hA Ο hΟ' k rw [Finset.sum_congr rfl this, Finset.sum_const, nsmul_eq_mul] end Rows /-! ### The logarithmic bound (Schrijver) -/ section Main universe u v /-- Induction on the number of rows (arbitrary column type `J`). -/theorem log_bound_aux (n : β) : β {I : Type u} {J : Type v} [Fintype I] [Fintype J] [DecidableEq I] [DecidableEq J] (A : I β J β β), (β i j, A i j β€ 1) β Fintype.card I = n β Phi ((adm A).card : β) β€ ((adm A).card : β) * β i, F (β j, A i j) := by induction n with | zero => intro I J _ _ _ _ A hA hn have : IsEmpty I := Fintype.card_eq_zero_iff.1 hn have hle : (adm A).card β€ 1 := by rw [Finset.card_le_one] intro Ο _ Ο _ ext i exact isEmptyElim i have : (adm A).card = 0 β¨ (adm A).card = 1 := by omega rcases this with h | h <;> simp [h, Phi] | succ n ih => intro I J _ _ _ _ A hA hn by_cases hP : (adm A).card = 0 Β· simp [hP, Phi] have hPpos : (0 : β) < (adm A).card := by exact_mod_cast Nat.pos_of_ne_zero hP obtain β¨Ο0, hΟ0β© := Finset.card_pos.1 (Nat.pos_of_ne_zero hP) have hΟ0' : β i, A i (Ο0 i) = 1 := (mem_filter.1 hΟ0).2 have hr1 : β i, 1 β€ β j, A i j := fun i => calc 1 = A i (Ο0 i) := (hΟ0' i).symm _ β€ β j, A i j := Finset.single_le_sum (f := A i) (fun _ _ => Nat.zero_le _) (mem_univ _) have hN : (Fintype.card I : β) = n + 1 := by rw [hn]; push_cast; ring have hNpos : (0 : β) < Fintype.card I := by rw [hN]; positivity have hIH : β i j, Phi ((adm (minor A i j)).card : β) β€ ((adm (minor A i j)).card : β) * Gfun A i j := by intro i j have := ih (minor A i j) (fun k l => hA k l) (by rw [card_subtype_ne, hn]; rfl) rw [minor_sum_F] at this exact this have hrow : β i, Phi ((adm A).card : β) β€ ((adm A).card : β) * Real.log ((β j, A i j : β) : β) + β j, (A i j : β) * (((adm (minor A i j)).card : β) * Gfun A i j) := by intro i have key := jensen (univ : Finset J) (fun j => (A i j : β)) (fun j => ((adm (minor A i j)).card : β)) (fun j _ => Nat.cast_nonneg _) (fun j _ => Nat.cast_nonneg _) ((β j, A i j : β) : β) (by exact_mod_cast hr1 i) (by push_cast; rfl) (by simpa [β card_adm_eq A hA i] using hPpos) beta_reduce at key rw [β card_adm_eq A hA i] at key refine key.trans (add_le_add_right (Finset.sum_le_sum fun j _ => ?_) _) exact mul_le_mul_of_nonneg_left (hIH i j) (Nat.cast_nonneg _) have hsum : (Fintype.card I : β) * Phi ((adm A).card : β) β€ ((adm A).card : β) * β i, Real.log ((β j, A i j : β) : β) + ((adm A).card : β) * β k, (((Fintype.card I : β) - (β j, A k j : β)) * F (β j, A k j) + (((β j, A k j : β) : β) - 1) * F (β j, A k j - 1)) := by rw [β double_sum A hA] calc (Fintype.card I : β) * Phi ((adm A).card : β) = β _i : I, Phi ((adm A).card : β) := by simp _ β€ β i, (((adm A).card : β) * Real.log ((β j, A i j : β) : β) + β Ο β adm A, Gfun A i (Ο i)) := by refine Finset.sum_le_sum fun i _ => (hrow i).trans ?_ refine add_le_add_right (le_of_eq ?_) _ rw [sum_adm_eq A hA i (Gfun A i)] exact Finset.sum_congr rfl fun j _ => by ring _ = _ := by rw [Finset.sum_add_distrib, Finset.mul_sum] have hcomb : β i, Real.log ((β j, A i j : β) : β) + β k, (((Fintype.card I : β) - (β j, A k j : β)) * F (β j, A k j) + (((β j, A k j : β) : β) - 1) * F (β j, A k j - 1)) = (Fintype.card I : β) * β i, F (β j, A i j) := by rw [β Finset.sum_add_distrib, Finset.mul_sum] refine Finset.sum_congr rfl fun k _ => ?_ have := L2 _ (hr1 k) (Fintype.card I : β) linarith have h2 : (Fintype.card I : β) * Phi ((adm A).card : β) β€ (Fintype.card I : β) * (((adm A).card : β) * β i, F (β j, A i j)) := by calc (Fintype.card I : β) * Phi ((adm A).card : β) β€ _ := hsum _ = ((adm A).card : β) * ((β i, Real.log ((β j, A i j : β) : β) + β k, (((Fintype.card I : β) - (β j, A k j : β)) * F (β j, A k j) + (((β j, A k j : β) : β) - 1) * F (β j, A k j - 1)))) := by ring _ = _ := by rw [hcomb]; ring exact le_of_mul_le_mul_left h2 hNpos /-- **Logarithmic BrΓ©gman bound** (Schrijver; zero rows allowed): for the number `P` of bijections`I β J` picking a `1` in every row of the `(0,1)`-matrix `A`, `P log P β€ P Ξ£α΅’ log(rα΅’!)/rα΅’`. -/theorem log_bound {I : Type u} {J : Type v} [Fintype I] [Fintype J] [DecidableEq I] [DecidableEq J] (A : I β J β β) (hA : β i j, A i j β€ 1) : ((adm A).card : β) * Real.log ((adm A).card : β) β€ ((adm A).card : β) * β i, Real.log (((β j, A i j).factorial : β) : β) / ((β j, A i j : β) : β) := log_bound_aux _ A hA rfl end Main /-! ### BrΓ©gman's theorem -/ /-- The permanent of a `(0,1)`-matrix counts the admissible bijections. -/lemma permanent_eq_card {n : β} (A : Matrix (Fin n) (Fin n) β) (hA : β i j, A i j β€ 1) : A.permanent = (adm A).card := by rw [β Matrix.permanent_transpose] unfold Matrix.permanent adm rw [Finset.card_filter] refine Finset.sum_congr rfl fun Ο _ => ?_ split_ifs with h Β· exact Finset.prod_eq_one fun i _ => by simpa using h i Β· push Not at h obtain β¨i, hiβ© := h apply Finset.prod_eq_zero (mem_univ i) have := hA i (Ο i) simp only [Matrix.transpose_apply] omega /-- **BrΓ©gman's theorem (Minc's conjecture).** For an `n Γ n` `(0,1)`-matrix `A` with row sums`rα΅’ = Ξ£β±Ό A i j`, the permanent satisfies `per A β€ βα΅’ (rα΅’!)^(1/rα΅’)`. The classical statement asks for non-zero row sums;none is needed here: a zero row makes `per A = 0`, and with `1/0 = 0` its factor is `(0!)^0 = 1`. -/theorem permanent_le (n : β) (A : Matrix (Fin n) (Fin n) β) (hA : β i j, A i j β€ 1) : (A.permanent : β) β€ β i, (((β j, A i j).factorial : β) : β) ^ ((1 : β) / (β j, A i j : β)) := by rw [permanent_eq_card A hA] by_cases hP : (adm A).card = 0 Β· rw [hP] simp only [Nat.cast_zero] exact Finset.prod_nonneg fun i _ => by positivity have hpos : (0 : β) < (adm A).card := by exact_mod_cast Nat.pos_of_ne_zero hP have hb := log_bound A hA have hlog : Real.log ((adm A).card : β) β€ β i, Real.log (((β j, A i j).factorial : β) : β) / ((β j, A i j : β) : β) := le_of_mul_le_mul_left hb hpos calc ((adm A).card : β) = Real.exp (Real.log ((adm A).card : β)) := (Real.exp_log hpos).symm _ β€ Real.exp (β i, Real.log (((β j, A i j).factorial : β) : β) / ((β j, A i j : β) : β)) := Real.exp_le_exp.2 hlog _ = β i, Real.exp (Real.log (((β j, A i j).factorial : β) : β) / ((β j, A i j : β) : β)) := Real.exp_sum _ _ _ = _ := by refine Finset.prod_congr rfl fun i _ => ?_ rw [Real.rpow_def_of_pos (by exact_mod_cast Nat.factorial_pos _)] congr 1 ring end Bregman open Finset