roseking's picture
Add lean source and binary files (part 66)
8e4d533 verified
Raw History Blame Contribute Delete
4.63 kB
32
noncomputable def profile (a : ℝ≥0) (t x : ℝ) : ℝ :=
body · 1 line
  Real.smoothTransition ((a:ℝ) * (x-t))
34
noncomputable def dprofile (a : ℝ≥0) (t x : ℝ) : ℝ :=
body · 1 line
  (a:ℝ) * deriv Real.smoothTransition ((a:ℝ) * (x-t))
37
lemma affine_lipschitz (a : ℝ≥0) (t : ℝ) :
    LipschitzWith a (fun x : ℝ => (a:ℝ)*(x-t)) := by
proof · 4 lines
  apply LipschitzWith.of_dist_le_mul
  intro x y
  simp only [Real.dist_eq,←mul_sub,sub_sub_sub_cancel_right,abs_mul,abs_of_nonneg a.coe_nonneg]
  exact le_rfl
44
lemma profile_hasDerivAt (a : ℝ≥0) (t x : ℝ) :
    HasDerivAt (profile a t) (dprofile a t x) x := by
proof · 5 lines
  have hd := ((@Real.smoothTransition.contDiff 1).differentiable (by norm_num) ((a:ℝ)*(x-t))).hasDerivAt
  change HasDerivAt (fun y => Real.smoothTransition ((a:ℝ)*(y-t)))
    ((a:ℝ)*deriv Real.smoothTransition ((a:ℝ)*(x-t))) x
  simpa only [Function.comp_def,id_eq,mul_one,mul_comm] using
    hd.comp x (((hasDerivAt_id x).sub_const t).const_mul (a:ℝ))
52
lemma profile_bounds (a : ℝ≥0) (t x : ℝ) :
    0 ≤ profile a t x ∧ profile a t x ≤ 1 :=
proof · 1 line
  ⟨Real.smoothTransition.nonneg _,Real.smoothTransition.le_one _⟩
56
lemma profile_zero (a : ℝ≥0) {t x : ℝ} (hx : x ≤ t) : profile a t x = 0 :=
proof · 1 line
  Real.smoothTransition.zero_of_nonpos (mul_nonpos_of_nonneg_of_nonpos a.coe_nonneg (sub_nonpos.mpr hx))
59
lemma dprofile_zero {a : ℝ≥0} (ha : 0 < a) {t x : ℝ}
    (hx : x ∉ Icc t (t+(a:ℝ)⁻¹)) : dprofile a t x = 0 := by
proof · 13 lines
  have ha' : 0 < (a:ℝ) := ha
  have hnot : (a:ℝ)*(x-t) ∉ Icc 0 1 := by
    intro h
    apply hx
    refine ⟨?_,?_⟩
    · have : 0 ≤ x-t := (mul_nonneg_iff_of_pos_left ha').mp h.1
      linarith
    · have : x-t ≤ (a:ℝ)⁻¹ := by
        rw [inv_eq_one_div]
        apply (le_div_iff₀ ha').mpr
        simpa [mul_comm] using h.2
      linarith
  simp [dprofile,deriv_transition_eq_zero hnot]
75
lemma exists_profile_bounds : ∃ C : ℝ≥0, ∀ (a : ℝ≥0) (t : ℝ),
    LipschitzWith (C*a) (profile a t) ∧
    LipschitzWith (a*(C*a)) (dprofile a t) ∧
    ∀ x, |dprofile a t x| ≤ (C*a:ℝ≥0) := by
proof · 11 lines
  obtain ⟨C,hC,hD,hb⟩ := exists_lipschitz_transition
  refine ⟨C,fun a t => ⟨hC.comp (affine_lipschitz a t),?_,?_⟩⟩
  · change LipschitzWith (a*(C*a)) (fun x => (a:ℝ)*deriv Real.smoothTransition ((a:ℝ)*(x-t)))
    simpa only [sub_zero,Function.comp_def] using
      (affine_lipschitz a 0).comp (hD.comp (affine_lipschitz a t))
  · intro x
    simp only [dprofile,abs_mul,abs_of_nonneg a.coe_nonneg,NNReal.coe_mul]
    calc
      (a:ℝ) * |deriv Real.smoothTransition ((a:ℝ)*(x-t))| ≤ (a:ℝ)*C :=
        mul_le_mul_of_nonneg_left (hb _) a.coe_nonneg
      _ = (C:ℝ)*a := mul_comm _ _
91
lemma profile_sequence_tendsto (t x : ℝ) :
    Tendsto (fun n : ℕ => profile ((n:ℝ≥0)+1) t x) atTop
      (𝓝 ((Ioi t).indicator (fun _ => (1:ℝ)) x)) := by
proof · 12 lines
  by_cases hx : t < x
  · rw [indicator_of_mem (show x ∈ Ioi t from hx)]
    have hlim : Tendsto (fun n : ℕ => ((n:ℝ)+1)*(x-t)) atTop atTop :=
      (tendsto_atTop_add_const_right atTop 1 tendsto_natCast_atTop_atTop).atTop_mul_const (sub_pos.mpr hx)
    have heq : (fun n : ℕ => profile ((n:ℝ≥0)+1) t x) =ᶠ[atTop] fun _ => (1:ℝ) := by
      filter_upwards [hlim.eventually (eventually_ge_atTop 1)] with n hn
      apply Real.smoothTransition.one_of_one_le
      simpa only [NNReal.coe_add,NNReal.coe_natCast,NNReal.coe_one] using hn
    exact tendsto_const_nhds.congr' heq.symm
  · rw [indicator_of_notMem (show x ∉ Ioi t from hx)]
    simpa only [profile_zero _ (le_of_not_gt hx)] using
      (tendsto_const_nhds : Tendsto (fun _ : ℕ => (0:ℝ)) atTop (𝓝 0))