Exact Lean source
Nonadditivity.HaarMatchingCount
Download original .lean · View on GitHub · Jump to source
Direct imports
Nonadditivity.HaarMatchingSingletonsMathlib.Algebra.BigOperators.Findependency
Imported by project modules
3 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
19 project constants, including generated, internal and private declarations.
19 declarations
Nonadditivity.HaarMatchingCount.AgreementMatchingNonadditivity.HaarMatchingCount.RelativeMatchingNonadditivity.HaarMatchingCount.card_agreementMatching_leNonadditivity.HaarMatchingCount.card_agreementMatching_le._proof_1_2internal/detail/privateNonadditivity.HaarMatchingCount.card_relativeMatching_leNonadditivity.HaarMatchingCount.card_relativeMatching_le._simp_1_1internal/detail/privateNonadditivity.HaarMatchingCount.card_relativeMatching_le._simp_1_2internal/detail/privateNonadditivity.HaarMatchingCount.count_ofFn_eq_cardNonadditivity.HaarMatchingCount.markedNonadditivity.HaarMatchingCount.marked.eq_1internal/detail/privateNonadditivity.HaarMatchingCount.marked_card_le_three_excessNonadditivity.HaarMatchingCount.marked_card_le_three_excess._proof_1_2internal/detail/privateNonadditivity.HaarMatchingCount.marked_card_le_three_excess._proof_1_3internal/detail/privateNonadditivity.HaarMatchingCount.marked_card_le_three_excess._proof_1_4internal/detail/privateNonadditivity.HaarMatchingCount.target_unique_of_not_markedNonadditivity.HaarMatchingCount.target_unique_of_not_marked._proof_1_2internal/detail/privateNonadditivity.HaarMatchingCount.two_le_count_ofFnNonadditivity.HaarMatchingCount.two_le_count_ofFn._simp_1_1internal/detail/privateNonadditivity.HaarMatchingCount.two_le_count_ofFn._simp_1_2internal/detail/private
Full module
1/-2Copyright (c) 2026 the Nonadditivity project contributors.3All rights reserved. See COPYRIGHT.md for licensing and attribution.4-/56import Nonadditivity.HaarMatchingSingletons7import Mathlib.Algebra.BigOperators.Fin89/-! # Counting entry matchings at a fixed relative permutation1011Away from exceptional positions, an entry of total multiplicity at most two12has at most one possible partner. Restricting a matching permutation to the13exceptional positions is therefore injective. Higher multiplicities are14charged to the literal excess-occurrence statistic.15-/16noncomputable section17namespace Nonadditivity.HaarMatchingCount18open HaarPathMultiplicity HaarMatchingSingletons19open scoped BigOperators20variable {E : Type*} [DecidableEq E] {p : ℕ}2122lemma count_ofFn_eq_card (f : Fin p → E) (e : E) :23(List.ofFn f).count e=(Finset.univ.filter (fun a => f a=e)).card := by24have hs : (List.ofFn f).count e=∑ a, if f a=e then 1 else 0 := by25induction p with26| zero => simp27| succ p ih =>28rw [List.ofFn_succ,List.count_cons,Fin.sum_univ_succ,ih]29by_cases h : f 0=e <;> simp [h,Nat.add_comm]30simpa using hs3132lemma two_le_count_ofFn (f : Fin p → E) (e : E) (a b : Fin p)33(ha : f a=e) (hb : f b=e) (hab : a≠b) : 2 ≤ (List.ofFn f).count e := by34rw [count_ofFn_eq_card]35have hsub : ({a,b} : Finset (Fin p)) ⊆ Finset.univ.filter (fun i => f i=e) := by36intro i hi37simp only [Finset.mem_insert,Finset.mem_singleton] at hi38rcases hi with rfl | rfl <;> simp [ha,hb]39have h := Finset.card_le_card hsub40simpa [hab] using h4142/-- Positive occurrences whose combined entry multiplicity is at least three. -/43def marked (x y : Fin p → E) : Finset (Fin p) :=44Finset.univ.filter (fun a => 3 ≤ (List.ofFn x ++ List.ofFn y).count (x a))4546lemma target_unique_of_not_marked (x y : Fin p → E) (a : Fin p)47(ha : a ∉ marked x y) (b c : Fin p) (hb : y b=x a) (hc : y c=x a) : b=c := by48by_contra hbc49have hn : ¬3 ≤ (List.ofFn x ++ List.ofFn y).count (x a) := by50simpa [marked] using ha51have hp : 0 < (List.ofFn x).count (x a) :=52List.count_pos_iff.mpr (List.mem_ofFn.mpr ⟨a,rfl⟩)53have hm := two_le_count_ofFn y (x a) b c hb hc hbc54rw [List.count_append] at hn55omega5657/-- The number of marked positive occurrences is controlled by three times58all occurrences beyond the second copy of each entry. -/59theorem marked_card_le_three_excess (x y : Fin p → E) :60(marked x y).card ≤ 3*excessOccurrences (List.ofFn x ++ List.ofFn y) := by61let L := List.ofFn x ++ List.ofFn y62let f : E → ℕ := fun e => if 3 ≤ L.count e then 1 else 063have he : (marked x y).card=((List.ofFn x).map f).sum := by64simp [marked,f,L,List.map_ofFn,Fin.sum_ofFn]65rw [he]66calc67_ ≤ (L.map f).sum := by68dsimp only [L]69rw [List.map_append,List.sum_append]70omega71_ = ∑ e ∈ L.toFinset, L.count e*f e := by72simpa only [nsmul_eq_mul] using sum_occurrence_weights L f73_ ≤ 3*excessOccurrences L := by74rw [excessOccurrences,Finset.mul_sum]75apply Finset.sum_le_sum76intro e _77dsimp only [f]78split_ifs <;> omega7980/-- Over-approximation of all matchings: only the nonexceptional positions81are required to pair identical entries. -/82abbrev AgreementMatching (x y : Fin p → E) (S : Finset (Fin p)) :=83{σ : Equiv.Perm (Fin p) // ∀ a, a ∉ S → x a=y (σ a)}8485/-- Restriction to the exceptional and marked positions determines the86entire permutation. This estimate has no probabilistic hypotheses. -/87theorem card_agreementMatching_le (x y : Fin p → E) (S : Finset (Fin p)) :88Fintype.card (AgreementMatching x y S) ≤ p^(S.card+3*excessOccurrences89(List.ofFn x ++ List.ofFn y)) := by90classical91let B := S ∪ marked x y92let enc : AgreementMatching x y S → (B → Fin p) := fun σ a => σ.val a.val93have hi : Function.Injective enc := by94intro σ τ h95apply Subtype.ext96apply Equiv.ext97intro a98by_cases ha : a ∈ B99· exact congrFun h ⟨a,ha⟩100· have hS : a ∉ S := fun hs => ha (Finset.mem_union_left _ hs)101have hM : a ∉ marked x y := fun hm => ha (Finset.mem_union_right _ hm)102exact target_unique_of_not_marked x y a hM (σ.val a) (τ.val a)103(σ.property a hS).symm (τ.property a hS).symm104have hcard := Fintype.card_le_of_injective enc hi105have hpow : B.card ≤ S.card+3*excessOccurrences (List.ofFn x ++ List.ofFn y) :=106(Finset.card_union_le S (marked x y)).trans107(Nat.add_le_add_left (marked_card_le_three_excess x y) S.card)108calc109_ ≤ p^B.card := by simpa only [Fintype.card_fun,Fintype.card_fin,Fintype.card_coe] using hcard110_ ≤ _ := by111by_cases hp : p=0112· subst p113simp [B,S.eq_empty_of_isEmpty,marked,excessOccurrences]114· exact Nat.pow_le_pow_right (by omega) hpow115116/-- Actual row and column matchings with prescribed relative permutation. -/117abbrev RelativeMatching {R C : Type*} (i k : Fin p → R) (j l : Fin p → C)118(α : Equiv.Perm (Fin p)) :=119{σ : Equiv.Perm (Fin p) // i=k ∘ σ ∧ j=l ∘ (σ*α)}120121/-- With the relative matching fixed, the number of compatible pairs is122bounded by support size and the actual entry-multiplicity excess. -/123theorem card_relativeMatching_le {R C : Type*} [DecidableEq R] [DecidableEq C]124(i k : Fin p → R) (j l : Fin p → C) (α : Equiv.Perm (Fin p)) :125Fintype.card (RelativeMatching i k j l α) ≤ p^(α.support.card+1263*excessOccurrences (List.ofFn (fun a => (i a,j a)) ++127List.ofFn (fun a => (k a,l a)))) := by128classical129let f : RelativeMatching i k j l α →130AgreementMatching (fun a => (i a,j a)) (fun a => (k a,l a)) α.support := fun σ =>131⟨σ.val,by132intro a ha133have hα : α a=a := by simpa only [Equiv.Perm.mem_support,not_not] using ha134apply Prod.ext135· exact congrFun σ.property.1 a136· simpa only [Function.comp_apply,Equiv.Perm.mul_apply,hα] using congrFun σ.property.2 a⟩137have hf : Function.Injective f := by138intro σ τ h139apply Subtype.ext140exact congrArg (fun z : AgreementMatching (fun a => (i a,j a))141(fun a => (k a,l a)) α.support => z.val) h142exact (Fintype.card_le_of_injective f hf).trans (card_agreementMatching_le _ _ α.support)143144end Nonadditivity.HaarMatchingCount