math / data /lean /OAI /Combinatorics /HalvingLines /PathLimits.lean
introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
18.7 kB
import OAI.Combinatorics.HalvingLines.ChainDrawing
namespace OAI
open Filter Topology
namespace PlanarHalving.Batches
open PlaneGraph RankCoordinates
variable {R : β„•}
lemma ConvexPath.extension_vertex (C : ConvexPath R) {l u : ℝ}
(hsl : βˆ€ b : Fin R, C.point b.castSucc β‰  C.point b.succ β†’
l ≀ slope (C.point b.castSucc) (C.point b.succ) ∧ slope (C.point b.castSucc) (C.point b.succ) ≀ u)
(c : Fin (R+1)) : C.extension l u (C.point c).1 = (C.point c).2 := by
induction c using Fin.induction with
| zero =>
apply le_antisymm (C.extension_below_vertex hsl 0)
have hh := le_envelope (C.extensionSlopes l u) (C.extensionIntercepts l u) (.inr false) (C.point 0).1
simp only [ConvexPath.extensionSlopes, ConvexPath.extensionIntercepts] at hh
change _ ≀ envelope (C.extensionSlopes l u) (C.extensionIntercepts l u) (C.point 0).1
linarith only [hh]
| succ b ih =>
by_cases hb : C.point b.castSucc = C.point b.succ
Β· rw [← hb]
exact ih
Β· exact C.extension_edge hsl b hb (right_mem_segment ℝ _ _)
lemma ConvexPath.extension_left (C : ConvexPath R) {l u : ℝ} (hlu : l ≀ u)
(hsl : βˆ€ b : Fin R, C.point b.castSucc β‰  C.point b.succ β†’
l ≀ slope (C.point b.castSucc) (C.point b.succ) ∧ slope (C.point b.castSucc) (C.point b.succ) ≀ u)
{x : ℝ} (hx : x ≀ (C.point 0).1) :
C.extension l u x = (C.point 0).2 + l*(x-(C.point 0).1) := by
apply le_antisymm
Β· apply envelope_le
intro i
have hi := le_envelope (C.extensionSlopes l u) (C.extensionIntercepts l u) i (C.point 0).1
change _ ≀ C.extension l u (C.point 0).1 at hi
rw [C.extension_vertex hsl] at hi
have hm := mul_nonpos_of_nonneg_of_nonpos
(sub_nonneg.mpr (C.extension_slopes hlu hsl i).1) (sub_nonpos.mpr hx)
nlinarith only [hi,hm]
Β· have hh := le_envelope (C.extensionSlopes l u) (C.extensionIntercepts l u) (.inr false) x
simp only [ConvexPath.extensionSlopes, ConvexPath.extensionIntercepts] at hh
change _ ≀ envelope (C.extensionSlopes l u) (C.extensionIntercepts l u) x
linarith only [hh]
lemma ConvexPath.extension_right (C : ConvexPath R) {l u : ℝ} (hlu : l ≀ u)
(hsl : βˆ€ b : Fin R, C.point b.castSucc β‰  C.point b.succ β†’
l ≀ slope (C.point b.castSucc) (C.point b.succ) ∧ slope (C.point b.castSucc) (C.point b.succ) ≀ u)
{x : ℝ} (hx : (C.point (Fin.last R)).1 ≀ x) :
C.extension l u x = (C.point (Fin.last R)).2 + u*(x-(C.point (Fin.last R)).1) := by
apply le_antisymm
Β· apply envelope_le
intro i
have hi := le_envelope (C.extensionSlopes l u) (C.extensionIntercepts l u) i (C.point (Fin.last R)).1
change _ ≀ C.extension l u (C.point (Fin.last R)).1 at hi
rw [C.extension_vertex hsl] at hi
have hm := mul_nonpos_of_nonpos_of_nonneg
(sub_nonpos.mpr (C.extension_slopes hlu hsl i).2) (sub_nonneg.mpr hx)
nlinarith only [hi,hm]
Β· have hh := le_envelope (C.extensionSlopes l u) (C.extensionIntercepts l u) (.inr true) x
simp only [ConvexPath.extensionSlopes, ConvexPath.extensionIntercepts] at hh
change _ ≀ envelope (C.extensionSlopes l u) (C.extensionIntercepts l u) x
linarith only [hh]
lemma finite_intermediate {R : β„•} (f : Fin (R+1) β†’ ℝ) {x : ℝ}
(hβ‚€ : f 0 ≀ x) (h₁ : x < f (Fin.last R)) :
βˆƒ b : Fin R, f b.castSucc ≀ x ∧ x < f b.succ := by
have haux : βˆ€ c : Fin (R+1), x < f c β†’ βˆƒ b : Fin R, f b.castSucc ≀ x ∧ x < f b.succ := by
intro c
induction c using Fin.induction with
| zero => exact fun h => (not_lt_of_ge hβ‚€ h).elim
| succ b ih =>
intro h
by_cases hb : f b.castSucc ≀ x
· exact ⟨b,hb,h⟩
Β· exact ih (lt_of_not_ge hb)
exact haux (Fin.last R) h₁
lemma ConvexPath.extension_middle (C : ConvexPath R) {l u : ℝ}
(hsl : βˆ€ b : Fin R, C.point b.castSucc β‰  C.point b.succ β†’
l ≀ slope (C.point b.castSucc) (C.point b.succ) ∧ slope (C.point b.castSucc) (C.point b.succ) ≀ u)
{x : ℝ} (hβ‚€ : (C.point 0).1 ≀ x) (h₁ : x < (C.point (Fin.last R)).1) :
βˆƒ b : Fin R, C.point b.castSucc β‰  C.point b.succ ∧
(x,C.extension l u x) ∈ segment ℝ (C.point b.castSucc) (C.point b.succ) := by
obtain ⟨b,hbβ‚€,hbβ‚βŸ© := finite_intermediate (fun c => (C.point c).1) hβ‚€ h₁
have hbx : (C.point b.castSucc).1 < (C.point b.succ).1 := hbβ‚€.trans_lt hb₁
have hb : C.point b.castSucc β‰  C.point b.succ := fun h => hbx.ne (congrArg Prod.fst h)
let t := (x-(C.point b.castSucc).1)/((C.point b.succ).1-(C.point b.castSucc).1)
have ht : t ∈ Set.Icc (0:ℝ) 1 := by
refine ⟨div_nonneg (sub_nonneg.mpr hbβ‚€) (sub_nonneg.mpr hbx.le), ?_⟩
exact (div_le_one (sub_pos.mpr hbx)).mpr (by linarith only [hb₁])
let z : Point := (1-t) β€’ C.point b.castSucc + t β€’ C.point b.succ
have hz : z ∈ segment ℝ (C.point b.castSucc) (C.point b.succ) := by
rw [segment_eq_image]
exact ⟨t,ht,rfl⟩
have hzx : z.1 = x := by
dsimp [z,t]
field_simp [ne_of_gt (sub_pos.mpr hbx)]
ring
have hzy := C.extension_edge hsl b hb hz
rw [hzx] at hzy
have he : (x,C.extension l u x) = z := Prod.ext hzx.symm hzy
exact ⟨b,hb,he β–Έ hz⟩
lemma ConvexPath.extension_cases (C : ConvexPath R) {l u : ℝ} (hlu : l ≀ u)
(hsl : βˆ€ b : Fin R, C.point b.castSucc β‰  C.point b.succ β†’
l ≀ slope (C.point b.castSucc) (C.point b.succ) ∧ slope (C.point b.castSucc) (C.point b.succ) ≀ u)
{z : Point} (hz : C.extension l u z.1 = z.2) :
(z.1 ≀ (C.point 0).1 ∧ z.2 = (C.point 0).2 + l*(z.1-(C.point 0).1)) ∨
((C.point (Fin.last R)).1 ≀ z.1 ∧ z.2 = (C.point (Fin.last R)).2 + u*(z.1-(C.point (Fin.last R)).1)) ∨
(βˆƒ b : Fin R, C.point b.castSucc β‰  C.point b.succ ∧ z ∈ segment ℝ (C.point b.castSucc) (C.point b.succ)) := by
by_cases hl : z.1 ≀ (C.point 0).1
· exact Or.inl ⟨hl, hz.symm.trans (C.extension_left hlu hsl hl)⟩
by_cases hu : (C.point (Fin.last R)).1 ≀ z.1
· exact Or.inr (Or.inl ⟨hu,hz.symm.trans (C.extension_right hlu hsl hu)⟩)
obtain ⟨b,hb,hz'⟩ := C.extension_middle hsl (le_of_not_ge hl) (lt_of_not_ge hu)
rw [hz] at hz'
exact Or.inr (Or.inr ⟨b,hb,hz'⟩)
end PlanarHalving.Batches
namespace PlanarHalving.Spatial
open Set Filter Metric
open scoped Topology
theorem subsequence_of_asymptotic_continuity
{X Y : Type*} [MetricSpace X] [SecondCountableTopology X]
[MetricSpace Y] [CompleteSpace Y]
(f : β„• β†’ X β†’ Y) (G : Set X) (hG : G.Nonempty) (K : Set Y) (hK : IsCompact K)
(hbounded : βˆ€ n p, p ∈ G β†’ f n p ∈ K)
(hcont : βˆ€ p ∈ G, βˆ€ Ξ΅ > 0, βˆƒ r > 0,
βˆ€αΆ  n in atTop, βˆ€ q, dist q p < r β†’ dist (f n q) (f n p) ≀ Ξ΅) :
βˆƒ (Ο† : β„• β†’ β„•) (l : G β†’ Y), StrictMono Ο† ∧
(βˆ€ p, l p ∈ K) ∧
(βˆ€ p : G, βˆ€ u : β„• β†’ X, Tendsto u atTop (𝓝 (p : X)) β†’
Tendsto (fun n => f (Ο† n) (u n)) atTop (𝓝 (l p))) := by
classical
let : Nonempty G := hG.to_subtype
let : CompactSpace K := isCompact_iff_compactSpace.mp hK
obtain ⟨q,hq⟩ := TopologicalSpace.exists_dense_seq G
let F : β„• β†’ β„• β†’ K := fun n j => ⟨f n (q j), hbounded n (q j) (q j).property⟩
obtain ⟨g,Ο†,hΟ†,hg⟩ := CompactSpace.tendsto_subseq F
have hgrid (j : β„•) : Tendsto (fun n => f (Ο† n) (q j)) atTop (𝓝 (g j : Y)) :=
continuous_subtype_val.tendsto _ |>.comp ((tendsto_pi_nhds.mp hg) j)
have hcauchy (p : G) : CauchySeq (fun n => f (Ο† n) p) := by
rw [Metric.cauchySeq_iff]
intro Ξ΅ hΞ΅
obtain ⟨r,hr,hrf⟩ := hcont p p.property (Ρ/4) (by positivity)
obtain ⟨j,hj⟩ := hq.exists_dist_lt p hr
have hj' : dist (q j : X) p < r := by simpa only [Subtype.dist_eq, dist_comm] using hj
obtain ⟨N,hN⟩ := eventually_atTop.mp (hΟ†.tendsto_atTop.eventually hrf)
obtain ⟨N',hN'⟩ := Metric.cauchySeq_iff.mp (hgrid j).cauchySeq (Ρ/4) (by positivity)
refine ⟨max N N',fun m hm n hn => ?_⟩
have hm' := hN m (le_trans (le_max_left _ _) hm) (q j) hj'
have hn' := hN n (le_trans (le_max_left _ _) hn) (q j) hj'
have hmn := hN' m (le_trans (le_max_right _ _) hm) n (le_trans (le_max_right _ _) hn)
have htri := dist_triangle4 (f (Ο† m) p) (f (Ο† m) (q j)) (f (Ο† n) (q j)) (f (Ο† n) p)
rw [dist_comm (f (Ο† m) p) (f (Ο† m) (q j))] at htri
linarith only [htri,hm',hn',hmn,hΞ΅]
choose l hl using fun p => cauchySeq_tendsto_of_complete (hcauchy p)
refine βŸ¨Ο†,l,hΟ†,?_,?_⟩
Β· intro p
exact hK.isClosed.mem_of_tendsto (hl p) (Eventually.of_forall (fun n => hbounded (Ο† n) p p.property))
Β· intro p u hu
apply Metric.tendsto_atTop.mpr
intro Ξ΅ hΞ΅
obtain ⟨r,hr,hrf⟩ := hcont p p.property (Ρ/3) (by positivity)
have hu' : βˆ€αΆ  n in atTop, dist (u n) (p : X) < r := (Metric.tendsto_nhds.mp hu) r hr
have hl' : βˆ€αΆ  n in atTop, dist (f (Ο† n) p) (l p) < Ξ΅/3 :=
(Metric.tendsto_nhds.mp (hl p)) (Ξ΅/3) (by positivity)
apply eventually_atTop.mp
filter_upwards [hφ.tendsto_atTop.eventually hrf,hu',hl'] with n hn hnu hnl
have hh := hn (u n) hnu
have ht := dist_triangle (f (Ο† n) (u n)) (f (Ο† n) p) (l p)
linarith only [hh,ht,hnl,hΞ΅]
lemma asymptotic_continuity_of_radial
{X Y : Type*} [MetricSpace X] [MetricSpace Y]
(f : β„• β†’ X β†’ Y) (G : Set X) (r e : β„• β†’ ℝ)
(hr : βˆ€ j, 0 < r j) (he : Tendsto e atTop (𝓝 0))
(hb : βˆ€ p ∈ G, βˆ€ j, βˆ€αΆ  n in atTop,
βˆ€ q, dist q p < r j β†’ dist (f n q) (f n p) ≀ e j) :
βˆ€ p ∈ G, βˆ€ Ξ΅ > 0, βˆƒ Ξ΄ > 0,
βˆ€αΆ  n in atTop, βˆ€ q, dist q p < Ξ΄ β†’ dist (f n q) (f n p) ≀ Ξ΅ := by
intro p hp Ξ΅ hΞ΅
obtain ⟨j,hj⟩ := ((tendsto_order.mp he).2 Ρ hΡ).exists
refine ⟨r j,hr j,?_⟩
filter_upwards [hb p hp j] with n hn q hq
exact (hn q hq).trans hj.le
lemma lower_distance_of_limit
{X Y : Type*} [MetricSpace X] [MetricSpace Y]
(f : ℕ → X → Y) (φ : ℕ → ℕ) (hφ : StrictMono φ)
{p q : X} {x y : Y} (hp : Tendsto (fun n => f (Ο† n) p) atTop (𝓝 x))
(hq : Tendsto (fun n => f (Ο† n) q) atTop (𝓝 y))
{a : ℝ} (ha : βˆ€αΆ  n in atTop, a ≀ dist (f n p) (f n q)) : a ≀ dist x y := by
exact ge_of_tendsto (hp.dist hq) (hφ.tendsto_atTop.eventually ha)
end PlanarHalving.Spatial
namespace PlanarHalving.Spatial
open Set Filter Metric
open scoped Topology
lemma geometric_scale {q h d : ℝ} (hq : 0 < q) (hq1 : q < 1)
(_hh : 0 < h) (hd : 0 < d) (hdh : d ≀ h) :
βˆƒ j : β„•, 1 ≀ j ∧ h*q^j < d ∧ q*d ≀ h*q^j := by
have ht : Tendsto (fun j : β„• => h*q^j) atTop (𝓝 0) := by
simpa using (tendsto_pow_atTop_nhds_zero_of_lt_one hq.le hq1).const_mul h
have hex : βˆƒ j : β„•, h*q^j < d := ((tendsto_order.mp ht).2 d hd).exists
let j := Nat.find hex
have hj : h*q^j < d := Nat.find_spec hex
have hj0 : j β‰  0 := by
intro h
simp only [h,pow_zero,mul_one] at hj
exact (not_lt_of_ge hdh) hj
have hj1 : 1 ≀ j := Nat.one_le_iff_ne_zero.mpr hj0
have hprev : d ≀ h*q^(j-1) := by
exact le_of_not_gt (Nat.find_min hex (show j-1 < j by omega))
refine ⟨j,hj1,hj,?_⟩
have hp : q^j = q^(j-1)*q := by
rw [← pow_succ]
congr 1
omega
rw [hp]
nlinarith only [mul_le_mul_of_nonneg_left hprev hq.le]
lemma geometric_lower_power {q h d s : ℝ} (hq : 0 < q) (hq1 : q < 1)
(hh : 0 < h) (hd : 0 < d) (hdh : d ≀ h) (hs : 0 ≀ s) :
βˆƒ j : β„•, 1 ≀ j ∧ h*q^j < d ∧
q^s * (q/h)^s * d^s ≀ (q^s)^(j+1) := by
obtain ⟨j,hj,hjd,hdj⟩ := geometric_scale hq hq1 hh hd hdh
refine ⟨j,hj,hjd,?_⟩
have hdiv : q/h*d ≀ q^j := by
have hv : q*d/h ≀ q^j := (div_le_iffβ‚€ hh).mpr (by nlinarith only [hdj])
convert hv using 1
ring
have hp := Real.rpow_le_rpow (by positivity : 0 ≀ q/h*d) hdiv hs
rw [Real.mul_rpow (by positivity) hd.le] at hp
rw [pow_succ, Real.rpow_pow_comm hq.le]
have ht := mul_le_mul_of_nonneg_left hp (Real.rpow_nonneg hq.le s)
nlinarith only [ht]
lemma inverse_holder_of_radial_limits
{X Y : Type*} [MetricSpace X] [MetricSpace Y]
(f : ℕ → X → Y) (φ : ℕ → ℕ) (hφ : StrictMono φ)
(G : Set X) (l : G β†’ Y)
(hl : βˆ€ p : G, Tendsto (fun n => f (Ο† n) p) atTop (𝓝 (l p)))
{q h s : ℝ} (hq : 0 < q) (hq1 : q < 1) (hh : 0 < h) (hs : 0 < s)
(hdiam : βˆ€ p p' : G, dist (p : X) p' ≀ h)
(hlower : βˆ€ p : G, βˆ€ j : β„•, 1 ≀ j β†’ βˆ€αΆ  n in atTop,
βˆ€ p' : G, h*q^j < dist (p : X) p' β†’ (q^s)^(j+1) ≀ dist (f n p) (f n p')) :
βˆ€ p p' : G, (q^s * (q/h)^s) * dist (p : X) p' ^ s ≀ dist (l p) (l p') := by
intro p p'
by_cases hpp : p = p'
Β· subst p'
simp [Real.zero_rpow hs.ne']
Β· have hd : 0 < dist (p : X) p' := dist_pos.mpr (Subtype.coe_ne_coe.mpr hpp)
obtain ⟨j,hj,hjd,hdj⟩ := geometric_lower_power hq hq1 hh hd (hdiam p p') hs.le
apply hdj.trans
apply lower_distance_of_limit f φ hφ (hl p) (hl p')
filter_upwards [hlower p j hj] with n hn
exact hn p' hjd
end PlanarHalving.Spatial
namespace PlanarHalving.Limits
open MeasureTheory Set Filter
open scoped Topology NNReal
theorem finiteMeasure_subsequence
{X : Type*} [MetricSpace X] [CompactSpace X] [Nonempty X]
[MeasurableSpace X] [BorelSpace X]
(ΞΌ : β„• β†’ β„• β†’ FiniteMeasure X) (C : β„• β†’ ℝβ‰₯0)
(hbound : βˆ€ n j, (ΞΌ n j).mass ≀ C j) :
βˆƒ (Ο† : β„• β†’ β„•) (Ξ½ : β„• β†’ FiniteMeasure X), StrictMono Ο† ∧
βˆ€ j, Tendsto (fun n => ΞΌ (Ο† n) j) atTop (𝓝 (Ξ½ j)) := by
let F : β„• β†’ βˆ€ j : β„•, (Icc (0 : ℝβ‰₯0) (C j)) Γ— ProbabilityMeasure X :=
fun n j => (⟨(μ n j).mass,zero_le,hbound n j⟩,(μ n j).normalize)
obtain ⟨g,Ο†,hΟ†,hg⟩ := CompactSpace.tendsto_subseq F
refine βŸ¨Ο†,fun j => (g j).1.val β€’ (g j).2.toFiniteMeasure,hΟ†,?_⟩
intro j
have hj := (tendsto_pi_nhds.mp hg) j
have hm := continuous_subtype_val.tendsto _ |>.comp ((continuous_fst.tendsto (g j)).comp hj)
have hn := (ProbabilityMeasure.toFiniteMeasure_isEmbedding X).continuous.tendsto _ |>.comp
((continuous_snd.tendsto (g j)).comp hj)
have ht := hm.smul hn
convert ht using 1
funext n
exact (ΞΌ (Ο† n) j).self_eq_mass_smul_normalize
end PlanarHalving.Limits
namespace PlanarHalving.RankCoordinates
open Set
lemma variation_le_two {f : β„• β†’ ℝ} {n : β„•}
(hf : βˆ€ i ≀ n, 0 ≀ f i ∧ f i ≀ 1)
(hqc : βˆ€ i j k, i ≀ j β†’ j ≀ k β†’ k ≀ n β†’ min (f i) (f k) ≀ f j) :
βˆ‘ i ∈ Finset.range n, |f (i+1)-f i| ≀ 2 := by
classical
obtain ⟨k,hk,hmax⟩ := (Finset.range (n+1)).exists_max_image f (by simp)
have hkn : k ≀ n := by simpa only [Finset.mem_range,Nat.lt_succ_iff] using hk
have hleft : βˆ‘ i ∈ Finset.range k, |f (i+1)-f i| = f k-f 0 := by
rw [← Finset.sum_range_sub f k]
apply Finset.sum_congr rfl
intro i hi
have hik : i < k := Finset.mem_range.mp hi
apply abs_of_nonneg
apply sub_nonneg.mpr
have hq := hqc i (i+1) k (by omega) (by omega) hkn
rw [min_eq_left (hmax i (by simp; omega))] at hq
exact hq
have hright : βˆ‘ i ∈ Finset.Ico k n, |f (i+1)-f i| = f k-f n := by
calc
_ = - βˆ‘ i ∈ Finset.Ico k n, (f (i+1)-f i) := by
rw [← Finset.sum_neg_distrib]
apply Finset.sum_congr rfl
intro i hi
obtain ⟨hki,hin⟩ := Finset.mem_Ico.mp hi
apply abs_of_nonpos
apply sub_nonpos.mpr
have hq := hqc k i (i+1) hki (by omega) (by omega)
rw [min_eq_right (hmax (i+1) (by simp; omega))] at hq
exact hq
_ = _ := by rw [Finset.sum_Ico_sub f hkn]; ring
rw [← Finset.sum_range_add_sum_Ico (fun i => |f (i+1)-f i|) hkn,hleft,hright]
have h0 := (hf 0 (Nat.zero_le n)).1
have hn := (hf n le_rfl).1
have hk1 := (hf k hkn).2
linarith only [h0,hn,hk1]
lemma min_le_of_quasiconcave {f : ℝ β†’ ℝ} (hf : QuasiconcaveOn ℝ univ f)
{x y z : ℝ} (hxy : x ≀ y) (hyz : y ≀ z) : min (f x) (f z) ≀ f y := by
have hc := (hf (min (f x) (f z))).ordConnected
have hx : x ∈ univ ∩ {u | min (f x) (f z) ≀ f u} := by
refine ⟨mem_univ _,?_⟩
change min (f x) (f z) ≀ f x
exact min_le_left _ _
have hz : z ∈ univ ∩ {u | min (f x) (f z) ≀ f u} := by
refine ⟨mem_univ _,?_⟩
change min (f x) (f z) ≀ f z
exact min_le_right _ _
exact (hc.out hx hz ⟨hxy,hyz⟩).2
lemma concave_cdf_variation {f F : ℝ β†’ ℝ} (hf : ConcaveOn ℝ univ f)
(hF : Monotone F) (hFrange : βˆ€ x, F x ∈ Icc 0 1)
(x : β„• β†’ ℝ) (hx : Monotone x) (n : β„•) :
βˆ‘ i ∈ Finset.range n, |F (f (x (i+1)))-F (f (x i))| ≀ 2 := by
apply variation_le_two (fun i _ => hFrange (f (x i)))
intro i j k hij hjk _
rw [← hF.map_min]
exact hF (min_le_of_quasiconcave hf.quasiconcaveOn (hx hij) (hx hjk))
lemma sigmoid_variation {f : ℝ β†’ ℝ} (hf : ConcaveOn ℝ univ f)
{Ξ΅ : ℝ} (hΞ΅ : 0 < Ξ΅) (x : β„• β†’ ℝ) (hx : Monotone x) (n : β„•) :
βˆ‘ i ∈ Finset.range n,
|Real.sigmoid (f (x (i+1))/Ξ΅)-Real.sigmoid (f (x i)/Ξ΅)| ≀ 2 := by
apply concave_cdf_variation hf
(fun _ _ h => Real.sigmoid_strictMono.monotone (div_le_div_of_nonneg_right h hΞ΅.le))
(fun _ => ⟨(Real.sigmoid_pos _).le,(Real.sigmoid_lt_one _).le⟩) x hx n
lemma smoothed_variation {m : β„•} (hm : 0 < m) (g : Fin m β†’ ℝ β†’ ℝ)
(hg : βˆ€ j, ConvexOn ℝ univ (g j)) {f : ℝ β†’ ℝ} (hf : ConcaveOn ℝ univ f)
{Ξ΅ : ℝ} (hΞ΅ : 0 < Ξ΅) (x : β„• β†’ ℝ) (hx : Monotone x) (n : β„•) :
βˆ‘ i ∈ Finset.range n,
|smoothed g Ξ΅ (x (i+1),f (x (i+1)))-smoothed g Ξ΅ (x i,f (x i))| ≀ 2 := by
have hmR : (0 : ℝ) < m := Nat.cast_pos.mpr hm
have hterm (i : β„•) :
|smoothed g Ξ΅ (x (i+1),f (x (i+1)))-smoothed g Ξ΅ (x i,f (x i))| ≀
(βˆ‘ j, |Real.sigmoid ((f (x (i+1))-g j (x (i+1)))/Ξ΅) -
Real.sigmoid ((f (x i)-g j (x i))/Ξ΅)|) / m := by
unfold smoothed
rw [← sub_div,abs_div,abs_of_pos hmR,← Finset.sum_sub_distrib]
exact div_le_div_of_nonneg_right (Finset.abs_sum_le_sum_abs _ _) hmR.le
calc
_ ≀ βˆ‘ i ∈ Finset.range n, (βˆ‘ j, |Real.sigmoid ((f (x (i+1))-g j (x (i+1)))/Ξ΅) -
Real.sigmoid ((f (x i)-g j (x i))/Ξ΅)|) / m := Finset.sum_le_sum (fun i _ => hterm i)
_ = (βˆ‘ j : Fin m, βˆ‘ i ∈ Finset.range n,
|Real.sigmoid ((f (x (i+1))-g j (x (i+1)))/Ξ΅) -
Real.sigmoid ((f (x i)-g j (x i))/Ξ΅)|) / m := by
rw [← Finset.sum_div,Finset.sum_comm]
_ ≀ (βˆ‘ _j : Fin m, (2 : ℝ))/m := by
apply div_le_div_of_nonneg_right _ hmR.le
exact Finset.sum_le_sum (fun j _ => sigmoid_variation (hf.sub (hg j)) hΞ΅ x hx n)
_ = 2 := by simp; field_simp
end PlanarHalving.RankCoordinates
end OAI