File size: 4,396 Bytes
4a56cd6 | 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 | import OAI.Combinatorics.MatchingPSD.MatrixInterpolation
namespace OAI
namespace MatchingInterpolation
open MatchingSmoothing PerfectMatchingPSD Matrix
open scoped BigOperators
attribute [local instance] Classical.propDecidable
abbrev SampleIndex (d : β) := Fin 5 β GridIndex d
noncomputable def samplePoint (d : β) (L : β) : SampleIndex d β Point :=
Sum.elim specialPoint (scaledNode L)
lemma specialPoint_explicit (j : Fin 5) :
specialPoint j = (![![1,0,0], ![0,1,1], ![3,0,0], ![1,2,0], ![1,0,2]] j : Point) := by
fin_cases j <;> ext a <;> fin_cases a <;> norm_num [specialPoint, origin, dirP, dirStar, dirA, dirB]
lemma sample_witness {s l d : β} (hs : 1 β€ s) (hsl : 2*l*d β€ s) (t : SampleIndex d) :
β M : Pairing (TripleVertices s), crossVector threeColor M = samplePoint d (2*l) t := by
rcases t with j | g
Β· rw [samplePoint, Sum.elim_inl, specialPoint_explicit]
exact triple_pairing_five hs j
Β· exact triple_pairing_grid hsl g
lemma good_cell_polynomials (K : β) :
β d H : β, 0 < d β§ β s q l r : β, H β€ 3*s+1 β 1 β€ s β 2*l*d β€ s β
β (B : Pairing (GlobalVertices s q) β Matrix (Fin r) (Fin r) β),
(β M, (B M).PosSemidef) β (β M, (B M).trace β€ (r:β)) β
β Ξ· : β, 0 β€ Ξ· β
(q:β)*r^4*(Fintype.card (SampleIndex d))*((2*(3*s+1):β)^(2*K))β»ΒΉ β€ Ξ·^2 β
β a : Equiv.Perm (GlobalVertices s q),
β P : Fin q β Fin r β Fin r β Point β β,
(β i u v, P i u v β lowDegree coord d) β§
β i u v t, |cellMatrix i (fun M => B (Pairing.relabel a M))
(samplePoint d (2*l) t) u v-P i u v (samplePoint d (2*l) t)| β€ Ξ· := by
classical
obtain β¨d,H,hd,hmainβ© := simultaneous_cross_approximation K
refine β¨d,H,hd,?_β©
intro s q l r hH hs hsl B hB htr Ξ· hΞ· hnum
let J := Fin q Γ (Fin r Γ Fin r)
let T := SampleIndex d
let M : T β Pairing (TripleVertices s) := fun t => (sample_witness hs hsl t).choose
have hM (t : T) : crossVector threeColor (M t) = samplePoint d (2*l) t :=
(sample_witness hs hsl t).choose_spec
let g (j : J) (a : Equiv.Perm (GlobalVertices s q)) (N : Pairing (TripleVertices s)) : β :=
extensionAverage j.1 (fun Z => B (Pairing.relabel a Z) j.2.1 j.2.2) N
have hg (j : J) (a : Equiv.Perm (GlobalVertices s q)) (p : Equiv.Perm (TripleVertices s)) :
g j (a * liftLocal j.1 p) = fun N => g j a (Pairing.relabel p N) := by
funext N
dsimp only [g]
rw [extensionAverage_relabel]
simp only [Pairing.relabel_mul]
have hgb (j : J) (a : Equiv.Perm (GlobalVertices s q)) (N : Pairing (TripleVertices s)) :
(g j a N)^2 β€ (r:β)^2 :=
extensionAverage_sq_bound j.1 _ (fun Z => hB _) (Nat.cast_nonneg r)
(fun Z => htr _) j.2.1 j.2.2 N
obtain β¨a,P,hP,hboundβ© := hmain (3*s+1) hH (TripleVertices s)
(Equiv.Perm (GlobalVertices s q)) J T (tripleEquiv s) (fun _ => threeColor)
(fun _ c => triple_histogram_pos (by omega) c) (fun _ => M)
(fun j => liftLocal j.1) g hg (r:β) hgb
refine β¨a,fun i u v => P (i,u,v),fun i u v => hP (i,u,v),?_β©
intro i u v t
let E (j : J) (t : T) :=
predicateAverage (fun N => crossVector threeColor N = crossVector threeColor (M t)) (g j a) -
P j (crossVector threeColor (M t))
have hjt : (E (i,u,v) t)^2 β€ β j, β t, (E j t)^2 := by
exact (Finset.single_le_sum (fun z _ => sq_nonneg (E (i,u,v) z)) (Finset.mem_univ t)).trans
(Finset.single_le_sum (fun j _ => Finset.sum_nonneg (fun z _ => sq_nonneg (E j z)))
(Finset.mem_univ (i,u,v)))
have hb : (β j, β t, (E j t)^2) β€ Ξ·^2 := by
apply hbound.trans
have heq : (Fintype.card J : β)*(Fintype.card T)*((2*(3*s+1:β):β)^(2*K))β»ΒΉ*(r:β)^2 =
(q:β)*r^4*(Fintype.card (SampleIndex d))*((2*(3*s+1):β)^(2*K))β»ΒΉ := by
simp only [J, T, Fintype.card_prod, Fintype.card_fin, Nat.cast_mul, Nat.cast_add, Nat.cast_ofNat]
ring
rw [heq]
exact hnum
have hab : |E (i,u,v) t| β€ Ξ· := (sq_le_sqβ (abs_nonneg _) hΞ·).mp
(by simpa only [sq_abs] using hjt.trans hb)
have he : E (i,u,v) t = cellMatrix i (fun Z => B (Pairing.relabel a Z))
(samplePoint d (2*l) t) u v-P (i,u,v) (samplePoint d (2*l) t) := by
rw [cellMatrix_apply]
dsimp only [E, cellAverage, g]
rw [hM]
rwa [he] at hab
end MatchingInterpolation
end OAI
|