πŸ›οΈ Atlasβœ’οΈFormalizations.Combinatorics.Permanent.Bregman view on GitHub β†—16 theorems
/-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