lemmascalarCell_mem {m : ℕ} (q : Cube m) {y : ℝ} (hy : y ∈Icc (0:ℝ) 1) :
scalarCell q y ∈Icc (0:ℝ) 1:=by
proof · 7
lines
induction m with
| zero => exact hy
| succ m ih =>
obtain ⟨b,q⟩ := q
have h := ih q
cases b <;> simp only [scalarCell, Bool.false_eq_true, ↓reduceIte, zero_add] <;>
constructor <;> linarith [h.1, h.2]
induction m with
| zero =>
change LipschitzWith1 (id : ℝ→ℝ)
exact LipschitzWith.id
| succ m ih =>
obtain ⟨b,q⟩ := q
apply LipschitzWith.of_dist_le_mul
intro x y
have h := (ih q).dist_le_mul x y
simp only [Real.dist_eq] at h ⊢havehe : scalarCell (m:=m+1) (b,q) x - scalarCell (m:=m+1) (b,q) y =
(scalarCell q x - scalarCell q y)/2:=by dsimp [scalarCell]; ring
rw [he, abs_div]
norm_num only [abs_of_pos (bynorm_num : (0:ℝ)<2), NNReal.coe_pow, NNReal.coe_div, NNReal.coe_one,
NNReal.coe_ofNat, pow_succ, NNReal.coe_mul] at ⊢
norm_num only [NNReal.coe_pow, NNReal.coe_div, NNReal.coe_one, NNReal.coe_ofNat] at h
linarith
lemmahalfInput_lipschitz (b : Bool) : LipschitzWith (1/2) (halfInput b) :=by
proof · 8
lines
apply LipschitzWith.of_dist_le_mul
intro x y
simp only [Real.dist_eq, halfInput]
havehe : ((if b then1else0)+x)/2 - ((if b then1else0)+y)/2 = (x-y)/2:=by ring
rw [he, abs_div]
norm_num
ring_nf
exact le_rfl
have hder (b : Bool) (x : ℝ) :
deriv (f ∘ halfInput b) x = (1/2:ℝ) * deriv f (halfInput b x) :=byhavehe : f ∘ halfInput b = (fun y => f (((if b then1else0)+y)/2)) := rfl
rw [he]
havehe' : (fun y => f (((if b then1else0)+y)/2)) =
(fun y => (fun z => f ((1/2:ℝ)*z)) ((if b then1else0)+y)) :=by
funext y; congr 1; ring
rw [he']
have hadd := deriv_comp_const_add (fun z => f ((1/2:ℝ)*z)) (if b then1else0) x
rw [hadd, deriv_comp_mul_left, smul_eq_mul]
congr 2
dsimp [halfInput]
ring
have hv (b : Bool) : variation (f ∘ halfInput b) =
∫ y in (if b then (1/2:ℝ) else0)..(if b then1else1/2), |deriv f y| :=by
simp only [variation, hder, abs_mul, abs_of_pos (bynorm_num : (0:ℝ)<1/2)]
rw [intervalIntegral.integral_const_mul]
havehe : (fun y => |deriv f (halfInput b y)|) =
(fun y => |deriv f (y/2 + (if b then (1/2:ℝ) else0))|) :=by
funext y
congr 2
cases b <;> simp [halfInput]
ring
rw [he, intervalIntegral.integral_comp_div_add (fun y => |deriv f y|) (bynorm_num : (2:ℝ)≠0)]
cases b <;> norm_num [smul_eq_mul] <;> ring
rw [hv, hv]
havehac : AbsolutelyContinuousOnInterval f 01:=
hf.lipschitzOnWith.absolutelyContinuousOnInterval
exact intervalIntegral.integral_add_adjacent_intervals
(hac.intervalIntegrable_deriv.abs.mono_set (by intro x hx; simp only [Set.mem_uIcc] at *; grind))
(hac.intervalIntegrable_deriv.abs.mono_set (by intro x hx; simp only [Set.mem_uIcc] at *; grind))
lemmahalf_integral_sum {f : ℝ→ℝ} (hf : Continuous f) :
(∫ y in (0:ℝ)..1, f (halfInput false y)) +
(∫ y in (0:ℝ)..1, f (halfInput true y)) = 2 * ∫ y in (0:ℝ)..1, f y :=by
proof · 11
lines
have he (b : Bool) : (∫ y in (0:ℝ)..1, f (halfInput b y)) =
2 * ∫ y in (if b then (1/2:ℝ) else0)..(if b then1else1/2), f y :=byhavehh : (fun y => f (halfInput b y)) =
(fun y => f (y/2 + (if b then (1/2:ℝ) else0))) :=by
funext y; congr 1; cases b <;> simp [halfInput]
ring
rw [hh, intervalIntegral.integral_comp_div_add f (bynorm_num : (2:ℝ)≠0)]
cases b <;> norm_num [smul_eq_mul]
rw [he, he]
simp only [Bool.false_eq_true, ↓reduceIte, ← mul_add]
rw [intervalIntegral.integral_add_adjacent_intervals (hf.intervalIntegrable _ _) (hf.intervalIntegrable _ _)]
lemmamean_scalarAvg {m : ℕ} {f : ℝ→ℝ} (hf : Continuous f) :
mean (scalarAvg (m:=m) f) = ∫ y in (0:ℝ)..1, f y :=by
proof · 10
lines
induction m generalizing f with
| zero => rw [mean_zero]; rfl
| succ m ih =>
rw [mean_succ]
simp only [scalarAvg_cons]
rw [ih (hf.comp (halfInput_lipschitz false).continuous),
ih (hf.comp (halfInput_lipschitz true).continuous)]
have h := half_integral_sum hf
dsimp [Function.comp_def]
linarith
lemmainfluence_succ {m : ℕ} (f : Cube (m+1) →ℝ) (i : Fin m) :
influence f i.succ =
(influence (fun q => f (false,q)) i + influence (fun q => f (true,q)) i)/2:=by