File size: 6,430 Bytes
e5a97c6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
import OAI.Combinatorics.MatchingPSD.SpectralMultiplicity

namespace OAI

universe u_1 u_2 u_3

namespace MatchingSmoothing

namespace Pairing
variable {V : Type u_1} [Fintype V] [DecidableEq V]

noncomputable instance : Fintype (Pairing V) := Fintype.ofFinite _

instance relabelMulAction : MulAction (Equiv.Perm V) (Pairing V) where
  smul := relabel
  one_smul := relabel_one
  mul_smul := relabel_mul

omit [Fintype V] [DecidableEq V] in
lemma smul_eq_relabel (p : Equiv.Perm V) (M : Pairing V) : p • M = relabel p M := rfl

noncomputable def table (M : Pairing V) (f : V → Fin 3) (t : Fin 6) : ℕ :=
  histogram (fun v => threeEdgeType (f v, f (M.1 v))) t / 2

omit [DecidableEq V] in
lemma table_relabel (p : Equiv.Perm V) (M : Pairing V) (f : V → Fin 3) :
    (relabel p M).table f = M.table (f ∘ p) := by
  funext t
  unfold table
  congr 1
  have he : (fun v => threeEdgeType (f v, f ((relabel p M).1 v))) ∘ p =
      (fun v => threeEdgeType ((f ∘ p) v, (f ∘ p) (M.1 v))) := by
    funext v
    simp only [Function.comp_apply, relabel_apply]
    rw [Equiv.Perm.inv_def, p.symm_apply_apply]
  rw [← he, histogram_comp_perm]

end Pairing

section StandardTable
variable {H : Type u_2} [Fintype H] [DecidableEq H]

def standardPairing : Pairing (H × Bool) :=
  ⟨Equiv.prodCongr (Equiv.refl H) Equiv.boolNot,
    by rintro ⟨i,b⟩; cases b <;> rfl,
    by rintro ⟨i,b⟩ h; have he := congrArg Prod.snd h; cases b <;> contradiction⟩

omit [DecidableEq H] in
lemma standardPairing_table (f : H × Bool → Fin 3) :
    (standardPairing (H := H)).table f = threeTable f := by
  funext t
  have he : histogram (fun v => threeEdgeType (f v, f ((standardPairing (H := H)).1 v))) t =
      2 * threeTable f t := by
    have hr : (histogram (fun v => threeEdgeType (f v,
        f ((standardPairing (H := H)).1 v))) t : ℝ) = 2 * threeTable f t := by
      simp only [histogram_cast_sum, Fintype.sum_prod_type, Fintype.sum_bool,
        standardPairing, Equiv.prodCongr_apply]
      change (∑ i, ((if threeEdgeType (f (i,true),f (i,false)) = t then (1 : ℝ) else 0) +
        (if threeEdgeType (f (i,false),f (i,true)) = t then 1 else 0))) = _
      simp_rw [threeEdgeType_symm (f (_,true)) (f (_,false))]
      rw [Finset.sum_add_distrib]
      change (∑ i, if threeEdgeType (f (i,false),f (i,true)) = t then (1 : ℝ) else 0) +
        (∑ i, if threeEdgeType (f (i,false),f (i,true)) = t then (1 : ℝ) else 0) = _
      rw [show (threeTable f t : ℝ) =
        ∑ i, if threeEdgeType (f (i,false),f (i,true)) = t then 1 else 0 from
          histogram_cast_sum (threeEdgeType ∘ pairColorEquiv f) t]
      ring
    exact_mod_cast hr
  change _ / 2 = _
  rw [he, Nat.mul_div_right _ (by decide : 0 < 2)]

end StandardTable

section MatchingIncidence
variable {H : Type u_3} [Fintype H] [DecidableEq H]

noncomputable def tableRelation (f₀ : H × Bool → Fin 3) :
    Pairing (H × Bool) → Colorings (H × Bool) (Fin 3) (histogram f₀) → Prop :=
  fun M z => M.table z.1 = threeTable f₀

noncomputable def coloringPerm (s : Fin 3 → ℕ) (p : Equiv.Perm (H × Bool)) :
    Equiv.Perm (Colorings (H × Bool) (Fin 3) s) where
  toFun z := ⟨z.1 ∘ p, (histogram_comp_perm z.1 p).trans z.2⟩
  invFun z := ⟨z.1 ∘ p.symm, (histogram_comp_perm z.1 p.symm).trans z.2⟩
  left_inv z := by apply Subtype.ext; funext v; simp
  right_inv z := by apply Subtype.ext; funext v; simp

omit [DecidableEq H] in
lemma commonIncidence_table_relabel (f₀ : H × Bool → Fin 3)
    (p : Equiv.Perm (H × Bool)) (M N : Pairing (H × Bool)) :
    commonIncidence (tableRelation f₀) (Pairing.relabel p M) (Pairing.relabel p N) =
      commonIncidence (tableRelation f₀) M N := by
  classical
  unfold commonIncidence
  congr 1
  apply Fintype.card_congr
  apply (coloringPerm (histogram f₀) p).subtypeEquiv
  intro z
  change ((Pairing.relabel p M).table z.1 = _ ∧ (Pairing.relabel p N).table z.1 = _) ↔
    (M.table (z.1 ∘ p) = _ ∧ N.table (z.1 ∘ p) = _)
  simp only [Pairing.table_relabel]

lemma commonIncidence_standard (f₀ : H × Bool → Fin 3) (hH : 0 < Fintype.card H)
    (p : Equiv.Perm (H × Bool)) :
    commonIncidence (tableRelation f₀) standardPairing (Pairing.relabel p standardPairing) =
      (Fintype.card {f : H × Bool → Fin 3 //
        threeTable f = threeTable f₀ ∧ threeTable (f ∘ p) = threeTable f₀} : ℝ) := by
  classical
  unfold commonIncidence
  congr 1
  apply Fintype.card_congr
  refine { toFun := fun z => ⟨z.1.1, ?_⟩
           invFun := fun f => ⟨⟨f.1, threeTable_histogram_eq hH f.2.1⟩, ?_⟩
           left_inv := fun _ => rfl
           right_inv := fun _ => rfl }
  · simpa only [tableRelation, Pairing.table_relabel, standardPairing_table] using z.2
  · simpa only [tableRelation, Pairing.table_relabel, standardPairing_table] using f.2

lemma matching_table_trace_square (f₀ : H × Bool → Fin 3) (hH : 0 < Fintype.card H)
    (hf₀ : ∀ i, 0 < histogram f₀ i) :
    let D : ℝ := Fintype.card {f : H × Bool → Fin 3 // threeTable f = threeTable f₀}
    Matrix.trace (incidenceOperator (tableRelation f₀) D *
      incidenceOperator (tableRelation f₀) D) ≤ (Fintype.card H + 1 : ℝ) ^ 33 := by
  classical
  dsimp only
  let D : ℝ := Fintype.card {f : H × Bool → Fin 3 // threeTable f = threeTable f₀}
  change Matrix.trace (incidenceOperator (tableRelation f₀) D *
    incidenceOperator (tableRelation f₀) D) ≤ _
  have he := trace_normalized_invariant_kernel_sq (G := Equiv.Perm (H × Bool))
    (standardPairing (H := H)) (fun M => Pairing.exists_relabel _ M)
    (incidenceKernel (tableRelation f₀) D)
    (incidenceKernel_symm (tableRelation f₀) D)
    (fun p M N => by
      change (Fintype.card _ : ℝ) / D ^ 2 * commonIncidence _ (Pairing.relabel p M)
        (Pairing.relabel p N) = (Fintype.card _ : ℝ) / D ^ 2 * commonIncidence _ M N
      rw [commonIncidence_table_relabel])
  change Matrix.trace (incidenceOperator (tableRelation f₀) D *
    incidenceOperator (tableRelation f₀) D) = _ at he
  rw [he]
  have hp : (0 : ℝ) < Fintype.card (Equiv.Perm (H × Bool)) := Nat.cast_pos.mpr Fintype.card_pos
  apply (div_le_iff₀ hp).mpr
  simp only [incidenceKernel, Pairing.smul_eq_relabel,
    commonIncidence_standard f₀ hH]
  exact (three_table_kernel_moment f₀ hH hf₀).trans_eq (mul_comm _ _)

end MatchingIncidence
end MatchingSmoothing

end OAI