Exact Lean source
Nonadditivity.HaarMatchingFibers
Download original .lean · View on GitHub · Jump to source
Direct imports
Mathlib.SetTheory.Cardinal.FinitedependencyMathlib.Data.Fintype.PermdependencyMathlib.Data.Fintype.BigOperatorsdependencyMathlib.Algebra.BigOperators.Ring.FinsetdependencyMathlib.Algebra.Order.BigOperators.Group.Finsetdependency
Imported by project modules
2 direct reverse imports
Relationships above come from literal import commands. The declarations below link to types and references extracted from Lean’s environment. Source text is complete and unchanged.
Declarations in this module
15 project constants, including generated, internal and private declarations.
15 declarations
Nonadditivity.HaarMatchingFibers.LabelEquivNonadditivity.HaarMatchingFibers.card_equiv_le_factorialNonadditivity.HaarMatchingFibers.card_labelEquiv_leNonadditivity.HaarMatchingFibers.card_labelEquiv_le._simp_1_1internal/detail/privateNonadditivity.HaarMatchingFibers.fiberEquivNonadditivity.HaarMatchingFibers.fiberEquiv._proof_1internal/detail/privateNonadditivity.HaarMatchingFibers.fiberEquiv._proof_2internal/detail/privateNonadditivity.HaarMatchingFibers.fiberEquiv._proof_3internal/detail/privateNonadditivity.HaarMatchingFibers.fiberEquiv._proof_4internal/detail/privateNonadditivity.HaarMatchingFibers.fiberEquiv._proof_5internal/detail/privateNonadditivity.HaarMatchingFibers.fiberEquiv._proof_6internal/detail/privateNonadditivity.HaarMatchingFibers.fiberEquiv_injectiveNonadditivity.HaarMatchingFibers.instFintypeLabelEquivNonadditivity.HaarMatchingFibers.prod_factorial_le_pow_half_highNonadditivity.HaarMatchingFibers.prod_factorial_le_pow_half_high._proof_1_1internal/detail/private
Full module
1/-2Copyright (c) 2026 the Nonadditivity project contributors.3All rights reserved. See COPYRIGHT.md for licensing and attribution.4-/56import Mathlib.SetTheory.Cardinal.Finite7import Mathlib.Data.Fintype.Perm8import Mathlib.Data.Fintype.BigOperators9import Mathlib.Algebra.BigOperators.Ring.Finset10import Mathlib.Algebra.Order.BigOperators.Group.Finset1112/-! # Counting bijections that preserve actual entry labels1314A label-preserving bijection restricts to a bijection of each pair of fibers.15This gives the exact factorial counting bound used after the values of a Haar16matching have been fixed on its disagreement support.17-/18noncomputable section19set_option backward.isDefEq.respectTransparency false20set_option maxHeartbeats 40000021namespace Nonadditivity.HaarMatchingFibers22open scoped BigOperators23attribute [local instance] Classical.propDecidable2425variable {A B E : Type*}2627/-- Literal bijections of the occurrence sets preserving their entry labels. -/28def LabelEquiv (x : A → E) (y : B → E) := {σ : A ≃ B // ∀ a, y (σ a) = x a}2930instance [Fintype A] [Fintype B] (x : A → E) (y : B → E) : Fintype (LabelEquiv x y) :=31by32classical33exact inferInstanceAs (Fintype {σ : A ≃ B // ∀ a, y (σ a) = x a})3435/-- A label-preserving matching induces an actual equivalence on each fiber. -/36def fiberEquiv (x : A → E) (y : B → E) (σ : LabelEquiv x y) (e : E) :37{a : A // x a = e} ≃ {b : B // y b = e} where38toFun a := ⟨σ.val a.val, (σ.property a.val).trans a.property⟩39invFun b := ⟨σ.val.symm b.val, (σ.property (σ.val.symm b.val)).symm.trans40(by rw [σ.val.apply_symm_apply]; exact b.property)⟩41left_inv a := by apply Subtype.ext; exact σ.val.symm_apply_apply _42right_inv b := by apply Subtype.ext; exact σ.val.apply_symm_apply _4344/-- All fiber restrictions together determine the entire matching. -/45theorem fiberEquiv_injective (x : A → E) (y : B → E) :46Function.Injective (fun σ : LabelEquiv x y => fiberEquiv x y σ) := by47intro σ τ h48apply Subtype.ext49apply Equiv.ext50intro a51have he := congrFun h (x a)52have hv := congrArg (fun f : {a' : A // x a' = x a} ≃ {b : B // y b = x a} =>53(f ⟨a,rfl⟩).val) he54exact hv5556/-- Even for unequal fiber sizes, the number of bijections is at most the57factorial of the source size: an incompatible fiber contributes zero. -/58theorem card_equiv_le_factorial [Fintype A] [Fintype B] :59Fintype.card (A ≃ B) ≤ (Fintype.card A).factorial := by60classical61by_cases h : Nonempty (A ≃ B)62· obtain ⟨e⟩ := h63exact le_of_eq (Fintype.card_equiv e)64· letI : IsEmpty (A ≃ B) := not_nonempty_iff.mp h65simp6667/-- The sharp fiber-factorial bound, with no premise asserting compatible68fiber cardinalities or existence of a matching. -/69theorem card_labelEquiv_le [Fintype A] [Fintype B] [Fintype E]70(x : A → E) (y : B → E) :71Fintype.card (LabelEquiv x y) ≤72∏ e : E, (Fintype.card {a : A // x a = e}).factorial := by73classical74calc75_ ≤ Fintype.card (∀ e : E, {a : A // x a = e} ≃ {b : B // y b = e}) :=76Fintype.card_le_of_injective (fun σ => fiberEquiv x y σ) (fiberEquiv_injective x y)77_ = ∏ e : E, Fintype.card ({a : A // x a = e} ≃ {b : B // y b = e}) :=78Fintype.card_pi79_ ≤ _ := by80have h (e : E) := card_equiv_le_factorial81(A := {a : A // x a = e}) (B := {b : B // y b = e})82simp only [← Nat.card_eq_fintype_card] at h ⊢83exact Finset.prod_le_prod' (fun e _ => h e)848586/-- Only fibers with total multiplicity at least four cost a nontrivial87factorial. Matching uses at most half of the total occurrences in each fiber. -/88theorem prod_factorial_le_pow_half_high [Fintype E]89(p : ℕ) (hp : 0 < p) (a t : E → ℕ)90(ha : ∀ e, a e ≤ p) (hat : ∀ e, 2*a e ≤ t e) :91(∏ e : E, (a e).factorial) ≤92p ^ ((∑ e : E, if 4 ≤ t e then t e else 0)/2) := by93classical94let c : E → ℕ := fun e => if 4 ≤ t e then a e else 095have hfactor (e : E) : (a e).factorial ≤ p ^ c e := by96by_cases h : 4 ≤ t e97· simp only [c, if_pos h]98exact (Nat.factorial_le_pow (a e)).trans (Nat.pow_le_pow_left (ha e) _)99· have hsmall : a e ≤ 1 := by have := hat e; omega100simp [c, h, Nat.factorial_eq_one.mpr hsmall]101have hexp : (∑ e : E, c e) ≤ (∑ e : E, if 4 ≤ t e then t e else 0)/2 := by102apply (Nat.le_div_iff_mul_le (by decide : 0 < 2)).mpr103rw [Finset.sum_mul]104apply Finset.sum_le_sum105intro e he106by_cases h : 4 ≤ t e107· simpa [c, h, mul_comm] using hat e108· simp [c, h]109calc110_ ≤ ∏ e : E, p ^ c e := Finset.prod_le_prod' (fun e _ => hfactor e)111_ = p ^ (∑ e : E, c e) := Finset.prod_pow_eq_pow_sum _ _ _112_ ≤ _ := Nat.pow_le_pow_right hp hexp113114end Nonadditivity.HaarMatchingFibers