Buckets:
| import Mathlib | |
| namespace OAI | |
| noncomputable section | |
| open MeasureTheory Filter Set | |
| open scoped NNReal Topology BigOperators | |
| namespace Problem367.EnergyRiemann | |
| def point (T : ℝ) (n i : ℕ) : ℝ := (i : ℝ) * (T / n) | |
| def sum (f : ℝ → ℝ) (T : ℝ) (n : ℕ) : ℝ := | |
| (T / n) * ∑ i ∈ Finset.range n, f (point T n i) | |
| @[simp] theorem point_zero (T : ℝ) (n : ℕ) : point T n 0 = 0 := by simp [point] | |
| theorem point_end (T : ℝ) {n : ℕ} (hn : 0 < n) : point T n n = T := by | |
| dsimp [point] | |
| field_simp | |
| theorem point_step (T : ℝ) (n i : ℕ) : | |
| point T n (i + 1) - point T n i = T / n := by | |
| simp only [point, Nat.cast_add, Nat.cast_one] | |
| ring | |
| theorem point_mono {T : ℝ} (hT : 0 ≤ T) (n : ℕ) : Monotone (point T n) := by | |
| intro i j hij | |
| exact mul_le_mul_of_nonneg_right (by exact_mod_cast hij) (by positivity) | |
| theorem point_mem {T : ℝ} (hT : 0 ≤ T) {n i : ℕ} (hn : 0 < n) (hi : i ≤ n) : | |
| point T n i ∈ Icc 0 T := by | |
| constructor | |
| · dsimp [point]; positivity | |
| · exact (point_mono hT n hi).trans_eq (point_end T hn) | |
| theorem error_le {f : ℝ → ℝ} (hf : Continuous f) {T ε : ℝ} | |
| (hT : 0 ≤ T) {n : ℕ} (hn : 0 < n) | |
| (hmod : ∀ i < n, ∀ x ∈ Icc (point T n i) (point T n (i + 1)), | |
| |f (point T n i) - f x| ≤ ε) : | |
| |sum f T n - ∫ x in (0 : ℝ)..T, f x| ≤ ε * T := by | |
| have hpart := intervalIntegral.sum_integral_adjacent_intervals | |
| (μ := volume) (a := point T n) (n := n) (fun i _ => hf.intervalIntegrable _ _) | |
| rw [point_zero, point_end T hn] at hpart | |
| have hcluster (i : ℕ) : | |
| (T / n) * f (point T n i) - | |
| (∫ x in point T n i..point T n (i + 1), f x) = | |
| ∫ x in point T n i..point T n (i + 1), f (point T n i) - f x := by | |
| rw [intervalIntegral.integral_sub intervalIntegrable_const (hf.intervalIntegrable _ _), | |
| intervalIntegral.integral_const, smul_eq_mul, point_step] | |
| have hdecomp : sum f T n - (∫ x in (0 : ℝ)..T, f x) = | |
| ∑ i ∈ Finset.range n, | |
| ∫ x in point T n i..point T n (i + 1), f (point T n i) - f x := by | |
| rw [sum, Finset.mul_sum, ← hpart, ← Finset.sum_sub_distrib] | |
| exact Finset.sum_congr rfl (fun i _ => hcluster i) | |
| rw [hdecomp] | |
| calc | |
| _ ≤ ∑ i ∈ Finset.range n, | |
| |∫ x in point T n i..point T n (i + 1), f (point T n i) - f x| := | |
| Finset.abs_sum_le_sum_abs _ _ | |
| _ ≤ ∑ _i ∈ Finset.range n, ε * (T / n) := by | |
| apply Finset.sum_le_sum | |
| intro i hi | |
| have hle := point_mono hT n (Nat.le_succ i) | |
| have hbound := intervalIntegral.norm_integral_le_of_norm_le_const | |
| (a := point T n i) (b := point T n (i + 1)) (C := ε) | |
| (f := fun x => f (point T n i) - f x) (fun x hx => ?_) | |
| · simpa only [Real.norm_eq_abs, point_step, abs_of_nonneg (div_nonneg hT | |
| (Nat.cast_nonneg n))] using hbound | |
| · rw [uIoc_of_le hle] at hx | |
| exact hmod i (Finset.mem_range.mp hi) x ⟨hx.1.le, hx.2⟩ | |
| _ = ε * T := by | |
| simp only [Finset.sum_const, Finset.card_range, nsmul_eq_mul] | |
| have hn0 : (n : ℝ) ≠ 0 := by exact_mod_cast (Nat.ne_of_gt hn) | |
| field_simp | |
| theorem tendsto_sum {f : ℝ → ℝ} (hf : Continuous f) {T : ℝ} (hT : 0 ≤ T) : | |
| Tendsto (sum f T) atTop (𝓝 (∫ x in (0 : ℝ)..T, f x)) := by | |
| apply Metric.tendsto_atTop.mpr | |
| intro ε hε | |
| let η := ε / (T + 1) | |
| have hη : 0 < η := div_pos hε (by linarith) | |
| have hUC := isCompact_Icc.uniformContinuousOn_of_continuous | |
| (s := Icc (0 : ℝ) T) hf.continuousOn | |
| obtain ⟨δ, hδ, hδmod⟩ := Metric.uniformContinuousOn_iff.mp hUC η hη | |
| have hwidth : Tendsto (fun n : ℕ => T / (n : ℝ)) atTop (𝓝 0) := | |
| tendsto_const_nhds.div_atTop tendsto_natCast_atTop_atTop | |
| have hev : ∀ᶠ n : ℕ in atTop, T / (n : ℝ) < δ := | |
| hwidth.eventually (gt_mem_nhds hδ) | |
| obtain ⟨N, hN⟩ := (hev.and (eventually_ge_atTop 1)).exists_forall_of_atTop | |
| refine ⟨N, ?_⟩ | |
| intro n hn | |
| obtain ⟨hmesh, hnpos⟩ := hN n hn | |
| have hn' : 0 < n := hnpos | |
| have he := error_le hf hT hn' (ε := η) ?_ | |
| · change |sum f T n - ∫ x in (0 : ℝ)..T, f x| < ε | |
| apply he.trans_lt | |
| change ε / (T + 1) * T < ε | |
| rw [div_mul_eq_mul_div] | |
| apply (div_lt_iff₀ (by linarith : 0 < T + 1)).mpr | |
| nlinarith | |
| · intro i hi x hx | |
| have hleft := point_mem hT hn' hi.le | |
| have hright := point_mem hT hn' (Nat.succ_le_of_lt hi) | |
| have hxT : x ∈ Icc (0 : ℝ) T := ⟨hleft.1.trans hx.1, hx.2.trans hright.2⟩ | |
| have hdist : dist (point T n i) x < δ := by | |
| rw [Real.dist_eq, abs_of_nonpos (sub_nonpos.mpr hx.1)] | |
| have hstep := point_step T n i | |
| linarith [hx.2] | |
| exact (hδmod _ hleft x hxT hdist).le | |
| def energy {Ω : Type*} [MeasurableSpace Ω] (P : Measure Ω) | |
| (H : ℝ≥0 → Ω → ℝ) (t : ℝ≥0) : ℝ := ∫ ω, (H t ω) ^ 2 ∂P | |
| theorem continuous_energy {Ω : Type*} [MeasurableSpace Ω] | |
| {P : Measure Ω} [IsFiniteMeasure P] {H : ℝ≥0 → Ω → ℝ} | |
| (hm : ∀ t, AEStronglyMeasurable (H t) P) | |
| (hc : ∀ᵐ ω ∂P, Continuous (fun t => H t ω)) | |
| {C : ℝ} (hC : 0 ≤ C) (hb : ∀ᵐ ω ∂P, ∀ t, |H t ω| ≤ C) : | |
| Continuous (energy P H) := by | |
| apply continuous_of_dominated (bound := fun _ => C ^ 2) | |
| · intro t | |
| exact (hm t).pow 2 | |
| · intro t | |
| filter_upwards [hb] with ω hω | |
| simpa only [Real.norm_eq_abs, abs_sq, sq_abs] using | |
| (sq_le_sq₀ (abs_nonneg _) hC).mpr (hω t) | |
| · exact integrable_const _ | |
| · filter_upwards [hc] with ω hω | |
| exact hω.pow 2 | |
| theorem tendsto_energy_sum {Ω : Type*} [MeasurableSpace Ω] | |
| {P : Measure Ω} [IsFiniteMeasure P] {H : ℝ≥0 → Ω → ℝ} | |
| (hm : ∀ t, AEStronglyMeasurable (H t) P) | |
| (hc : ∀ᵐ ω ∂P, Continuous (fun t => H t ω)) | |
| {C : ℝ} (hC : 0 ≤ C) (hb : ∀ᵐ ω ∂P, ∀ t, |H t ω| ≤ C) | |
| (T : ℝ≥0) : | |
| Tendsto (fun n : ℕ => ((T : ℝ) / n) * | |
| ∑ i ∈ Finset.range n, | |
| ∫ ω, (H ((i : ℝ≥0) * T / n) ω) ^ 2 ∂P) | |
| atTop (𝓝 (∫ t in (0 : ℝ)..(T : ℝ), ∫ ω, (H t.toNNReal ω) ^ 2 ∂P)) := by | |
| have hcont : Continuous (fun t : ℝ => energy P H t.toNNReal) := | |
| (continuous_energy hm hc hC hb).comp (by fun_prop) | |
| have hlim := tendsto_sum hcont T.coe_nonneg | |
| convert hlim using 1 | |
| funext n | |
| congr 1 | |
| apply Finset.sum_congr rfl | |
| intro i _ | |
| congr 1 | |
| funext ω | |
| congr 2 | |
| apply NNReal.eq | |
| simp only [NNReal.coe_mul, NNReal.coe_div, NNReal.coe_natCast, point, | |
| Real.coe_toNNReal' ] | |
| rw [max_eq_left (by positivity)] | |
| ring | |
| all_goals rfl | |
| end Problem367.EnergyRiemann | |
| end | |
| end OAI | |
Xet Storage Details
- Size:
- 6.56 kB
- Xet hash:
- ae917059e9b333f236f2d9abec260dd2de663d2e45aa314fe3a236f3e7b2bfb8
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.