Download data/lean/OAI/Analysis/DiamondDistortion/Stretch.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 12.5 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Analysis/DiamondDistortion/Stretch.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Analysis/DiamondDistortion/Stretch.lean
-
curl -L -o Stretch.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Analysis/DiamondDistortion/Stretch.lean
12.5 kB
| import OAI.Analysis.DiamondDistortion.DiamondGraph | |
| namespace OAI | |
| universe u v | |
| noncomputable section | |
| open scoped BigOperators Classical Topology | |
| open Set | |
| namespace DiamondDistortion | |
| namespace Diamond | |
| variable {X : Type*} [NormedAddCommGroup X] [NormedSpace β X] | |
| lemma norm_center_le {x y : X} {R : β} (hp : βx+yβ β€ R) (hm : βx-yβ β€ R) : | |
| βxβ β€ R := by | |
| have he : x=(1/2:β) β’ ((x+y)+(x-y)) := by module | |
| calc | |
| βxβ = (1/2:β)*β(x+y)+(x-y)β := by | |
| conv_lhs => rw [he] | |
| rw [norm_smul,Real.norm_eq_abs,abs_of_pos (by norm_num : (0:β)<1/2)] | |
| _ β€ (1/2:β)*(βx+yβ+βx-yβ) := mul_le_mul_of_nonneg_left (norm_add_le _ _) (by norm_num) | |
| _ β€ R := by linarith | |
| lemma norm_deviation_le {x y : X} {R : β} (hp : βx+yβ β€ R) (hm : βx-yβ β€ R) : | |
| βyβ β€ R := norm_center_le (x := y) (y := x) (by simpa only [add_comm] using hp) | |
| (by simpa only [norm_sub_rev] using hm) | |
| lemma slope_lower {k : β} (f : Vertex k β X) {s : β} | |
| (hl : β u v,s*distance k u v β€ βf u-f vβ) (e : Edge k) : s β€ βslope f eβ := by | |
| have he := hl (endpoint k e false) (endpoint k e true) | |
| rw [distance_edge] at he | |
| rw [slope,norm_smul,Real.norm_eq_abs,abs_of_pos (by positivity : 0<(2:β)^k),norm_sub_rev] | |
| calc | |
| s = (2:β)^k*(s*(1/(2:β)^k)) := by field_simp | |
| _ β€ _ := mul_le_mul_of_nonneg_left he (by positivity) | |
| lemma slope_upper {k : β} (f : Vertex k β X) {L : β} | |
| (hu : β u v,βf u-f vβ β€ L*distance k u v) (e : Edge k) : βslope f eβ β€ L := by | |
| have he := hu (endpoint k e false) (endpoint k e true) | |
| rw [distance_edge] at he | |
| rw [slope,norm_smul,Real.norm_eq_abs,abs_of_pos (by positivity : 0<(2:β)^k),norm_sub_rev] | |
| calc | |
| _ β€ (2:β)^k*(L*(1/(2:β)^k)) := mul_le_mul_of_nonneg_left he (by positivity) | |
| _ = _ := by field_simp | |
| lemma old_lower {X : Type*} [NormedAddCommGroup X] [NormedSpace β X] {k : β} (f : Vertex (k+1) β X) {s : β} | |
| (hl : β u v,s*distance (k+1) u v β€ βf u-f vβ) : | |
| β u v,s*distance k u v β€ βf (Sum.inl u)-f (Sum.inl v)β := by | |
| intro u v | |
| simpa only [distance_old] using hl (Sum.inl u) (Sum.inl v) | |
| /-- Abstract multiplicative backward iteration, retaining every all-pairs lower | |
| bound and making no assertion of an attained stage supremum. -/ | |
| lemma iterate_contraction {s D c : β} (hc : 0 β€ c) (hc1 : c β€ 1) | |
| (hstep : β (x : X) (z : β β X) (R : β),0 β€ R β R β€ D β s β€ βxβ β | |
| (β i,βx+z iβ β€ R) β (β i,βx-z iβ β€ R) β | |
| (β i j,i β j β 2*s β€ βz i-z jβ) β βxβ β€ c*R) | |
| (k : β) (f : Vertex k β X) {L : β} (hL : 0 β€ L) (hLD : L β€ D) | |
| (hl : β u v,s*distance k u v β€ βf u-f vβ) | |
| (hb : β e,βslope f eβ β€ L) : s β€ c^k*L := by | |
| induction k generalizing L with | |
| | zero => simpa using (slope_lower f hl ()).trans (hb ()) | |
| | succ n ih => | |
| have hold : β e,βslope (fun v => f (Sum.inl v)) eβ β€ c*L := by | |
| intro e | |
| apply hstep _ (deviation f e) L hL hLD (slope_lower _ (old_lower f hl) e) | |
| Β· intro i | |
| simpa only [slope_plus_deviation] using hb (e,i,false) | |
| Β· intro i | |
| simpa only [slope_minus_deviation] using hb (e,i,true) | |
| Β· exact fun _ _ hij => deviation_separated f hl e hij | |
| have hcL : c*L β€ D := (mul_le_of_le_one_left hL hc1).trans hLD | |
| have h := ih (fun v => f (Sum.inl v)) (mul_nonneg hc hL) hcL (old_lower f hl) hold | |
| simpa only [pow_succ,mul_assoc] using h | |
| /-- Abstract additive backward iteration. The existence of old edges ensures | |
| nonnegativity of each improved bound, including the last nonempty stage. -/ | |
| lemma iterate_additive {s D Ξ΄ : β} (hΞ΄ : 0 β€ Ξ΄) | |
| (hstep : β (x : X) (z : β β X) (R : β),0 β€ R β R β€ D β s β€ βxβ β | |
| (β i,βx+z iβ β€ R) β (β i,βx-z iβ β€ R) β | |
| (β i j,i β j β 2*s β€ βz i-z jβ) β βxβ β€ R-Ξ΄) | |
| (k : β) (f : Vertex k β X) {L : β} (hL : 0 β€ L) (hLD : L β€ D) | |
| (hl : β u v,s*distance k u v β€ βf u-f vβ) | |
| (hb : β e,βslope f eβ β€ L) : s+(k:β)*Ξ΄ β€ L := by | |
| induction k generalizing L with | |
| | zero => simpa using (slope_lower f hl ()).trans (hb ()) | |
| | succ n ih => | |
| have hold : β e,βslope (fun v => f (Sum.inl v)) eβ β€ L-Ξ΄ := by | |
| intro e | |
| apply hstep _ (deviation f e) L hL hLD (slope_lower _ (old_lower f hl) e) | |
| Β· intro i | |
| simpa only [slope_plus_deviation] using hb (e,i,false) | |
| Β· intro i | |
| simpa only [slope_minus_deviation] using hb (e,i,true) | |
| Β· exact fun _ _ hij => deviation_separated f hl e hij | |
| have hnew : 0 β€ L-Ξ΄ := (norm_nonneg _).trans (hold (baseEdge n)) | |
| have h := ih (fun v => f (Sum.inl v)) hnew (by linarith) (old_lower f hl) hold | |
| push_cast | |
| linarith | |
| def SquareLens (X : Type*) [NormedAddCommGroup X] (b : β) : Prop := | |
| β (x : X) (z : β β X) (R Ξ΅ : β),0 β€ R β 0 < Ξ΅ β | |
| (β i,βx+z iβ β€ R) β (β i,βx-z iβ β€ R) β | |
| (β i j,i β j β Ξ΅ β€ βz i-z jβ) β βxβ^2+b*Ξ΅^2 β€ R^2 | |
| lemma squared_stretch_loss_general {b : β} (hX : SquareLens X b) (k : β) (f : Vertex k β X) | |
| {s B : β} (hs : 0 < s) | |
| (hl : β u v,s*distance k u v β€ βf u-f vβ) | |
| (hb : β e,βslope f eβ^2 β€ B) : s^2*(1+4*b*(k:β)) β€ B := by | |
| induction k generalizing B with | |
| | zero => | |
| have h := slope_lower f hl () | |
| have h0 := hb () | |
| norm_num | |
| nlinarith [sq_nonneg (s-βslope f ()β)] | |
| | succ n ih => | |
| have hB : 0 β€ B := (sq_nonneg _).trans (hb (baseEdge (n+1))) | |
| have hold : β e,βslope (fun v => f (Sum.inl v)) eβ^2 β€ B-4*b*s^2 := by | |
| intro e | |
| have hp : β i,βslope (fun v => f (Sum.inl v)) e+deviation f e iβ β€ Real.sqrt B := by | |
| intro i | |
| rw [slope_plus_deviation] | |
| exact (Real.le_sqrt (norm_nonneg _) hB).mpr (hb _) | |
| have hm : β i,βslope (fun v => f (Sum.inl v)) e-deviation f e iβ β€ Real.sqrt B := by | |
| intro i | |
| rw [slope_minus_deviation] | |
| exact (Real.le_sqrt (norm_nonneg _) hB).mpr (hb _) | |
| have h := hX (slope (fun v => f (Sum.inl v)) e) (deviation f e) | |
| (Real.sqrt B) (2*s) (Real.sqrt_nonneg _) (by positivity) hp hm | |
| (fun _ _ hij => deviation_separated f hl e hij) | |
| rw [Real.sq_sqrt hB] at h | |
| nlinarith | |
| have hind := ih (fun v => f (Sum.inl v)) (old_lower f hl) hold | |
| push_cast | |
| nlinarith only [hind] | |
| lemma squared_transfer {b : β} (_hb : 0 < b) (hX : SquareLens X b) | |
| (k : β) (f : Vertex k β X) (D s : β) (h : HasDistortion k f D s) : | |
| 1+4*b*(k:β) β€ D^2 := by | |
| obtain β¨hD,hs,hβ© := h | |
| have hbound : β e,βslope f eβ^2 β€ (D*s)^2 := by | |
| intro e | |
| have hh := slope_upper f (fun u v => (h u v).2) e | |
| exact (sq_le_sqβ (norm_nonneg _) (mul_nonneg (by linarith) hs.le)).mpr hh | |
| have h' := squared_stretch_loss_general hX k f hs (fun u v => (h u v).1) hbound | |
| have hp : 0 < s^2 := sq_pos_of_pos hs | |
| have hmul : s^2*(1+4*b*(k:β)) β€ s^2*D^2 := by nlinarith only [h'] | |
| exact (mul_le_mul_iff_rightβ hp).mp hmul | |
| lemma normalized_distortion {k : β} (f : Vertex k β X) {D s : β} | |
| (h : HasDistortion k f D s) : | |
| HasDistortion k (fun v => sβ»ΒΉ β’ f v) D 1 := by | |
| obtain β¨hD,hs,hβ© := h | |
| refine β¨hD,by norm_num,?_β© | |
| intro u v | |
| rw [β smul_sub,norm_smul,Real.norm_of_nonneg (inv_nonneg.mpr hs.le)] | |
| have hl := mul_le_mul_of_nonneg_left (h u v).1 (inv_nonneg.mpr hs.le) | |
| have hu := mul_le_mul_of_nonneg_left (h u v).2 (inv_nonneg.mpr hs.le) | |
| have he : sβ»ΒΉ*(s*distance k u v)=distance k u v := by field_simp | |
| have he' : sβ»ΒΉ*(D*s*distance k u v)=D*distance k u v := by field_simp | |
| rw [he] at hl | |
| rw [he'] at hu | |
| simpa only [one_mul,mul_one] using And.intro hl hu | |
| lemma upper_one_normalization {k : β} (f : Vertex k β X) {D s : β} | |
| (h : HasDistortion k f D s) : | |
| β u v,Dβ»ΒΉ*distance k u v β€ β(D*s)β»ΒΉ β’ f u-(D*s)β»ΒΉ β’ f vβ β§ | |
| β(D*s)β»ΒΉ β’ f u-(D*s)β»ΒΉ β’ f vβ β€ distance k u v := by | |
| obtain β¨hD,hs,hβ© := h | |
| have hD0 : 0 < D := by linarith | |
| have hDs : 0 < D*s := mul_pos hD0 hs | |
| intro u v | |
| rw [β smul_sub,norm_smul,Real.norm_of_nonneg (inv_nonneg.mpr hDs.le)] | |
| have hl := mul_le_mul_of_nonneg_left (h u v).1 (inv_nonneg.mpr hDs.le) | |
| have hu := mul_le_mul_of_nonneg_left (h u v).2 (inv_nonneg.mpr hDs.le) | |
| have he : (D*s)β»ΒΉ*(s*distance k u v)=Dβ»ΒΉ*distance k u v := by field_simp | |
| have he' : (D*s)β»ΒΉ*(D*s*distance k u v)=distance k u v := by field_simp | |
| rw [he] at hl | |
| rw [he'] at hu | |
| exact β¨hl,huβ© | |
| def RadialLens (X : Type*) [NormedAddCommGroup X] (C : β) : Prop := | |
| β (x : X) (z : β β X) (R Ξ΅ : β),0 β€ R β 0 < Ξ΅ β | |
| (β i,βx+z iβ β€ R) β (β i,βx-z iβ β€ R) β | |
| (β i j,i β j β Ξ΅ β€ βz i-z jβ) β Ξ΅^2/4 β€ C^2*R*(R-βxβ) | |
| theorem radial_transfer {C : β} (hC : 0 < C) (hX : RadialLens X C) | |
| (k : β) (f : Vertex k β X) (D s : β) (hf : HasDistortion k f D s) : | |
| (k:β) β€ C^2*D*(D-1) := by | |
| obtain β¨hD,_,hβ© := normalized_distortion f hf | |
| have hD0 : 0 < D := by linarith | |
| have hP : 0 < C^2*D := mul_pos (sq_pos_of_pos hC) hD0 | |
| let Ξ΄ : β := 1/(C^2*D) | |
| have hΞ΄ : 0 β€ Ξ΄ := by dsimp [Ξ΄]; positivity | |
| have hstep : β (x : X) (z : β β X) (R : β),0 β€ R β R β€ D β 1 β€ βxβ β | |
| (β i,βx+z iβ β€ R) β (β i,βx-z iβ β€ R) β | |
| (β i j,i β j β 2*1 β€ βz i-z jβ) β βxβ β€ R-Ξ΄ := by | |
| intro x z R hR hRD hx hp hm hsep | |
| have he := hX x z R 2 hR (by norm_num) hp hm (by simpa using hsep) | |
| have hxr := norm_center_le (hp 0) (hm 0) | |
| have hmul := mul_le_mul_of_nonneg_right | |
| (mul_le_mul_of_nonneg_left hRD (sq_nonneg C)) (sub_nonneg.mpr hxr) | |
| have hh : 1 β€ C^2*D*(R-βxβ) := by norm_num at he; exact he.trans hmul | |
| have hh' : Ξ΄ β€ R-βxβ := (div_le_iffβ hP).mpr (by nlinarith only [hh]) | |
| linarith | |
| have hi := iterate_additive hΞ΄ hstep k (fun v => sβ»ΒΉ β’ f v) hD0.le le_rfl | |
| (fun u v => by simpa using (h u v).1) | |
| (fun e => slope_upper _ (fun u v => by simpa using (h u v).2) e) | |
| have hquot : (k:β)/(C^2*D) β€ D-1 := by | |
| dsimp [Ξ΄] at hi | |
| rw [mul_one_div] at hi | |
| linarith | |
| have hmul := (div_le_iffβ hP).mp hquot | |
| nlinarith only [hmul] | |
| def UnitLensBound (X : Type*) [NormedAddCommGroup X] (Ξ΅ Ο : β) : Prop := | |
| β (x : X) (z : β β X), (β i,βx+z iβ β€ 1) β (β i,βx-z iβ β€ 1) β | |
| (β i j,i β j β Ξ΅ β€ βz i-z jβ) β βxβ β€ Ο | |
| theorem backward {Ξ± Ο : β} (hΞ± : 0 < Ξ±) (_hΞ±1 : Ξ± β€ 1) (hΟ : 0 β€ Ο) (hΟ1 : Ο < 1) | |
| (hX : UnitLensBound X (2*Ξ±) Ο) (k : β) (f : Vertex k β X) | |
| (hl : β u v,Ξ±*distance k u v β€ βf u-f vβ) | |
| (hu : β u v,βf u-f vβ β€ distance k u v) : Ξ± β€ Ο^k := by | |
| have hstep : β (x : X) (z : β β X) (R : β),0 β€ R β R β€ 1 β Ξ± β€ βxβ β | |
| (β i,βx+z iβ β€ R) β (β i,βx-z iβ β€ R) β | |
| (β i j,i β j β 2*Ξ± β€ βz i-z jβ) β βxβ β€ Ο*R := by | |
| intro x z R hR hR1 hx hp hm hs | |
| have hxr := norm_center_le (hp 0) (hm 0) | |
| have hR0 : 0 < R := lt_of_lt_of_le hΞ± (hx.trans hxr) | |
| have hscale (u : X) : βRβ»ΒΉ β’ uβ=Rβ»ΒΉ*βuβ := by | |
| rw [norm_smul,Real.norm_of_nonneg (inv_nonneg.mpr hR)] | |
| have hi : Rβ»ΒΉ*R=1 := inv_mul_cancelβ hR0.ne' | |
| have hinv : 1 β€ Rβ»ΒΉ := by | |
| rw [β one_div] | |
| exact (le_div_iffβ hR0).mpr (by simpa using hR1) | |
| have hb := hX (Rβ»ΒΉ β’ x) (fun i => Rβ»ΒΉ β’ z i) | |
| (fun i => by | |
| rw [β smul_add,hscale] | |
| exact (mul_le_mul_of_nonneg_left (hp i) (inv_nonneg.mpr hR)).trans hi.le) | |
| (fun i => by | |
| rw [β smul_sub,hscale] | |
| exact (mul_le_mul_of_nonneg_left (hm i) (inv_nonneg.mpr hR)).trans hi.le) | |
| (fun i j hij => by | |
| rw [β smul_sub,hscale] | |
| exact (le_mul_of_one_le_left (by positivity : 0 β€ 2*Ξ±) hinv).trans | |
| (mul_le_mul_of_nonneg_left (hs i j hij) (inv_nonneg.mpr hR))) | |
| rw [hscale] at hb | |
| have hh := mul_le_mul_of_nonneg_left hb hR | |
| rw [β mul_assoc,mul_inv_cancelβ hR0.ne',one_mul] at hh | |
| simpa only [mul_comm] using hh | |
| have h := iterate_contraction hΟ hΟ1.le hstep k f (by norm_num : (0:β) β€ 1) le_rfl hl | |
| (fun e => slope_upper f (fun u v => by simpa using hu u v) e) | |
| simpa only [mul_one] using h | |
| end Diamond | |
| end DiamondDistortion | |
| end | |
| end OAI | |