Exact Lean source
Nonadditivity.HaarMatchingSharp
Download original .lean · View on GitHub · Jump to source
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
22 project constants, including generated, internal and private declarations.
22 declarations
Nonadditivity.HaarMatchingSharp.RemainingNonadditivity.HaarMatchingSharp.RestrictionFiberNonadditivity.HaarMatchingSharp.card_agreementMatching_le_sharpNonadditivity.HaarMatchingSharp.card_relativeMatching_le_sharpNonadditivity.HaarMatchingSharp.card_relativeMatching_le_sharp._simp_1_1internal/detail/privateNonadditivity.HaarMatchingSharp.card_relativeMatching_le_sharp._simp_1_2internal/detail/privateNonadditivity.HaarMatchingSharp.card_restrictionFiber_leNonadditivity.HaarMatchingSharp.card_restrictionFiber_le._simp_1_2internal/detail/privateNonadditivity.HaarMatchingSharp.fiberToLabelNonadditivity.HaarMatchingSharp.fiberToLabel._proof_1internal/detail/privateNonadditivity.HaarMatchingSharp.fiberToLabel._proof_2internal/detail/privateNonadditivity.HaarMatchingSharp.fiberToLabel._proof_3internal/detail/privateNonadditivity.HaarMatchingSharp.fiberToLabel_injectiveNonadditivity.HaarMatchingSharp.residualCountNonadditivity.HaarMatchingSharp.residualCount.congr_simpNonadditivity.HaarMatchingSharp.residualCount.eq_1internal/detail/privateNonadditivity.HaarMatchingSharp.residualCount_leNonadditivity.HaarMatchingSharp.restrictionNonadditivity.HaarMatchingSharp.sum_high_multiplicityNonadditivity.HaarMatchingSharp.twice_residualCount_leNonadditivity.HaarMatchingSharp.twice_residualCount_le._proof_1_1internal/detail/privateNonadditivity.HaarPathMultiplicity.highMultiplicityOccurrences.congr_simp
Full module
1/-2Copyright (c) 2026 the Nonadditivity project contributors.3All rights reserved. See COPYRIGHT.md for licensing and attribution.4-/56import Nonadditivity.HaarMatchingCount7import Nonadditivity.HaarMatchingFibers89/-! # The high-multiplicity matching bound1011Fixing the disagreement images leaves a literal bijection between fibers of12identical entries. Fibers of size zero or one carry no factorial cost; all13other costs are charged to half the total multiplicity of entries occurring14at least four times.15-/16noncomputable section17set_option backward.isDefEq.respectTransparency false18set_option maxHeartbeats 100000019namespace Nonadditivity.HaarMatchingSharp20open HaarMatchingCount HaarMatchingFibers HaarPathMultiplicity21open scoped BigOperators22variable {E : Type*} [Fintype E] [DecidableEq E] {p : ℕ}2324abbrev Remaining (S : Finset (Fin p)) := {a : Fin p // a ∉ S}2526def restriction (x y : Fin p → E) (S : Finset (Fin p))27(σ : AgreementMatching x y S) : S → Fin p := fun a => σ.val a.val2829abbrev RestrictionFiber (x y : Fin p → E) (S : Finset (Fin p)) (t : S → Fin p) :=30{σ : AgreementMatching x y S // restriction x y S σ=t}3132/-- Fixed images on the exceptional positions leave an actual bijection33between the complementary occurrence sets, preserving their entry labels. -/34def fiberToLabel (x y : Fin p → E) (S : Finset (Fin p)) (t : S → Fin p)35(σ₀ σ : RestrictionFiber x y S t) :36LabelEquiv (fun a : Remaining S => x a.val)37(fun b : Remaining (S.image σ₀.val.val) => y b.val) := by38classical39have hs (a : Fin p) (ha : a ∈ S) : σ.val.val a=σ₀.val.val a :=40congrFun (σ.property.trans σ₀.property.symm) ⟨a,ha⟩41let e : Remaining S ≃ Remaining (S.image σ₀.val.val) :=42σ.val.val.subtypeEquiv (fun a => by43constructor44· intro ha hm45obtain ⟨b,hb,he⟩ := Finset.mem_image.mp hm46have hba : b=a := σ.val.val.injective ((hs b hb).trans he)47exact ha (hba ▸ hb)48· intro ha hm49exact ha (Finset.mem_image.mpr ⟨a,hm,(hs a hm).symm⟩))50exact ⟨e,fun a => (σ.val.property a.val a.property).symm⟩5152omit [Fintype E] [DecidableEq E] in53theorem fiberToLabel_injective (x y : Fin p → E) (S : Finset (Fin p)) (t : S → Fin p)54(σ₀ : RestrictionFiber x y S t) : Function.Injective (fiberToLabel x y S t σ₀) := by55classical56intro σ τ h57apply Subtype.ext58apply Subtype.ext59apply Equiv.ext60intro a61by_cases ha : a ∈ S62· exact congrFun (σ.property.trans τ.property.symm) ⟨a,ha⟩63· exact congrArg (fun f : LabelEquiv (fun a : Remaining S => x a.val)64(fun b : Remaining (S.image σ₀.val.val) => y b.val) => (f.val ⟨a,ha⟩).val) h6566/-- Actual residual multiplicity of one entry value. -/67def residualCount (x : Fin p → E) (S : Finset (Fin p)) (e : E) : ℕ :=68Fintype.card {a : Remaining S // x a.val=e}6970omit [Fintype E] in71theorem residualCount_le (x : Fin p → E) (S : Finset (Fin p)) (e : E) :72residualCount x S e ≤ p := by73classical74apply (Fintype.card_subtype_le _).trans75simpa only [Fintype.card_fin] using Fintype.card_subtype_le (fun a : Fin p => a ∉ S)7677omit [Fintype E] in78/-- Every remaining positive occurrence has a distinct negative partner;79the combined multiplicity is therefore at least twice the residual size. -/80theorem twice_residualCount_le (x y : Fin p → E) (S : Finset (Fin p))81(σ : AgreementMatching x y S) (e : E) :822*residualCount x S e ≤ (List.ofFn x ++ List.ofFn y).count e := by83classical84let A := {a : Remaining S // x a.val=e}85let f : A → {a : Fin p // x a=e} := fun a => ⟨a.val.val,a.property⟩86have hf : Function.Injective f := by87intro a b h88apply Subtype.ext89apply Subtype.ext90exact congrArg (fun z : {a : Fin p // x a=e} => z.val) h91let g : A → {b : Fin p // y b=e} := fun a =>92⟨σ.val a.val.val,(σ.property a.val.val a.val.property).symm.trans a.property⟩93have hg : Function.Injective g := by94intro a b h95apply Subtype.ext96apply Subtype.ext97exact σ.val.injective (congrArg Subtype.val h)98have hpos := Fintype.card_le_of_injective f hf99have hneg := Fintype.card_le_of_injective g hg100have hx : Fintype.card {a : Fin p // x a=e}=(List.ofFn x).count e := by101rw [count_ofFn_eq_card,Fintype.card_subtype]102have hy : Fintype.card {a : Fin p // y a=e}=(List.ofFn y).count e := by103rw [count_ofFn_eq_card,Fintype.card_subtype]104rw [hx] at hpos105rw [hy] at hneg106change residualCount x S e ≤ _ at hpos hneg107rw [List.count_append]108omega109110lemma sum_high_multiplicity (L : List E) :111(∑ e : E, if 4 ≤ L.count e then L.count e else 0)=highMultiplicityOccurrences L := by112classical113symm114apply Finset.sum_subset (Finset.subset_univ _)115intro e _ he116have hz : L.count e=0 := List.count_eq_zero.mpr117(fun h => he (List.mem_toFinset.mpr h))118simp [hz]119120/-- After the exceptional images have been fixed, only repeated pairs carry121any choice: their total cost is at most half the high multiplicity count. -/122theorem card_restrictionFiber_le (hp : 0 < p) (x y : Fin p → E)123(S : Finset (Fin p)) (t : S → Fin p) :124Fintype.card (RestrictionFiber x y S t) ≤125p^(highMultiplicityOccurrences (List.ofFn x ++ List.ofFn y)/2) := by126classical127by_cases h : Nonempty (RestrictionFiber x y S t)128· obtain ⟨σ₀⟩ := h129calc130_ ≤ Fintype.card (LabelEquiv (fun a : Remaining S => x a.val)131(fun b : Remaining (S.image σ₀.val.val) => y b.val)) :=132Fintype.card_le_of_injective (fiberToLabel x y S t σ₀)133(fiberToLabel_injective x y S t σ₀)134_ ≤ ∏ e : E, (residualCount x S e).factorial := by135simpa only [residualCount, ← Nat.card_eq_fintype_card] using136(card_labelEquiv_le (fun a : Remaining S => x a.val)137(fun b : Remaining (S.image σ₀.val.val) => y b.val))138_ ≤ _ := by139have hnum := prod_factorial_le_pow_half_high p hp (residualCount x S)140(fun e => (List.ofFn x ++ List.ofFn y).count e)141(residualCount_le x S) (twice_residualCount_le x y S σ₀.val)142simpa only [sum_high_multiplicity] using hnum143· letI : IsEmpty (RestrictionFiber x y S t) := not_nonempty_iff.mp h144simp145146/-- The sharp matching estimate before selecting any row/column data. -/147theorem card_agreementMatching_le_sharp (hp : 0 < p) (x y : Fin p → E)148(S : Finset (Fin p)) :149Fintype.card (AgreementMatching x y S) ≤150p^(S.card+highMultiplicityOccurrences (List.ofFn x ++ List.ofFn y)/2) := by151classical152calc153_ = ∑ t : S → Fin p, Fintype.card (RestrictionFiber x y S t) := by154rw [← Fintype.card_sigma]155exact (Fintype.card_congr (Equiv.sigmaFiberEquiv (restriction x y S))).symm156_ ≤ ∑ _t : S → Fin p,157p^(highMultiplicityOccurrences (List.ofFn x ++ List.ofFn y)/2) :=158Finset.sum_le_sum (fun t _ => card_restrictionFiber_le hp x y S t)159_ = p^S.card * p^(highMultiplicityOccurrences (List.ofFn x ++ List.ofFn y)/2) := by160simp161_ = _ := (pow_add _ _ _).symm162163/-- The actual fixed-relative Haar matching bound, with the fourth-and-higher164multiplicity statistic from the literal entry list. -/165theorem card_relativeMatching_le_sharp {R C : Type*}166[Fintype R] [Fintype C] [DecidableEq R] [DecidableEq C]167(hp : 0 < p) (i k : Fin p → R) (j l : Fin p → C) (α : Equiv.Perm (Fin p)) :168Fintype.card (RelativeMatching i k j l α) ≤ p^(α.support.card+169highMultiplicityOccurrences (List.ofFn (fun a => (i a,j a)) ++170List.ofFn (fun a => (k a,l a)))/2) := by171classical172let f : RelativeMatching i k j l α →173AgreementMatching (fun a => (i a,j a)) (fun a => (k a,l a)) α.support := fun σ =>174⟨σ.val,by175intro a ha176have hα : α a=a := by simpa only [Equiv.Perm.mem_support,not_not] using ha177apply Prod.ext178· exact congrFun σ.property.1 a179· simpa only [Function.comp_apply,Equiv.Perm.mul_apply,hα] using congrFun σ.property.2 a⟩180have hf : Function.Injective f := by181intro σ τ h182apply Subtype.ext183exact congrArg (fun z : AgreementMatching (fun a => (i a,j a))184(fun a => (k a,l a)) α.support => z.val) h185exact (Fintype.card_le_of_injective f hf).trans (card_agreementMatching_le_sharp hp _ _ α.support)186187end Nonadditivity.HaarMatchingSharp