import Mathlib import OAI.Analysis.BiholderTransport.CostGeometry.UniformFiniteRadialScale namespace OAI section section noncomputable section open Set namespace WeakMTWTransport lemma finite_interval_mesh {K ε e : ℝ} (hK : 0 ≤ K) (hε : 0 < ε) (he : e∈Ioo (0:ℝ) 1) : ∃ N : ℕ, 0 (k:ℝ)/N*(1-e) refine ⟨N,hNnat,t,by simp [t],by simp [t,ne_of_gt hn0],?_,?_⟩ · intro k hk have hr : (k:ℝ)/N ≤ 1 := (div_le_one hn0).mpr (by exact_mod_cast hk) have hr0 : 0 ≤ (k:ℝ)/N := div_nonneg (Nat.cast_nonneg _) hn0.le dsimp [t] constructor · exact mul_nonneg hr0 (by linarith [he.2]) · have HH := mul_le_mul_of_nonneg_right hr (show 0 ≤ 1-e by linarith [he.2]) simpa only [one_mul] using HH · intro k hk have hstep : t (k+1)-t k=(1-e)/N := by dsimp [t] rw [Nat.cast_add,Nat.cast_one] ring rw [hstep,abs_of_nonneg (div_nonneg (by linarith [he.2]) hn0.le)] have hKN : K/N ≤ ε := by rw [div_le_iff₀ hn0] have HH := (div_lt_iff₀ hε).mp (show K/ε<(N:ℝ) by linarith [hN]) linarith have HH := mul_le_mul_of_nonneg_left (show (1-e)/N ≤ 1/N by exact div_le_div_of_nonneg_right (by linarith [he.1]) hn0.le) hK rw [mul_one_div] at HH exact HH.trans hKN end WeakMTWTransport end end section noncomputable section open Set namespace WeakMTWTransport lemma uniform_finite_profile_comparison {C l u b D e K : ℝ} (hC : 0 norm_num) have hs₁ : 0 s (t k)) have hSc : S.card ≤ N+1 := Finset.card_image_le.trans (by simp) obtain ⟨δ,hd0,hdη,hdsmall,hdlarge,hdsep⟩ := HC S hSc (s 0) (s 1) hs₁ hsD hfail have hd : δ∈Ioc (0:ℝ) (1/2) := ⟨hd0,hdη.trans (min_le_left _ _)⟩ have hbg : b*δ ≤ l/32 := by have HH := hdη.trans (min_le_right _ _) have HH2 := (le_div_iff₀ (show 0<32*b by positivity)).mp HH nlinarith only [HH2] have hti (k : ℕ) (hk : k≤N) : t k∈Icc (0:ℝ) 1 := ⟨(ht k hk).1,le_trans (ht k hk).2 (by linarith [he.1])⟩ have hlarge_case (r : ℝ) (hr : r∈Icc (0:ℝ) 1) (hh : Real.exp L*s r ≤ δ) : l/4 ≤ f δ r := by have HH := radial_profile_small (hs r hr) hd0 hl.le hR hh hbg (hprof δ hd r hr).1 linarith have hsmall_case (r : ℝ) (hr : r∈Icc (0:ℝ) 1) (hh : δ*Real.exp L ≤ s r) : f δ r ≤ ε := by have HH := radial_profile_large (hs r hr) hd0 hu.le (Real.exp_pos L) hh hbg (hprof δ hd r hr).2 dsimp [ε] linarith have hfzero : l/4 ≤ f δ (t 0) := by rw [ht0] exact hlarge_case 0 (by constructor <;> norm_num) hdsmall have hfend : f δ 1 ≤ ε := hsmall_case 1 (by constructor <;> norm_num) hdlarge have hfbin (k : ℕ) (hk : k≤N) : f δ (t k) ≤ ε ∨ l/4 ≤ f δ (t k) := by have hmem : s (t k)∈S := Finset.mem_image.mpr ⟨k,Finset.mem_range.mpr (by omega),rfl⟩ rcases hdsep _ hmem with Hs|Hs · exact Or.inr (hlarge_case (t k) (hti k hk) Hs) · exact Or.inl (hsmall_case (t k) (hti k hk) Hs) have hfstep (k : ℕ) (hk : k f δ (t k)) (show 2*ε