Download data/lean/OAI/Analysis/ForestSpace/Distortion.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 8.03 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Analysis/ForestSpace/Distortion.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Analysis/ForestSpace/Distortion.lean
-
curl -L -o Distortion.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Analysis/ForestSpace/Distortion.lean
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 | |