Download data/lean/OAI/Analysis/BackwardIntertwiners/WeightSeparation.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/BackwardIntertwiners/WeightSeparation.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Analysis/BackwardIntertwiners/WeightSeparation.lean
-
curl -L -o WeightSeparation.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Analysis/BackwardIntertwiners/WeightSeparation.lean
12.5 kB
| import OAI.Analysis.BackwardIntertwiners.CoefficientSupport | |
| namespace OAI | |
| namespace BackwardIntertwiners | |
| open Filter | |
| open scoped Topology | |
| noncomputable section | |
| structure QuadraticWeights (w : β€ β β) : Prop where | |
| positive : β j, 0 < w j | |
| decreasing : Antitone w | |
| convex_negative : DiscreteConvex (fun n => Real.log (w (-(n : β€)))) | |
| concave_positive : DiscreteConvex (fun n => -Real.log (w n)) | |
| root_sum : Summable (fun j : β€ => if j = 0 then 0 else w j ^ (1 / (j : β))) | |
| quadratic : β a : β, Real.log 3 < a β§ | |
| Tendsto (fun n : β => Real.log (w n) / (n : β)^2) atTop (π (-a)) β§ | |
| Tendsto (fun n : β => Real.log (w (-(n : β€))) / (n : β)^2) atTop (π a) | |
| def SupportSeparation (w : β€ β β) : Prop := | |
| β b c : β€ β β, | |
| (β j, b j β 0) β (β j, c j β 0) β | |
| (β j, βb jβ β€ w j) β (β j, βc jβ * w j β€ 1) β | |
| (β r : β, 1 β€ r β (β' j : β€, b j * c (j - r)) = 0) β | |
| β t h : β€, b t β 0 β§ c h β 0 β§ | |
| (β j, t < j β b j = 0) β§ (β j, j < h β c j = 0) β§ t β€ h | |
| def reflectedWeight (w : β€ β β) (j : β€) : β := (w (-j))β»ΒΉ | |
| lemma reflectedWeight_pos {w : β€ β β} (hw : β j, 0 < w j) (j : β€) : | |
| 0 < reflectedWeight w j := inv_pos.mpr (hw _) | |
| lemma reflectedWeight_antitone {w : β€ β β} (hw : β j, 0 < w j) (hdec : Antitone w) : | |
| Antitone (reflectedWeight w) := by | |
| intro i j hij | |
| exact (inv_le_invβ (hw _) (hw _)).mpr (hdec (neg_le_neg hij)) | |
| lemma reflected_positiveLog (w : β€ β β) : positiveLog (reflectedWeight w) = negativeLog w := by | |
| funext n | |
| simp [positiveLog, negativeLog, reflectedWeight, Real.log_inv] | |
| lemma reflected_negativeLog (w : β€ β β) : negativeLog (reflectedWeight w) = positiveLog w := by | |
| funext n | |
| simp [positiveLog, negativeLog, reflectedWeight, Real.log_inv] | |
| lemma reflected_stepRatio_summable {w : β€ β β} (hs : Summable (stepRatio w)) : | |
| Summable (stepRatio (reflectedWeight w)) := by | |
| have hh := hs.comp_injective (i := fun j : β€ => -j-1) (by | |
| intro a b hab; dsimp only at hab; omega) | |
| apply hh.congr | |
| intro j | |
| dsimp [stepRatio, reflectedWeight] | |
| have eβ : -j-1+1 = -j := by omega | |
| have eβ : -(j+1) = -j-1 := by omega | |
| rw [eβ, eβ, inv_div_inv] | |
| lemma reflected_correlations {b c : β€ β β} | |
| (hz : β r : β, 1 β€ r β (β' j : β€, b j * c (j-r)) = 0) : | |
| β r : β, 1 β€ r β (β' j : β€, c (-j) * b (-(j-r))) = 0 := by | |
| intro r hr | |
| let e : β€ β β€ := β¨fun j => (r:β€)-j, fun j => (r:β€)-j, by intro j; dsimp only; omega, by intro j; dsimp only; omegaβ© | |
| calc (β' j : β€, c (-j) * b (-(j-r))) = | |
| β' j : β€, b (e j) * c (e j-r) := by | |
| apply tsum_congr | |
| intro j | |
| dsimp [e] | |
| have eβ : (r:β€)-j = -(j-r) := by omega | |
| have eβ : (r:β€)-j-r = -j := by omega | |
| rw [eβ, show -(j-(r:β€))-(r:β€) = -j by omega, mul_comm] | |
| _ = β' j : β€, b j * c (j-r) := e.tsum_eq (fun j : β€ => b j * c (j-r)) | |
| _ = 0 := hz r hr | |
| lemma reflected_bounds {w : β€ β β} (hw : β j, 0 < w j) {b c : β€ β β} | |
| (hb : β j, βb jβ β€ w j) (hc : β j, βc jβ*w j β€ 1) : | |
| (β j, βc (-j)β β€ reflectedWeight w j) β§ | |
| (β j, βb (-j)β*reflectedWeight w j β€ 1) := by | |
| constructor | |
| Β· intro j | |
| simpa only [reflectedWeight, one_div] using (le_div_iffβ (hw (-j))).mpr (hc (-j)) | |
| Β· intro j | |
| dsimp [reflectedWeight] | |
| rw [β div_eq_mul_inv] | |
| exact (div_le_one (hw _)).mpr (hb _) | |
| theorem normalized_support_separation {w : β€ β β} (hw : β j, 0 < w j) | |
| (hdec : Antitone w) (hw0 : w 0 = 1) | |
| (hP : DiscreteConvex (negativeLog w)) (hQ : DiscreteConvex (positiveLog w)) | |
| {lam Ξ΄ : β} (hlam : Real.log 3 < lam) (hΞ΄ : lam < Ξ΄) | |
| (hqp : βαΆ n : β in atTop, Ξ΄*(n:β)^2 β€ negativeLog w n) | |
| (hqq : βαΆ n : β in atTop, Ξ΄*(n:β)^2 β€ positiveLog w n) : | |
| SupportSeparation w := by | |
| intro b c hbn hcn hb hc hz | |
| have hΞ΄0 : 0 < Ξ΄ := lt_trans (lt_trans (Real.log_pos (by norm_num : (1:β)<3)) hlam) hΞ΄ | |
| have hP0 : negativeLog w 0 = 0 := by simp [negativeLog, hw0] | |
| have hQ0 : positiveLog w 0 = 0 := by simp [positiveLog, hw0] | |
| have hs := stepRatio_summable hw hw0 hP hQ hΞ΄0 hqp hqq | |
| have hb_bd : β m : β€, β j : β€, b j β 0 β j β€ m := by | |
| by_cases hc_bd : β m : β€, β j : β€, c j β 0 β m β€ j | |
| Β· obtain β¨h, hch, hhβ© := Int.exists_least_of_bdd hc_bd hcn | |
| apply bounded_above_of_min hw hdec hw0 hs hQ hΞ΄0 hqq hb hc hch ?_ hz | |
| intro j hj | |
| by_contra hne | |
| have := hh j hne | |
| omega | |
| Β· by_contra hbu | |
| have hcu : Β¬β m : β€, β j : β€, c (-j) β 0 β j β€ m := by | |
| rintro β¨m, hmβ© | |
| apply hc_bd | |
| refine β¨-m, ?_β© | |
| intro j hj | |
| have hh := hm (-j) (by simpa using hj) | |
| omega | |
| exact no_both_unbounded (bounds_of_weight hw hb hc) hP hQ hP0 hQ0 hlam hΞ΄ hqp hqq | |
| (nat_support_unbounded hbu) (nat_support_unbounded hcu) hz | |
| obtain β¨t, hbt, htβ© := Int.exists_greatest_of_bdd hb_bd hbn | |
| have hc_bd : β m : β€, β j : β€, c j β 0 β m β€ j := by | |
| have hwr0 : reflectedWeight w 0 = 1 := by simp [reflectedWeight, hw0] | |
| have hQr : DiscreteConvex (positiveLog (reflectedWeight w)) := by | |
| rw [reflected_positiveLog]; exact hP | |
| have hqpr : βαΆ n : β in atTop, Ξ΄*(n:β)^2 β€ positiveLog (reflectedWeight w) n := by | |
| simpa only [reflected_positiveLog] using hqp | |
| obtain β¨hbr, hcrβ© := reflected_bounds hw hb hc | |
| have hzref := reflected_correlations hz | |
| have hm := bounded_above_of_min (reflectedWeight_pos hw) (reflectedWeight_antitone hw hdec) | |
| hwr0 (reflected_stepRatio_summable hs) hQr hΞ΄0 hqpr hbr hcr | |
| (h := -t) (by simpa using hbt) (by | |
| intro j hj | |
| by_contra hne | |
| have hh := ht (-j) hne | |
| omega) hzref | |
| obtain β¨m, hmβ© := hm | |
| refine β¨-m, ?_β© | |
| intro j hj | |
| have hh := hm (-j) (by simpa using hj) | |
| omega | |
| obtain β¨h, hch, hhβ© := Int.exists_least_of_bdd hc_bd hcn | |
| have hbmax : β j : β€, t < j β b j = 0 := by | |
| intro j hj | |
| by_contra hne | |
| have := ht j hne | |
| omega | |
| have hcmin : β j : β€, j < h β c j = 0 := by | |
| intro j hj | |
| by_contra hne | |
| have := hh j hne | |
| omega | |
| refine β¨t, h, hbt, hch, hbmax, hcmin, ?_β© | |
| by_contra! hth | |
| let r := (t-h).toNat | |
| have hr : 1 β€ r := by dsimp [r]; omega | |
| have hri : (r:β€) = t-h := by dsimp [r]; omega | |
| have he : (β' j : β€, b j * c (j-r)) = b t * c h := by | |
| rw [tsum_eq_single t] | |
| Β· congr 2 | |
| omega | |
| Β· intro j hj | |
| by_cases hbj : b j = 0 | |
| Β· simp [hbj] | |
| Β· have htj := ht j hbj | |
| rw [hcmin _ (by omega), mul_zero] | |
| have hzero := hz r hr | |
| rw [he] at hzero | |
| exact (mul_ne_zero hbt hch) hzero | |
| lemma DiscreteConvex.add_const {G : β β β} (h : DiscreteConvex G) (c : β) : | |
| DiscreteConvex (fun n => G n+c) := by | |
| intro i j hij | |
| simpa only [add_sub_add_right_eq_sub] using h hij | |
| lemma eventually_quadratic_lower {G : β β β} {a Ξ΄ : β} (hΞ΄a : Ξ΄ < a) | |
| (ht : Tendsto (fun n => G n / (n:β)^2) atTop (π a)) : | |
| βαΆ n : β in atTop, Ξ΄*(n:β)^2 β€ G n := by | |
| filter_upwards [ht (eventually_gt_nhds hΞ΄a), eventually_ge_atTop 1] with n hn hn1 | |
| have hnpos : 0 < (n:β)^2 := sq_pos_of_pos (Nat.cast_pos.mpr (by omega)) | |
| exact ((lt_div_iffβ hnpos).mp hn).le | |
| theorem quadratic_support_separation (w : β€ β β) (hw : QuadraticWeights w) : | |
| SupportSeparation w := by | |
| let W := fun j : β€ => w j / w 0 | |
| have hw0 : 0 < w 0 := hw.positive 0 | |
| have hWpos (j : β€) : 0 < W j := div_pos (hw.positive j) hw0 | |
| have hWdec : Antitone W := by | |
| intro i j hij | |
| exact div_le_div_of_nonneg_right (hw.decreasing hij) hw0.le | |
| have hW0 : W 0 = 1 := div_self (ne_of_gt hw0) | |
| have hlog (j : β€) : Real.log (w j / w 0) = Real.log (w j) - Real.log (w 0) := | |
| Real.log_div (ne_of_gt (hw.positive j)) (ne_of_gt hw0) | |
| have hP : DiscreteConvex (negativeLog W) := by | |
| have heq : negativeLog W = fun n : β => Real.log (w (-(n:β€))) + -Real.log (w 0) := by | |
| funext n | |
| simp only [negativeLog, W, hlog, sub_eq_add_neg] | |
| rw [heq] | |
| exact hw.convex_negative.add_const _ | |
| have hQ : DiscreteConvex (positiveLog W) := by | |
| have heq : positiveLog W = fun n : β => -Real.log (w n) + Real.log (w 0) := by | |
| funext n | |
| simp only [positiveLog, W, hlog] | |
| ring | |
| rw [heq] | |
| exact hw.concave_positive.add_const _ | |
| obtain β¨a, ha, hqa, hpaβ© := hw.quadratic | |
| have hnat : Tendsto (fun n : β => (n:β)^2) atTop atTop := by | |
| exact (tendsto_pow_atTop (by norm_num : 2 β 0)).comp tendsto_natCast_atTop_atTop | |
| have hsmall : Tendsto (fun n : β => Real.log (w 0) / (n:β)^2) atTop (π 0) := by | |
| simpa only [div_eq_mul_inv, mul_zero, Function.comp_def] using | |
| (tendsto_inv_atTop_zero.comp hnat).const_mul (Real.log (w 0)) | |
| have htP : Tendsto (fun n : β => negativeLog W n / (n:β)^2) atTop (π a) := by | |
| simpa only [negativeLog, W, hlog, sub_div, sub_zero] using hpa.sub hsmall | |
| have htQ : Tendsto (fun n : β => positiveLog W n / (n:β)^2) atTop (π a) := by | |
| have heq : (fun n : β => positiveLog W n / (n:β)^2) = | |
| (fun n : β => -(Real.log (w n) / (n:β)^2) + Real.log (w 0) / (n:β)^2) := by | |
| funext n | |
| simp only [positiveLog, W, hlog] | |
| ring | |
| rw [heq] | |
| simpa only [neg_neg, add_zero] using hqa.neg.add hsmall | |
| obtain β¨lam, hlam, hlamaβ© := exists_between ha | |
| obtain β¨Ξ΄, hΞ΄, hΞ΄aβ© := exists_between hlama | |
| have hsep := normalized_support_separation hWpos hWdec hW0 hP hQ hlam hΞ΄ | |
| (eventually_quadratic_lower hΞ΄a htP) (eventually_quadratic_lower hΞ΄a htQ) | |
| intro b c hbn hcn hb hc hz | |
| let C : β := (w 0 : β) | |
| have hC : C β 0 := by dsimp [C]; exact_mod_cast (ne_of_gt hw0) | |
| have hCnorm : βCβ = w 0 := by simpa [C] using Real.norm_of_nonneg hw0.le | |
| let b' := fun j => b j / C | |
| let c' := fun j => C * c j | |
| have hbn' : β j, b' j β 0 := by | |
| obtain β¨j, hjβ© := hbn | |
| exact β¨j, div_ne_zero hj hCβ© | |
| have hcn' : β j, c' j β 0 := by | |
| obtain β¨j, hjβ© := hcn | |
| exact β¨j, mul_ne_zero hC hjβ© | |
| have hb' (j : β€) : βb' jβ β€ W j := by | |
| dsimp [b', W] | |
| rw [norm_div, hCnorm] | |
| exact div_le_div_of_nonneg_right (hb j) hw0.le | |
| have hc' (j : β€) : βc' jβ * W j β€ 1 := by | |
| dsimp [c', W] | |
| rw [norm_mul, hCnorm] | |
| have he : w 0 * βc jβ * (w j / w 0) = βc jβ * w j := by field_simp | |
| rw [he] | |
| exact hc j | |
| have hz' (r : β) (hr : 1 β€ r) : (β' j : β€, b' j * c' (j-r)) = 0 := by | |
| have he (j : β€) : b' j * c' (j-r) = b j * c (j-r) := by | |
| dsimp [b', c'] | |
| field_simp | |
| simp only [he] | |
| exact hz r hr | |
| have hh := hsep b' c' hbn' hcn' hb' hc' hz' | |
| simpa [b', c', hC] using hh | |
| lemma SupportSeparation.of_bounded {w : β€ β β} (hsep : SupportSeparation w) | |
| {b c : β€ β β} (hbn : β j, b j β 0) (hcn : β j, c j β 0) | |
| {B C : β} (hB : 0 < B) (hC : 0 < C) | |
| (hb : β j, βb jβ β€ B*w j) (hc : β j, βc jβ*w j β€ C) | |
| (hz : β r : β, 1 β€ r β (β' j : β€, b j * c (j-r)) = 0) : | |
| β t h : β€, b t β 0 β§ c h β 0 β§ | |
| (β j, t < j β b j = 0) β§ (β j, j < h β c j = 0) β§ t β€ h := by | |
| have hBC : (B:β) β 0 := by exact_mod_cast (ne_of_gt hB) | |
| have hCC : (C:β) β 0 := by exact_mod_cast (ne_of_gt hC) | |
| let b' := fun j => b j / (B:β) | |
| let c' := fun j => c j / (C:β) | |
| have hbn' : β j, b' j β 0 := by | |
| obtain β¨j, hjβ© := hbn | |
| exact β¨j, div_ne_zero hj hBCβ© | |
| have hcn' : β j, c' j β 0 := by | |
| obtain β¨j, hjβ© := hcn | |
| exact β¨j, div_ne_zero hj hCCβ© | |
| have hb' (j : β€) : βb' jβ β€ w j := by | |
| dsimp [b'] | |
| rw [norm_div, Complex.norm_real, Real.norm_of_nonneg hB.le] | |
| exact (div_le_iffβ hB).mpr (by simpa only [mul_comm] using hb j) | |
| have hc' (j : β€) : βc' jβ*w j β€ 1 := by | |
| dsimp [c'] | |
| rw [norm_div, Complex.norm_real, Real.norm_of_nonneg hC.le, div_mul_eq_mul_div] | |
| exact (div_le_one hC).mpr (hc j) | |
| have hz' (r : β) (hr : 1 β€ r) : (β' j : β€, b' j * c' (j-r)) = 0 := by | |
| have he (j : β€) : b' j * c' (j-r) = (b j*c (j-r)) / ((B:β)*(C:β)) := by | |
| dsimp [b', c']; ring | |
| simp only [he, tsum_div_const, hz r hr, zero_div] | |
| have hh := hsep b' c' hbn' hcn' hb' hc' hz' | |
| simpa [b', c', hBC, hCC] using hh | |
| end | |
| end BackwardIntertwiners | |
| end OAI | |