math / data /lean /OAI /Analysis /ForestSpace /Distortion.lean
introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
8.03 kB
import OAI.Analysis.ForestSpace.Diamonds
namespace OAI
open scoped BigOperators
open Finset
namespace ForestSpace
noncomputable section
attribute [local instance] Classical.propDecidable
namespace Diamond
noncomputable section
section Distortion
variable {E : Type} [NormedAddCommGroup E] [NormedSpace ℝ E]
/-- The exact separated approximate-midpoint estimate proved for the target space. -/
def LensProperty (E : Type) [NormedAddCommGroup E] [NormedSpace ℝ E] : Prop :=
βˆ€ (R Ξ΅ : ℝ), 0 < R β†’ 0 < Ξ΅ β†’ βˆ€ (x : E) (y : β„• β†’ E),
(βˆ€ j, β€–x+y jβ€– ≀ R) β†’ (βˆ€ j, β€–x-y jβ€– ≀ R) β†’
(βˆ€ i j, i β‰  j β†’ Ξ΅ ≀ β€–y i-y jβ€–) β†’ Ξ΅^2/48 ≀ R^2-β€–xβ€–^2
theorem parent_step (hLens : LensProperty E) (R β„“ : ℝ) (hR : 0 < R) (hβ„“ : 0 < β„“)
(a b : E) (w : β„• β†’ E)
(hp : βˆ€ j, β€–w j-aβ€–/β„“ ≀ R) (hm : βˆ€ j, β€–b-w jβ€–/β„“ ≀ R)
(hs : βˆ€ i j, i β‰  j β†’ 2*β„“ ≀ β€–w i-w jβ€–) :
(β€–b-aβ€–/(2*β„“))^2+1/12 ≀ R^2 := by
let x : E := (2*β„“)⁻¹ β€’ (b-a)
let y : β„• β†’ E := fun j => ℓ⁻¹ β€’ (w j-(1/2 : ℝ) β€’ (a+b))
have hc : (2*β„“)⁻¹ = (1/2 : ℝ)*ℓ⁻¹ := by field_simp
have hplus : βˆ€ j, x+y j = ℓ⁻¹ β€’ (w j-a) := by
intro j
dsimp [x,y]
rw [hc]
module
have hminus : βˆ€ j, x-y j = ℓ⁻¹ β€’ (b-w j) := by
intro j
dsimp [x,y]
rw [hc]
module
have hdn : βˆ€ i j, β€–y i-y jβ€– = β€–w i-w jβ€–/β„“ := by
intro i j
have he : y i-y j = ℓ⁻¹ β€’ (w i-w j) := by dsimp [y]; module
rw [he,norm_smul,Real.norm_of_nonneg (inv_nonneg.mpr hβ„“.le)]
ring
have hh := hLens R 2 hR (by norm_num) x y
(by
intro j
rw [hplus,norm_smul,Real.norm_of_nonneg (inv_nonneg.mpr hβ„“.le)]
simpa only [div_eq_mul_inv,mul_comm] using hp j)
(by
intro j
rw [hminus,norm_smul,Real.norm_of_nonneg (inv_nonneg.mpr hβ„“.le)]
simpa only [div_eq_mul_inv,mul_comm] using hm j)
(by intro i j hij; rw [hdn]; exact (le_div_iffβ‚€ hβ„“).mpr (hs i j hij))
have hx : β€–xβ€– = β€–b-aβ€–/(2*β„“) := by
dsimp [x]
rw [norm_smul,Real.norm_of_nonneg (inv_nonneg.mpr (mul_nonneg (by norm_num) hβ„“.le))]
ring
rw [hx] at hh
norm_num at hh
linarith
/-- The squared loss holds on each original edge, without requiring attainment
of any supremum of edge stretches. -/
theorem edge_sq_loss (hLens : LensProperty E) (A : Network) (hA : A.graph.Connected)
(n : β„•) (f : (A.iterate n).V β†’ E) (C : ℝ) (hC : 0 ≀ C)
(hl : βˆ€ u v, ((A.iterate n).graph.dist u v : ℝ) ≀ β€–f u-f vβ€–)
(hu : βˆ€ u v, β€–f u-f vβ€– ≀ C*((A.iterate n).graph.dist u v : ℝ))
(e : A.E) :
(β€–f (A.old n (A.right e))-f (A.old n (A.left e))β€–/(2:ℝ)^n)^2+(n:ℝ)/12 ≀ C^2 := by
induction n generalizing A with
| zero =>
have hh := hu (A.right e) (A.left e)
have he : A.graph.dist (A.right e) (A.left e) = 1 :=
SimpleGraph.dist_eq_one_iff_adj.mpr (A.edge_adj e).symm
change β€–f (A.right e)-f (A.left e)β€– ≀ C*(A.graph.dist (A.right e) (A.left e) : ℝ) at hh
rw [he,Nat.cast_one,mul_one] at hh
simpa using (sq_le_sqβ‚€ (norm_nonneg _) hC).mpr hh
| succ n ih =>
let β„“ : ℝ := (2:ℝ)^n
have hβ„“ : 0 < β„“ := pow_pos (by norm_num) _
let a := f (A.refine.old n (Sum.inl (A.left e)))
let b := f (A.refine.old n (Sum.inl (A.right e)))
let w : β„• β†’ E := fun j => f (A.refine.old n (Sum.inr (e,j)))
have hchild : βˆ€ c : A.refine.E,
(β€–f (A.refine.old n (A.refine.right c))-f (A.refine.old n (A.refine.left c))β€–/β„“)^2+
(n:ℝ)/12 ≀ C^2 := by
intro c
exact ih A.refine (A.refine_connected hA) f hl hu c
have hrad : 1 ≀ C^2-(n:ℝ)/12 := by
have hb := hchild (e,0,false)
have hd := A.refine.old_edge_dist (A.refine_connected hA) n (e,0,false)
have hlo := hl (A.refine.old n (Sum.inl (A.left e))) (A.refine.old n (Sum.inr (e,0)))
have hd' : ((A.refine.iterate n).graph.dist
(A.refine.old n (Sum.inl (A.left e))) (A.refine.old n (Sum.inr (e,0))) : ℝ) = β„“ := by
dsimp [β„“]
exact_mod_cast hd
change ((A.refine.iterate n).graph.dist
(A.refine.old n (Sum.inl (A.left e))) (A.refine.old n (Sum.inr (e,0))) : ℝ) ≀
β€–a-w 0β€– at hlo
rw [hd',norm_sub_rev] at hlo
have hc : 1 ≀ β€–w 0-aβ€–/β„“ := (le_div_iffβ‚€ hβ„“).mpr (by simpa using hlo)
change (β€–w 0-aβ€–/β„“)^2+(n:ℝ)/12 ≀ C^2 at hb
nlinarith
let R : ℝ := Real.sqrt (C^2-(n:ℝ)/12)
have hR : 0 < R := Real.sqrt_pos.mpr (by linarith)
have hR2 : R^2 = C^2-(n:ℝ)/12 := Real.sq_sqrt (by linarith)
have hp : βˆ€ j, β€–w j-aβ€–/β„“ ≀ R := by
intro j
have hh := hchild (e,j,false)
change (β€–w j-aβ€–/β„“)^2+(n:ℝ)/12 ≀ C^2 at hh
exact Real.le_sqrt_of_sq_le (by linarith)
have hm : βˆ€ j, β€–b-w jβ€–/β„“ ≀ R := by
intro j
have hh := hchild (e,j,true)
change (β€–b-w jβ€–/β„“)^2+(n:ℝ)/12 ≀ C^2 at hh
exact Real.le_sqrt_of_sq_le (by linarith)
have hs : βˆ€ i j, i β‰  j β†’ 2*β„“ ≀ β€–w i-w jβ€– := by
intro i j hij
have hh := hl (A.refine.old n (Sum.inr (e,i))) (A.refine.old n (Sum.inr (e,j)))
rw [A.old_middle_dist hA n e i j hij] at hh
have he : ((2^(n+1) : β„•) : ℝ) = 2*β„“ := by
dsimp [β„“]
norm_cast
rw [pow_succ,mul_comm]
exact he β–Έ hh
have hh := parent_step hLens R β„“ hR hβ„“ a b w hp hm hs
rw [hR2] at hh
have he : (2:ℝ)^(n+1) = 2*β„“ := by dsimp [β„“]; rw [pow_succ,mul_comm]
change (β€–b-aβ€–/(2:ℝ)^(n+1))^2+((n+1:β„•):ℝ)/12 ≀ C^2
rw [he,Nat.cast_add,Nat.cast_one]
linarith
/-- The distortion convention, including its arbitrary positive scale. -/
def EmbeddingBound (k : β„•) (f : (diamond k).V β†’ E) (C : ℝ) : Prop :=
βˆƒ s : ℝ, 0 < s ∧ βˆ€ u v,
s*distance k u v ≀ β€–f u-f vβ€– ∧ β€–f u-f vβ€– ≀ C*s*distance k u v
theorem distortion_lower (hLens : LensProperty E) (k : β„•)
(f : (diamond k).V β†’ E) (C : ℝ) (hf : EmbeddingBound k f C) :
Real.sqrt (1+(k:ℝ)/12) ≀ C := by
obtain ⟨s,hs,hf⟩ := hf
let g : (diamond k).V β†’ E := fun v => s⁻¹ β€’ f v
have hgn : βˆ€ u v, β€–g u-g vβ€– = β€–f u-f vβ€–/s := by
intro u v
dsimp [g]
rw [← smul_sub,norm_smul,Real.norm_of_nonneg (inv_nonneg.mpr hs.le)]
ring
have hl : βˆ€ u v, ((base.iterate k).graph.dist u v : ℝ) ≀ β€–g u-g vβ€– := by
intro u v
rw [hgn]
exact (le_div_iffβ‚€ hs).mpr (by simpa only [distance,mul_comm] using (hf u v).1)
have hu : βˆ€ u v, β€–g u-g vβ€– ≀ C*((base.iterate k).graph.dist u v : ℝ) := by
intro u v
rw [hgn]
exact (div_le_iffβ‚€ hs).mpr (by simpa only [distance,mul_assoc,mul_comm,mul_left_comm] using (hf u v).2)
let a := base.old k (base.left ())
let b := base.old k (base.right ())
have hd : ((base.iterate k).graph.dist a b : ℝ) = (2:ℝ)^k := by
exact_mod_cast (base.old_edge_dist base_connected k ())
have hc : 1 ≀ C := by
have hlo := hl a b
have hup := hu a b
rw [hd] at hlo hup
have hpow : 0 < (2:ℝ)^k := pow_pos (by norm_num) _
nlinarith
have hbound := edge_sq_loss hLens base base_connected k g C (by linarith) hl hu ()
have hlo : 1 ≀ β€–g b-g aβ€–/(2:ℝ)^k := by
have hh := hl a b
rw [hd,norm_sub_rev] at hh
exact (le_div_iffβ‚€ (pow_pos (by norm_num : (0:ℝ)<2) k)).mpr (by simpa using hh)
change (β€–g b-g aβ€–/(2:ℝ)^k)^2+(k:ℝ)/12 ≀ C^2 at hbound
apply Real.sqrt_le_iff.mpr
exact ⟨by linarith,by nlinarith⟩
end Distortion
end
end Diamond
/-- The distortion bound, with the positive-scale
bi-Lipschitz convention and the actual shortest-path distance on D_k. -/
theorem main_diamond_distortion (k : β„•)
(f : (Diamond.diamond k).V β†’ FullDual Vertex) (C : ℝ)
(hf : Diamond.EmbeddingBound k f C) :
Real.sqrt (1+(k:ℝ)/12) ≀ C :=
Diamond.distortion_lower main_lens k f C hf
end
end ForestSpace
end OAI