Download data/lean/OAI/Probability/SKGap/Localization/AttractionBasinIUnion.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 9.09 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/SKGap/Localization/AttractionBasinIUnion.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Probability/SKGap/Localization/AttractionBasinIUnion.lean
-
curl -L -o AttractionBasinIUnion.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/SKGap/Localization/AttractionBasinIUnion.lean
9.09 kB
| import Mathlib | |
| import OAI.Probability.SKGap.Localization.TapPotential | |
| namespace OAI | |
| section | |
| noncomputable section | |
| open scoped BigOperators | |
| open Real Matrix Set Filter Function | |
| open scoped Topology | |
| namespace SKGap | |
| section Basins | |
| variable {X : Type*} [TopologicalSpace X] (T : X β X) | |
| lemma attractionBasin_eq_iUnion {p : X} {U : Set X} (hU : IsOpen U) (hp : p β U) | |
| (hatt : U β attractionBasin T p) : | |
| attractionBasin T p = β k : β, (T^[k]) β»ΒΉ' U := by | |
| ext x | |
| constructor | |
| Β· intro hx | |
| have h := hx.eventually (hU.mem_nhds hp) | |
| obtain β¨k, hkβ© := h.exists | |
| exact mem_iUnion.mpr β¨k, hkβ© | |
| Β· intro hx | |
| obtain β¨k, hkβ© := mem_iUnion.mp hx | |
| exact (mem_attractionBasin_iterate_iff T p x k).mp (hatt hk) | |
| lemma isOpen_attractionBasin (hT : Continuous T) {p : X} {U : Set X} | |
| (hU : IsOpen U) (hp : p β U) (hatt : U β attractionBasin T p) : | |
| IsOpen (attractionBasin T p) := by | |
| rw [attractionBasin_eq_iUnion T hU hp hatt] | |
| exact isOpen_iUnion (fun k => hU.preimage (hT.iterate k)) | |
| lemma disjoint_attractionBasins [T2Space X] {p q : X} (hpq : p β q) : | |
| Disjoint (attractionBasin T p) (attractionBasin T q) := by | |
| rw [disjoint_left] | |
| intro x hx hy | |
| exact hpq (tendsto_nhds_unique hx hy) | |
| end Basins | |
| theorem lyapunov_unique_fixed_point {X : Type*} [TopologicalSpace X] [CompactSpace X] | |
| [ConnectedSpace X] [T2Space X] | |
| (T : X β X) (hT : Continuous T) (Ο : X β β) (hΟ : Continuous Ο) | |
| (hstrict : β x, T x β x β Ο (T x) < Ο x) | |
| (hattract : β p, T p = p β β U : Set X, IsOpen U β§ p β U β§ | |
| U β attractionBasin T p) : β! p, T p = p := by | |
| have hopen (p) (hp : T p = p) : IsOpen (attractionBasin T p) := by | |
| obtain β¨U, hU, hpU, hattβ© := hattract p hp | |
| exact isOpen_attractionBasin T hT hU hpU hatt | |
| have hcover (x : X) : β p, T p = p β§ x β attractionBasin T p := by | |
| let U := β p : {p // T p = p}, attractionBasin T p.val | |
| have hU : IsOpen U := isOpen_iUnion (fun p => hopen p.val p.property) | |
| have hfixed (p) (hp : T p = p) : p β U := | |
| mem_iUnion.mpr β¨β¨p, hpβ©, fixed_mem_attractionBasin T hpβ© | |
| obtain β¨k, hkβ© := lyapunov_eventually_hits T hT Ο hΟ hstrict hU hfixed x | |
| obtain β¨p, hpβ© := mem_iUnion.mp hk | |
| exact β¨p.val, p.property, (mem_attractionBasin_iterate_iff T p.val x k).mp hpβ© | |
| obtain β¨p, hpβ© := lyapunov_fixed_point T Ο hΟ hstrict | |
| refine β¨p, hp, fun q hq => ?_β© | |
| by_contra hqp | |
| let V := β q : {q // T q = q β§ q β p}, attractionBasin T q.val | |
| have hV : IsOpen V := isOpen_iUnion (fun q => hopen q.val q.property.1) | |
| have hdisj : Disjoint (attractionBasin T p) V := by | |
| rw [disjoint_iUnion_right] | |
| intro q | |
| exact disjoint_attractionBasins T q.property.2.symm | |
| have hcov : (univ : Set X) β attractionBasin T p βͺ V := by | |
| intro x _ | |
| obtain β¨r, hr, hxβ© := hcover x | |
| by_cases he : r = p | |
| Β· subst r | |
| exact Or.inl hx | |
| Β· exact Or.inr (mem_iUnion.mpr β¨β¨r, hr, heβ©, hxβ©) | |
| have hconn := IsPreconnected.subset_or_subset (hopen p hp) hV hdisj hcov | |
| isPreconnected_univ | |
| rcases hconn with hconn | hconn | |
| Β· have hqp' := tendsto_nhds_unique (hconn (mem_univ q)) | |
| (fixed_mem_attractionBasin T hq) | |
| exact hqp hqp'.symm | |
| Β· exact disjoint_left.mp hdisj (fixed_mem_attractionBasin T hp) (hconn (mem_univ p)) | |
| theorem local_contraction_attracts {X : Type*} [MetricSpace X] | |
| {T : X β X} {p : X} (hp : T p = p) {K : NNReal} (hK : K < 1) | |
| {U : Set X} (hU : U β π p) (hlip : LipschitzOnWith K T U) : | |
| β V : Set X, IsOpen V β§ p β V β§ V β attractionBasin T p := by | |
| obtain β¨Ξ΅, hΞ΅, hballβ© := Metric.mem_nhds_iff.mp hU | |
| have hpU : p β U := hball (Metric.mem_ball_self hΞ΅) | |
| have hmaps : MapsTo T (Metric.ball p Ξ΅) (Metric.ball p Ξ΅) := by | |
| intro x hx | |
| have h := hlip.dist_le_mul x (hball hx) p hpU | |
| rw [hp] at h | |
| exact h.trans_lt ((mul_le_of_le_one_left (dist_nonneg : 0 β€ dist x p) | |
| (show (K:β) β€ 1 by exact_mod_cast hK.le)).trans_lt hx) | |
| refine β¨Metric.ball p Ξ΅, Metric.isOpen_ball, Metric.mem_ball_self hΞ΅, ?_β© | |
| intro x hx | |
| have hbd (n : β) : dist (T^[n] x) p β€ (K:β)^n * dist x p := by | |
| induction n with | |
| | zero => simp | |
| | succ n ih => | |
| rw [iterate_succ_apply'] | |
| have h := hlip.dist_le_mul (T^[n] x) (hball (hmaps.iterate n hx)) p hpU | |
| rw [hp] at h | |
| exact h.trans (by simpa only [pow_succ', mul_assoc] using | |
| mul_le_mul_of_nonneg_left ih K.coe_nonneg) | |
| have ht := (tendsto_pow_atTop_nhds_zero_of_lt_one K.coe_nonneg | |
| (show (K:β) < 1 by exact_mod_cast hK)).mul_const (dist x p) | |
| rw [zero_mul] at ht | |
| exact Metric.tendsto_atTop.mpr (fun Ξ΄ hΞ΄ => by | |
| obtain β¨N, hNβ© := eventually_atTop.mp (ht.eventually (gt_mem_nhds hΞ΄)) | |
| exact β¨N, fun n hn => (hbd n).trans_lt (hN n hn)β©) | |
| theorem strict_derivative_attracts {E : Type*} [NormedAddCommGroup E] [NormedSpace β E] | |
| {T : E β E} {p : E} {D : E βL[β] E} | |
| (hp : T p = p) (hD : HasStrictFDerivAt T D p) (hnorm : βDβ < 1) : | |
| β U : Set E, IsOpen U β§ p β U β§ U β attractionBasin T p := by | |
| have hn : βDββ < 1 := by exact_mod_cast hnorm | |
| obtain β¨K, hDK, hKβ© := exists_between hn | |
| obtain β¨U, hU, hlipβ© := hD.exists_lipschitzOnWith_of_nnnorm_lt K hDK | |
| exact local_contraction_attracts hp hK hU hlip | |
| end SKGap | |
| noncomputable section | |
| open Set Function Real | |
| open scoped Topology NNReal | |
| namespace SKGap | |
| section GradientDescent | |
| variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace β E] | |
| theorem lipschitz_gradient_remainder {Ο : E β β} {G : E β E} {s : Set E} | |
| (hs : Convex β s) (hgrad : β x β s, HasFDerivAt Ο (innerSL β (G x)) x) | |
| {L : ββ₯0} (hG : LipschitzOnWith L G s) {x y : E} (hx : x β s) (hy : y β s) : | |
| |Ο y - Ο x - inner β (G x) (y-x)| β€ (L:β)*βy-xβ^2 := by | |
| let d := y-x | |
| let β : β βα΅[β] E := AffineMap.lineMap x y | |
| let f := fun t : β => Ο (β t) - t * inner β (G x) d | |
| let f' := fun t : β => inner β (G (β t) - G x) d | |
| have hβ (t : β) : β t = x + t β’ d := by | |
| simp only [β, d, AffineMap.lineMap_apply_module] | |
| module | |
| have hmem (t : β) (ht : t β Icc (0:β) 1) : β t β s := | |
| hs.mapsTo_lineMap hx hy ht | |
| have hf (t : β) (ht : t β Icc (0:β) 1) : | |
| HasDerivWithinAt f (f' t) (Icc (0:β) 1) t := by | |
| have hd := ((hgrad (β t) (hmem t ht)).comp_hasDerivAt t | |
| AffineMap.hasDerivAt_lineMap).sub | |
| ((hasDerivAt_id t).mul_const (inner β (G x) d)) | |
| convert! (hd.hasDerivWithinAt (s := Icc (0:β) 1)) using 1 | |
| simp only [f', innerSL_apply_apply, inner_sub_left, d, one_mul] | |
| have hb (t : β) (ht : t β Ico (0:β) 1) : | |
| βf' tβ β€ (L:β)*βdβ^2 := by | |
| have hdiff : ββ t-xβ β€ βdβ := by | |
| rw [hβ, add_sub_cancel_left, norm_smul, Real.norm_eq_abs, abs_of_nonneg ht.1] | |
| exact mul_le_of_le_one_left (norm_nonneg _) ht.2.le | |
| have h := (hG.norm_sub_le (hmem t β¨ht.1, ht.2.leβ©) hx).trans | |
| (mul_le_mul_of_nonneg_left hdiff L.coe_nonneg) | |
| calc | |
| βf' tβ β€ βG (β t)-G xβ*βdβ := norm_inner_le_norm _ _ | |
| _ β€ ((L:β)*βdβ)*βdβ := mul_le_mul_of_nonneg_right h (norm_nonneg d) | |
| _ = _ := by ring | |
| have h := norm_image_sub_le_of_norm_deriv_le_segment_01' hf hb | |
| simpa only [f, β, AffineMap.lineMap_apply_zero, AffineMap.lineMap_apply_one, | |
| zero_mul, sub_zero, one_mul, Real.norm_eq_abs, d, sub_right_comm] using h | |
| theorem gradient_step_strict_descent {Ο : E β β} {G : E β E} {s : Set E} | |
| (hs : Convex β s) (hgrad : β x β s, HasFDerivAt Ο (innerSL β (G x)) x) | |
| {L : ββ₯0} (hG : LipschitzOnWith L G s) {Ξ΅ : β} (hΞ΅ : 0 < Ξ΅) | |
| (hsmall : (L:β)*Ξ΅ < 1) {x : E} (hx : x β s) (hstep : x-Ξ΅ β’ G x β s) | |
| (hGx : G x β 0) : Ο (x-Ξ΅ β’ G x) < Ο x := by | |
| have h := (le_abs_self _).trans (lipschitz_gradient_remainder hs hgrad hG hx hstep) | |
| have he : x-Ξ΅ β’ G x-x = -Ξ΅ β’ G x := by module | |
| rw [he, inner_smul_right, real_inner_self_eq_norm_sq, | |
| norm_smul, Real.norm_eq_abs, abs_of_neg (neg_neg_of_pos hΞ΅)] at h | |
| have hn : 0 < βG xβ^2 := sq_pos_of_pos (norm_pos_iff.mpr hGx) | |
| have hc : 0 < Ξ΅*(1-(L:β)*Ξ΅)*βG xβ^2 := by positivity | |
| nlinarith only [h, hc] | |
| theorem gradient_step_derivative_sq_bound {D : E βL[β] E} {c M Ξ΅ : β} | |
| (_hc : 0 β€ c) (_hM : 0 β€ M) (hΞ΅ : 0 β€ Ξ΅) | |
| (hcoercive : β v, c*βvβ^2 β€ inner β v (D v)) (hbound : βDβ β€ M) | |
| (v : E) : | |
| βv-Ξ΅ β’ D vβ^2 β€ (1-2*Ξ΅*c+Ξ΅^2*M^2)*βvβ^2 := by | |
| have hD : βD vβ β€ M*βvβ := D.le_of_opNorm_le hbound v | |
| have hD2 : βD vβ^2 β€ M^2*βvβ^2 := by | |
| nlinarith [norm_nonneg (D v), mul_nonneg _hM (norm_nonneg v)] | |
| have h := mul_le_mul_of_nonneg_left (hcoercive v) (show 0 β€ 2*Ξ΅ by positivity) | |
| have h' := mul_le_mul_of_nonneg_left hD2 (sq_nonneg Ξ΅) | |
| rw [norm_sub_sq_real, inner_smul_right, norm_smul, Real.norm_eq_abs, | |
| abs_of_nonneg hΞ΅] | |
| nlinarith only [h, h'] | |
| end GradientDescent | |
| end SKGap | |
| end | |
| end | |
| end | |
| end OAI | |