math / data /lean /OAI /Combinatorics /MatchingPSD /GoodCells.lean
introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
4.4 kB
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