Download data/lean/OAI/MathematicalPhysics/RapidForcing/FormulaNames.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 8.6 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/MathematicalPhysics/RapidForcing/FormulaNames.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/MathematicalPhysics/RapidForcing/FormulaNames.lean
-
curl -L -o FormulaNames.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/MathematicalPhysics/RapidForcing/FormulaNames.lean
8.6 kB
| import OAI.MathematicalPhysics.RapidForcing.FieldExpressions | |
| namespace OAI | |
| section | |
| open scoped BigOperators Topology | |
| open Set Filter | |
| namespace RapidForcing.EffectiveProfile | |
| namespace Formula | |
| variable {d : β} | |
| def lipBound (R : β) : Formula d β β | |
| | .const _ => 0 | |
| | .var _ => 1 | |
| | .add a b => a.lipBound R + b.lipBound R | |
| | .mul a b => a.bound R * b.lipBound R + b.bound R * a.lipBound R | |
| | .profile e a => e.diff.bound * a.lipBound R | |
| lemma lipBound_nonneg (a : Formula d) (R : β) : 0 β€ a.lipBound R := by | |
| induction a with | |
| | const q => rfl | |
| | var i => norm_num [lipBound] | |
| | add a b ha hb => exact add_nonneg ha hb | |
| | mul a b ha hb => | |
| exact add_nonneg (mul_nonneg (a.bound_nonneg R) hb) (mul_nonneg (b.bound_nonneg R) ha) | |
| | profile e a ha => exact mul_nonneg e.diff.bound_nonneg ha | |
| lemma abs_sub_le_lipBound (a : Formula d) (R : β) (x y : Fin d β β) | |
| (hx : β i, |x i| β€ |(R : β)|) (hy : β i, |y i| β€ |(R : β)|) : | |
| |a.value x - a.value y| β€ (a.lipBound R : β) * βx - yβ := by | |
| induction a with | |
| | const q => simp [value, lipBound] | |
| | var i => simpa [value, lipBound, Real.norm_eq_abs] using norm_le_pi_norm (x - y) i | |
| | add a b ha hb => | |
| calc | |
| _ = |(a.value x - a.value y) + (b.value x - b.value y)| := by dsimp [value]; congr 1; ring | |
| _ β€ |a.value x - a.value y| + |b.value x - b.value y| := abs_add_le _ _ | |
| _ β€ (a.lipBound R : β) * βx - yβ + (b.lipBound R : β) * βx - yβ := add_le_add ha hb | |
| _ = _ := by simp [lipBound, add_mul] | |
| | mul a b ha hb => | |
| calc | |
| _ = |a.value x * (b.value x - b.value y) + b.value y * (a.value x - a.value y)| := by | |
| dsimp [value]; congr 1; ring | |
| _ β€ |a.value x| * |b.value x - b.value y| + |b.value y| * |a.value x - a.value y| := by | |
| simpa [abs_mul] using abs_add_le (a.value x * (b.value x - b.value y)) | |
| (b.value y * (a.value x - a.value y)) | |
| _ β€ (a.bound R : β) * ((b.lipBound R : β) * βx - yβ) + | |
| (b.bound R : β) * ((a.lipBound R : β) * βx - yβ) := by | |
| apply add_le_add | |
| Β· exact mul_le_mul (a.abs_value_le R x hx) hb (abs_nonneg _) (by exact_mod_cast a.bound_nonneg R) | |
| Β· exact mul_le_mul (b.abs_value_le R y hy) ha (abs_nonneg _) (by exact_mod_cast b.bound_nonneg R) | |
| _ = _ := by simp only [lipBound, Rat.cast_add, Rat.cast_mul]; ring | |
| | profile e a ha => | |
| have he : |e.value (a.value x) - e.value (a.value y)| β€ | |
| (e.diff.bound : β) * |a.value x - a.value y| := e.lipschitz.dist_le_mul _ _ | |
| exact he.trans (by simpa only [lipBound, Rat.cast_mul, mul_assoc] using | |
| mul_le_mul_of_nonneg_left ha (show (0 : β) β€ e.diff.bound by exact_mod_cast e.diff.bound_nonneg)) | |
| def RationalName (name : β β Part (Fin d β β)) (x : Fin d β β) : Prop := | |
| β n, β q, q β name n β§ β(fun i => (q i : β)) - xβ β€ accuracy n | |
| def choosePrecision (L Ξ΅ : β) : Part β := | |
| Nat.rfindOpt fun n => if (1 / 2 : β) ^ n * L β€ Ξ΅ / 2 then some n else none | |
| lemma choosePrecision_spec (L Ξ΅ : β) {n : β} (hn : n β choosePrecision L Ξ΅) : | |
| (1 / 2 : β) ^ n * L β€ Ξ΅ / 2 := by | |
| obtain β¨m, hmβ© := Nat.rfindOpt_spec hn | |
| split_ifs at hm with h | |
| Β· have he := Option.mem_some_iff.mp hm | |
| subst m | |
| exact h | |
| Β· cases hm | |
| lemma choosePrecision_dom (L Ξ΅ : β) (hΞ΅ : 0 < Ξ΅) : (choosePrecision L Ξ΅).Dom := by | |
| have he : (0 : β) < (Ξ΅ : β) / 2 := by exact_mod_cast (half_pos hΞ΅) | |
| have hlim : Tendsto (fun n : β => (1 / 2 : β) ^ n * (L : β)) atTop (π 0) := by | |
| simpa using (tendsto_pow_atTop_nhds_zero_of_lt_one (by norm_num : (0 : β) β€ 1 / 2) | |
| (by norm_num : (1 / 2 : β) < 1)).mul_const (L : β) | |
| obtain β¨n, hnβ© := (hlim.eventually (Iio_mem_nhds he)).exists | |
| have hn'' : (((1 / 2 : β) ^ n * L : β) : β) β€ ((Ξ΅ / 2 : β) : β) := by | |
| simpa only [Rat.cast_mul, Rat.cast_pow, Rat.cast_div, Rat.cast_one, Rat.cast_ofNat] using hn.le | |
| have hn' : (1 / 2 : β) ^ n * L β€ Ξ΅ / 2 := by exact_mod_cast hn'' | |
| exact Nat.rfindOpt_dom.mpr β¨n, n, by rw [ite_eq_left hn']; rflβ© | |
| def evalName (a : Formula d) (name : β β Part (Fin d β β)) (Ξ΅ : β) : Part Ball := do | |
| let qβ β name 0 | |
| let R := 2 + β i, |qβ i| | |
| let L := a.lipBound R | |
| let n β choosePrecision L Ξ΅ | |
| let q β name n | |
| let b β a.evalAt q (Ξ΅ / 2) | |
| pure β¨b.center, b.radius + (1 / 2 : β) ^ n * Lβ© | |
| lemma rationalName_spec {name : β β Part (Fin d β β)} {x : Fin d β β} | |
| (hn : RationalName name x) (n : β) {q : Fin d β β} (hq : q β name n) : | |
| β(fun i => (q i : β)) - xβ β€ accuracy n := by | |
| obtain β¨q', hq', heβ© := hn n | |
| exact Part.mem_unique hq hq' βΈ he | |
| lemma accuracy_le_one (n : β) : accuracy n β€ 1 := | |
| pow_le_oneβ (by norm_num) (by norm_num) | |
| lemma name_box {name : β β Part (Fin d β β)} {x : Fin d β β} | |
| (hn : RationalName name x) {qβ q : Fin d β β} (hβ : qβ β name 0) | |
| {n : β} (hq : q β name n) : | |
| (β i, |x i| β€ |((2 + β j, |qβ j| : β) : β)|) β§ | |
| (β i, |(q i : β)| β€ |((2 + β j, |qβ j| : β) : β)|) := by | |
| have hdistβ := rationalName_spec hn 0 hβ | |
| have hdist := (rationalName_spec hn n hq).trans (accuracy_le_one n) | |
| have hp : (0 : β) β€ 2 + β j, |qβ j| := by positivity | |
| have hp' : (0 : β) β€ ((2 + β j, |qβ j| : β) : β) := by exact_mod_cast hp | |
| constructor | |
| Β· intro i | |
| have hi := (norm_le_pi_norm ((fun j => (qβ j : β)) - x) i).trans hdistβ | |
| have hsum : |(qβ i : β)| β€ (β j, |qβ j| : β) := by | |
| exact_mod_cast (Finset.single_le_sum (fun j (_ : j β (Finset.univ : Finset (Fin d))) => abs_nonneg (qβ j)) | |
| (Finset.mem_univ i)) | |
| have ht := abs_sub_le (x i) (qβ i : β) 0 | |
| simp only [Real.norm_eq_abs, Pi.sub_apply, accuracy, pow_zero] at hi | |
| rw [abs_sub_comm] at hi | |
| simp only [sub_zero] at ht | |
| rw [abs_of_nonneg hp', Rat.cast_add, Rat.cast_ofNat] | |
| linarith | |
| Β· intro i | |
| have hi := (norm_le_pi_norm ((fun j => (qβ j : β)) - x) i).trans hdistβ | |
| have hi' := (norm_le_pi_norm ((fun j => (q j : β)) - x) i).trans hdist | |
| have hsum : |(qβ i : β)| β€ (β j, |qβ j| : β) := by | |
| exact_mod_cast (Finset.single_le_sum (fun j (_ : j β (Finset.univ : Finset (Fin d))) => abs_nonneg (qβ j)) | |
| (Finset.mem_univ i)) | |
| have ht := abs_sub_le (q i : β) (x i) (qβ i : β) | |
| have ht' := abs_sub_le (q i : β) (qβ i : β) 0 | |
| simp only [Real.norm_eq_abs, Pi.sub_apply, accuracy, pow_zero] at hi hi' | |
| rw [abs_sub_comm] at hi | |
| simp only [sub_zero] at ht' | |
| rw [abs_of_nonneg hp', Rat.cast_add, Rat.cast_ofNat] | |
| linarith | |
| lemma evalName_spec (a : Formula d) {name : β β Part (Fin d β β)} {x : Fin d β β} | |
| (hn : RationalName name x) (Ξ΅ : β) (hΞ΅ : 0 < Ξ΅) {b : Ball} (hb : b β a.evalName name Ξ΅) : | |
| b.Covers (a.value x) β§ b.radius β€ Ξ΅ := by | |
| obtain β¨qβ, hβ, hrestβ© := Part.mem_bind_iff.mp hb | |
| obtain β¨n, hn', hrestβ© := Part.mem_bind_iff.mp hrest | |
| obtain β¨q, hq, hrestβ© := Part.mem_bind_iff.mp hrest | |
| obtain β¨c, hc, hbβ© := Part.mem_bind_iff.mp hrest | |
| have he : b = β¨c.center, c.radius + (1 / 2 : β) ^ n * a.lipBound (2 + β i, |qβ i|)β© := | |
| Part.mem_some_iff.mp hb | |
| subst b | |
| have hprec := choosePrecision_spec _ _ hn' | |
| obtain β¨hc, hc'β© := a.evalAt_spec q (Ξ΅ / 2) (by positivity) hc | |
| obtain β¨hx, hyβ© := name_box hn hβ hq | |
| have hdist := a.abs_sub_le_lipBound _ _ _ hy hx | |
| have hbound := rationalName_spec hn n hq | |
| have hL : (0 : β) β€ a.lipBound (2 + β i, |qβ i|) := by exact_mod_cast a.lipBound_nonneg _ | |
| refine β¨?_, by change c.radius + (1 / 2 : β) ^ n * a.lipBound (2 + β i, |qβ i|) β€ Ξ΅; linarithβ© | |
| change |(c.center : β) - a.value x| β€ _ | |
| calc | |
| _ β€ |(c.center : β) - a.value (fun i => (q i : β))| + | |
| |a.value (fun i => (q i : β)) - a.value x| := abs_sub_le _ _ _ | |
| _ β€ (c.radius : β) + (a.lipBound (2 + β i, |qβ i|) : β) * accuracy n := | |
| add_le_add hc (hdist.trans (mul_le_mul_of_nonneg_left hbound hL)) | |
| _ = _ := by simp [accuracy, mul_comm] | |
| lemma evalName_dom (a : Formula d) {name : β β Part (Fin d β β)} {x : Fin d β β} | |
| (hn : RationalName name x) (Ξ΅ : β) (hΞ΅ : 0 < Ξ΅) : (a.evalName name Ξ΅).Dom := by | |
| have ht (n : β) : (name n).Dom := let β¨_, h, _β© := hn n; h.fst | |
| refine β¨ht 0, choosePrecision_dom _ _ hΞ΅, ht _, ?_β© | |
| exact β¨a.evalAt_dom _ _ (by positivity), trivialβ© | |
| end Formula | |
| end RapidForcing.EffectiveProfile | |
| end | |
| end OAI | |