lemmaprofile_norm_sub (x y : V) : ‖profile x - profile y‖ = dist x y :=by
proof · 12
lines
apply le_antisymm
· apply (pi_norm_le_iff_of_nonneg dist_nonneg).2
intro z
simp only [Pi.sub_apply, profile, Real.norm_eq_abs]
apply abs_sub_le_iff.2
constructor
· linarith [dist_triangle x y z]
· have h := dist_triangle y x z
rw [dist_comm y x] at h
linarith
· have h := norm_le_pi_norm (profile x - profile y) y
simpa [profile, Real.norm_eq_abs, abs_of_nonneg dist_nonneg] using h
lemmanorm_coordinate_convex (c : V→ℝ) (i : V) :
Convexℝ {x : V→ℝ | ‖x - c‖ ≤ x i} :=by
proof · 15
lines
intro x hx y hy a b ha hb hab
change ‖a • x + b • y - c‖ ≤ (a • x + b • y) i
haveheq : a • x + b • y - c = a • (x - c) + b • (y - c) :=by
ext j
simp only [Pi.sub_apply, Pi.add_apply, Pi.smul_apply, smul_eq_mul]
linear_combination c j * hab
rw [heq]
calc
‖a • (x - c) + b • (y - c)‖ ≤ ‖a • (x - c)‖ + ‖b • (y - c)‖ := norm_add_le _ _
_ = a * ‖x - c‖ + b * ‖y - c‖ :=by
rw [norm_smul, norm_smul, Real.norm_eq_abs, Real.norm_eq_abs,
abs_of_nonneg ha, abs_of_nonneg hb]
_ ≤ a * x i + b * y i := add_le_add (mul_le_mul_of_nonneg_left hx ha)
(mul_le_mul_of_nonneg_left hy hb)
_ = (a • x + b • y) i := rfl
lemmadoubledDist_triangle (a b c : DoubledV) :
doubledDist a c ≤ doubledDist a b + doubledDist b c :=by
proof · 15
lines
have hab := twice_dist_lt_commonRadius V a.point b.point
have hbc := twice_dist_lt_commonRadius V b.point c.point
have hac := twice_dist_lt_commonRadius V a.point c.point
have hR := commonRadius_pos Vhave h₁ := dist_triangle a.point b.point c.point
have h₂ := dist_triangle a.point c.point b.point
have h₃ := dist_triangle b.point a.point c.point
rw [dist_comm c.point b.point] at h₂
rw [dist_comm b.point a.point] at h₃
rcases a with ⟨a, x⟩
rcases b with ⟨b, y⟩
rcases c with ⟨c, z⟩
cases a <;> cases b <;> cases c <;>
simp_all only [doubledDist, Bool.false_eq_true, Bool.true_eq_false,
↓reduceIte] <;> linarith
theoremsegment_subdivision_length (q r : E) (N : ℕ) (t : ℕ→ℝ)
(ht : ∀ i < N, t i ≤ t (i + 1)) (hzero : t 0 = 0) (hone : t N = 1) :
∑ i ∈Finset.range N, ‖mix q r (t (i + 1)) - mix q r (t i)‖ = ‖r - q‖ :=by
proof · 10
lines
havehsum : (∑ i ∈Finset.range N, (t (i + 1) - t i)) = 1:=by
rw [Finset.sum_range_sub, hone, hzero, sub_zero]
calc
_ = ∑ i ∈Finset.range N, (t (i + 1) - t i) * ‖r - q‖ :=by
apply Finset.sum_congr rfl
intro i hi
rw [segment_distance, abs_of_nonneg (sub_nonneg.mpr (ht i (mem_range.mp hi)))]
_ = (∑ i ∈Finset.range N, (t (i + 1) - t i)) * ‖r - q‖ :=
(Finset.sum_mul _ _ _).symm
_ = ‖r - q‖ :=by rw [hsum, one_mul]
defPiecewiseAffineOn (s : Setℝ) (f : ℝ→ℝ) : Prop:=
body · 3
lines
∃ (N : ℕ) (pieces : FinN→Setℝ) (slopes intercepts : FinN→ℝ),
(∀ i, Convexℝ (pieces i)) ∧ (∀ t ∈ s, ∃ i, t ∈ pieces i) ∧∀ i t, t ∈ s → t ∈ pieces i → f t = slopes i * t + intercepts i
lemmaPiecewiseAffineOn.mono {s t : Setℝ} {f : ℝ→ℝ}
(h : PiecewiseAffineOn s f) (ht : t ⊆ s) : PiecewiseAffineOn t f :=by
proof · 3
lines
obtain ⟨N, pieces, slopes, intercepts, hc, hcover, heq⟩ := h
exact ⟨N, pieces, slopes, intercepts, hc, fun u hu => hcover u (ht hu),
fun i u hu hp => heq i u (ht hu) hp⟩
lemmaPiecewiseAffineOn.congr {s : Setℝ} {f g : ℝ→ℝ}
(h : PiecewiseAffineOn s f) (hfg : ∀ t ∈ s, f t = g t) : PiecewiseAffineOn s g :=by
proof · 3
lines
obtain ⟨N, pieces, slopes, intercepts, hc, hcover, heq⟩ := h
exact ⟨N, pieces, slopes, intercepts, hc, hcover,
fun i t ht hp => (hfg t ht).symm.trans (heq i t ht hp)⟩
lemmaclamped_affine_piecewise {a b : ℝ} (hab : a ≤ b) (x y : ℝ) :
PiecewiseAffineOnSet.univ (funt : ℝ=>
min b (max a ((1 - t) * x + t * y))) :=by
proof · 32
lines
letf : ℝ→ᵃ[ℝ] ℝ:=AffineMap.lineMap x y
refine ⟨3, ![f ⁻¹' Set.Iic a, f ⁻¹' Set.Icc a b, f ⁻¹' Set.Ici b],
![0, y - x, 0], ![a, x, b], ?_, ?_, ?_⟩
· intro i
fin_cases i
· exact Convex.affine_preimage f (convex_Iic a)
· exact Convex.affine_preimage f (convex_Icc a b)
· exact Convex.affine_preimage f (convex_Ici b)
· intro t _
by_cases ha : f t ≤ a
· exact ⟨0, ha⟩
· by_cases hb : f t ≤ b
· exact ⟨1, (lt_of_not_ge ha).le, hb⟩
· exact ⟨2, (lt_of_not_ge hb).le⟩
· intro i t _ hp
fin_cases i
· change f t ≤ a at hp
havehp' : (1 - t) * x + t * y ≤ a :=by
simpa only [f, AffineMap.lineMap_apply_ring] using hp
change min b (max a ((1 - t) * x + t * y)) = 0 * t + a
rw [max_eq_left hp', min_eq_right hab, zero_mul, zero_add]
· change a ≤ f t ∧ f t ≤ b at hp
havehp' : a ≤ (1 - t) * x + t * y ∧ (1 - t) * x + t * y ≤ b :=by
simpa only [f, AffineMap.lineMap_apply_ring] using hp
change min b (max a ((1 - t) * x + t * y)) = (y - x) * t + x
rw [max_eq_right hp'.1, min_eq_right hp'.2]
ring
· change b ≤ f t at hp
havehp' : b ≤ (1 - t) * x + t * y :=by
simpa only [f, AffineMap.lineMap_apply_ring] using hp
change min b (max a ((1 - t) * x + t * y)) = 0 * t + b
rw [max_eq_right (hab.trans hp'), min_eq_left hp', zero_mul, zero_add]
theoremclamped_radius_piecewise {V : Type*} [FintypeV] [PseudoMetricSpaceV]
{q r : V→ℝ} (hq : q ∈ polytope) (hr : r ∈ polytope) (x : V)
{a b : ℝ} (hab : a ≤ b) :
PiecewiseAffineOn (Set.Icc (0 : ℝ) 1)
(fun t => min b (max a ‖mix q r t - profile x‖)) :=by
proof · 5
lines
have h := (clamped_affine_piecewise hab ‖q - profile x‖ ‖r - profile x‖).mono
(Set.subset_univ (Set.Icc (0 : ℝ) 1))
apply h.congr
intro t ht
rw [radius_mix hq hr x ht]