math / data /lean /OAI /Dynamics /EntropyCounterexample /AmbientRetraction.lean
introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
11.9 kB
import OAI.Dynamics.EntropyCounterexample.Embedding
namespace OAI
noncomputable section
open scoped ContDiff
namespace Problem340.AmbientRetraction
variable {E : Type*} [NormedAddCommGroup E] [InnerProductSpace ℝ E]
def normalize (x : E) : E := β€–x‖⁻¹ β€’ x
theorem contDiffAt_normalize {n : β„•βˆžΟ‰} {x : E} (hx : x β‰  0) :
ContDiffAt ℝ n normalize x := by
exact ((contDiffAt_id.norm ℝ hx).inv (norm_ne_zero_iff.mpr hx)).smul contDiffAt_id
theorem normalize_mem_sphere {x : E} (hx : x β‰  0) :
normalize x ∈ Metric.sphere (0 : E) 1 := by
rw [mem_sphere_zero_iff_norm, normalize, norm_smul, norm_inv, norm_norm]
exact inv_mul_cancelβ‚€ (norm_ne_zero_iff.mpr hx)
theorem normalize_eq_self {x : E} (hx : x ∈ Metric.sphere (0 : E) 1) :
normalize x = x := by
rw [normalize, mem_sphere_zero_iff_norm.mp hx, inv_one, one_smul]
@[simp]
theorem norm_smul_normalize (x : E) : β€–xβ€– β€’ normalize x = x := by
by_cases hx : x = 0
Β· simp [hx, normalize]
Β· rw [normalize, smul_smul, mul_inv_cancelβ‚€ (norm_ne_zero_iff.mpr hx), one_smul]
theorem norm_normalize_le_one (x : E) : β€–normalize xβ€– ≀ 1 := by
by_cases hx : x = 0
Β· simp [hx, normalize]
Β· exact le_of_eq (mem_sphere_zero_iff_norm.mp (normalize_mem_sphere hx))
theorem norm_normalize_sub_le {x : E} (hx : x β‰  0) (y : E) :
β€–normalize y - normalize xβ€– ≀ (2 / β€–xβ€–) * β€–y - xβ€– := by
have hid : β€–xβ€– β€’ (normalize y - normalize x) =
(β€–xβ€– - β€–yβ€–) β€’ normalize y + (y - x) := by
rw [smul_sub, sub_smul, norm_smul_normalize, norm_smul_normalize]
abel
have hscale : β€–xβ€– * β€–normalize y - normalize xβ€– ≀ 2 * β€–y - xβ€– := by
calc
β€–xβ€– * β€–normalize y - normalize xβ€– =
β€–β€–xβ€– β€’ (normalize y - normalize x)β€– := by rw [norm_smul, norm_norm]
_ = β€–(β€–xβ€– - β€–yβ€–) β€’ normalize y + (y - x)β€– := congrArg norm hid
_ ≀ β€–(β€–xβ€– - β€–yβ€–) β€’ normalize yβ€– + β€–y - xβ€– := norm_add_le _ _
_ = |β€–xβ€– - β€–yβ€–| * β€–normalize yβ€– + β€–y - xβ€– := by
rw [norm_smul, Real.norm_eq_abs]
_ ≀ |β€–xβ€– - β€–yβ€–| + β€–y - xβ€– := by
nlinarith [norm_normalize_le_one y, abs_nonneg (β€–xβ€– - β€–yβ€–)]
_ ≀ 2 * β€–y - xβ€– := by
have hnorm := abs_norm_sub_norm_le x y
rw [norm_sub_rev x y] at hnorm
linarith
calc
β€–normalize y - normalize xβ€– ≀ (2 * β€–y - xβ€–) / β€–xβ€– :=
(le_div_iffβ‚€ (norm_pos_iff.mpr hx)).mpr (by nlinarith [hscale])
_ = (2 / β€–xβ€–) * β€–y - xβ€– := by ring
theorem norm_fderiv_normalize_le {x : E} (hx : x β‰  0) :
β€–fderiv ℝ normalize xβ€– ≀ 2 / β€–xβ€– := by
apply norm_fderiv_le_of_lip' ℝ (by positivity)
exact Filter.Eventually.of_forall (norm_normalize_sub_le hx)
theorem norm_fderiv_normalize_le_four {x : E} (hx : (1 / 2 : ℝ) ≀ β€–xβ€–) :
β€–fderiv ℝ normalize xβ€– ≀ 4 := by
have hxpos : 0 < β€–xβ€– := by linarith
apply (norm_fderiv_normalize_le (norm_pos_iff.mp hxpos)).trans
apply (div_le_iffβ‚€ hxpos).mpr
linarith
def cylinder (x : ℝ Γ— E) : ℝ Γ— E := (x.1, normalize x.2)
theorem contDiffAt_cylinder {n : β„•βˆžΟ‰} {x : ℝ Γ— E} (hx : x.2 β‰  0) :
ContDiffAt ℝ n cylinder x := by
exact contDiffAt_fst.prodMk ((contDiffAt_normalize hx).comp x contDiffAt_snd)
theorem norm_cylinder_sub_le_four {x : ℝ Γ— E} (hx : (1 / 2 : ℝ) ≀ β€–x.2β€–)
(y : ℝ Γ— E) : β€–cylinder y - cylinder xβ€– ≀ 4 * β€–y - xβ€– := by
have hxpos : 0 < β€–x.2β€– := by linarith
have hratio : 2 / β€–x.2β€– ≀ 4 := (div_le_iffβ‚€ hxpos).mpr (by linarith)
change max β€–y.1 - x.1β€– β€–normalize y.2 - normalize x.2β€– ≀ 4 * β€–y - xβ€–
apply max_le
Β· have hfst := norm_fst_le (y - x)
change β€–y.1 - x.1β€– ≀ β€–y - xβ€– at hfst
nlinarith [norm_nonneg (y - x)]
Β· calc
β€–normalize y.2 - normalize x.2β€– ≀ (2 / β€–x.2β€–) * β€–y.2 - x.2β€– :=
norm_normalize_sub_le (norm_pos_iff.mp hxpos) _
_ ≀ 4 * β€–y.2 - x.2β€– := mul_le_mul_of_nonneg_right hratio (norm_nonneg _)
_ ≀ 4 * β€–y - xβ€– := mul_le_mul_of_nonneg_left (norm_snd_le (y - x)) (by norm_num)
theorem norm_fderiv_cylinder_le_four {x : ℝ Γ— E} (hx : (1 / 2 : ℝ) ≀ β€–x.2β€–) :
β€–fderiv ℝ cylinder xβ€– ≀ 4 := by
apply norm_fderiv_le_of_lip' ℝ (by norm_num)
exact Filter.Eventually.of_forall (norm_cylinder_sub_le_four hx)
@[simp]
theorem cylinder_eq_self {x : ℝ Γ— E} (hx : β€–x.2β€– = 1) : cylinder x = x := by
apply Prod.ext
Β· rfl
Β· exact normalize_eq_self (mem_sphere_zero_iff_norm.mpr hx)
def cylinderDomain : Set (ℝ Γ— E) := {x | (1 / 2 : ℝ) < β€–x.2β€–}
omit [InnerProductSpace ℝ E] in
theorem isOpen_cylinderDomain : IsOpen (cylinderDomain (E := E)) :=
isOpen_lt continuous_const (continuous_norm.comp continuous_snd)
theorem mapsTo_normalizedPredictor
(G : ℝ Γ— E β†’ ℝ Γ— E)
(hG : βˆ€ x : ℝ Γ— E, β€–x.2β€– = 1 β†’ β€–(G x).2β€– = 1) :
Set.MapsTo (G ∘ cylinder) cylinderDomain cylinderDomain := by
intro x hx
change (1 / 2 : ℝ) < β€–x.2β€– at hx
have hxne : x.2 β‰  0 := norm_pos_iff.mp (by linarith [hx])
have hn : β€–(cylinder x).2β€– = 1 :=
mem_sphere_zero_iff_norm.mp (normalize_mem_sphere hxne)
change (1 / 2 : ℝ) < β€–(G (cylinder x)).2β€–
rw [hG _ hn]
norm_num
theorem contDiffOn_normalizedPredictor {n : β„•βˆžΟ‰}
(G : ℝ Γ— E β†’ ℝ Γ— E) (hG : ContDiff ℝ n G) :
ContDiffOn ℝ n (G ∘ cylinder) cylinderDomain := by
intro x hx
change (1 / 2 : ℝ) < β€–x.2β€– at hx
apply ContDiffAt.contDiffWithinAt
exact hG.contDiffAt.comp x (contDiffAt_cylinder
(norm_pos_iff.mp (by linarith [hx])))
theorem norm_fderiv_normalizedPredictor_le
(G : ℝ Γ— E β†’ ℝ Γ— E) (hG : ContDiff ℝ 1 G)
{B : ℝ} (hB : 0 ≀ B)
(hbound : βˆ€ x : ℝ Γ— E, β€–x.2β€– = 1 β†’ β€–fderiv ℝ G xβ€– ≀ B)
{x : ℝ Γ— E} (hx : x ∈ cylinderDomain) :
β€–fderiv ℝ (G ∘ cylinder) xβ€– ≀ B * 4 := by
change (1 / 2 : ℝ) < β€–x.2β€– at hx
have hxpos : 0 < β€–x.2β€– := by linarith [hx]
have hnorm : β€–(cylinder x).2β€– = 1 :=
mem_sphere_zero_iff_norm.mp (normalize_mem_sphere (norm_pos_iff.mp hxpos))
rw [fderiv_comp x (hG.differentiable one_ne_zero _)
((contDiffAt_cylinder (n := 1) (norm_pos_iff.mp hxpos)).differentiableAt one_ne_zero)]
apply (ContinuousLinearMap.opNorm_comp_le _ _).trans
exact mul_le_mul (hbound _ hnorm) (norm_fderiv_cylinder_le_four (le_of_lt hx))
(norm_nonneg _) hB
theorem normalizedPredictor_iterate_eq
(G : ℝ Γ— E β†’ ℝ Γ— E)
(hG : βˆ€ x : ℝ Γ— E, β€–x.2β€– = 1 β†’ β€–(G x).2β€– = 1)
{x : ℝ Γ— E} (hx : β€–x.2β€– = 1) (n : β„•) :
(G ∘ cylinder)^[n] x = G^[n] x := by
have hinv : Set.MapsTo G {x : ℝ Γ— E | β€–x.2β€– = 1} {x : ℝ Γ— E | β€–x.2β€– = 1} := hG
induction n with
| zero => rfl
| succ n hn =>
rw [Function.iterate_succ_apply', Function.iterate_succ_apply', hn]
change G (cylinder (G^[n] x)) = G (G^[n] x)
rw [cylinder_eq_self (hinv.iterate n hx)]
theorem normalizedPredictor_iterate_succ_eq
(G : ℝ Γ— E β†’ ℝ Γ— E)
(hG : βˆ€ x : ℝ Γ— E, β€–x.2β€– = 1 β†’ β€–(G x).2β€– = 1)
{x : ℝ Γ— E} (hx : x.2 β‰  0) (n : β„•) :
(G ∘ cylinder)^[n + 1] x = G^[n + 1] (cylinder x) := by
rw [Function.iterate_succ_apply, Function.comp_apply]
have hn : β€–(G (cylinder x)).2β€– = 1 :=
hG _ (mem_sphere_zero_iff_norm.mp (normalize_mem_sphere hx))
rw [normalizedPredictor_iterate_eq G hG hn n, Function.iterate_succ_apply]
def domain (q : β„•) : Set (CounterexampleAmbient q) :=
{x | x.1 β‰  0 ∧ βˆ€ i, x.2 i β‰  0}
theorem isOpen_domain (q : β„•) : IsOpen (domain q) := by
have hclock : IsOpen {x : CounterexampleAmbient q | x.1 β‰  0} :=
isOpen_ne.preimage continuous_fst
have hsphere : IsOpen {x : CounterexampleAmbient q | βˆ€ i, x.2 i β‰  0} := by
rw [Set.ofPred_forall]
exact isOpen_iInter_of_finite fun i =>
isOpen_ne.preimage ((continuous_apply i).comp continuous_snd)
exact hclock.inter hsphere
theorem standardEmbedding_mem_domain {q : β„•} (x : CounterexampleManifold q) :
standardEmbedding q x ∈ domain q :=
⟨ne_zero_of_mem_unit_sphere x.1, fun i => ne_zero_of_mem_unit_sphere (x.2 i)⟩
def project (q : β„•) (x : CounterexampleAmbient q) : CounterexampleAmbient q :=
(normalize x.1, fun i => normalize (x.2 i))
theorem contDiffOn_project (q : β„•) (n : β„•βˆžΟ‰) :
ContDiffOn ℝ n (project q) (domain q) := by
intro x hx
apply ContDiffAt.contDiffWithinAt
apply ContDiffAt.prodMk
Β· exact (contDiffAt_normalize (E := ClockAmbient) (n := n) hx.1).comp x contDiffAt_fst
Β· apply (contDiffAt_pi (F' := fun _ : Fin (q + 1) => SphereAmbient)).mpr
intro i
exact ContDiffAt.comp (f := fun y : CounterexampleAmbient q => y.2 i)
(g := normalize (E := SphereAmbient)) x
(contDiffAt_normalize (n := n) (hx.2 i))
((contDiff_apply ℝ SphereAmbient i).contDiffAt.comp x contDiffAt_snd)
@[simp]
theorem project_standardEmbedding {q : β„•} (x : CounterexampleManifold q) :
project q (standardEmbedding q x) = standardEmbedding q x := by
apply Prod.ext
Β· exact normalize_eq_self x.1.property
Β· funext i
exact normalize_eq_self (x.2 i).property
def toManifold (q : β„•) (x : domain q) : CounterexampleManifold q :=
(⟨normalize x.1.1, normalize_mem_sphere x.2.1⟩,
fun i => ⟨normalize (x.1.2 i), normalize_mem_sphere (x.2.2 i)⟩)
@[simp]
theorem standardEmbedding_toManifold (q : β„•) (x : domain q) :
standardEmbedding q (toManifold q x) = project q x := rfl
theorem continuous_toManifold (q : β„•) : Continuous (toManifold q) := by
apply (continuous_iff_standardEmbedding q _).mpr
exact (contDiffOn_project q 0).continuousOn.domRestrict
@[simp]
theorem toManifold_standardEmbedding {q : β„•} (x : CounterexampleManifold q) :
toManifold q ⟨standardEmbedding q x, standardEmbedding_mem_domain x⟩ = x := by
apply standardEmbedding_injective q
exact project_standardEmbedding x
def fromAmbient {q : β„•} (F : CounterexampleAmbient q β†’ CounterexampleAmbient q)
(hF : βˆ€ x : CounterexampleManifold q, F (standardEmbedding q x) ∈ domain q)
(x : CounterexampleManifold q) : CounterexampleManifold q :=
toManifold q ⟨F (standardEmbedding q x), hF x⟩
@[simp]
theorem standardEmbedding_fromAmbient {q : β„•}
(F : CounterexampleAmbient q β†’ CounterexampleAmbient q)
(hF : βˆ€ x : CounterexampleManifold q, F (standardEmbedding q x) ∈ domain q)
(x : CounterexampleManifold q) :
standardEmbedding q (fromAmbient F hF x) =
project q (F (standardEmbedding q x)) := rfl
theorem isC1SelfMap_fromAmbient {q : β„•}
(F : CounterexampleAmbient q β†’ CounterexampleAmbient q)
(hF : βˆ€ x : CounterexampleManifold q, F (standardEmbedding q x) ∈ domain q)
{U : Set (CounterexampleAmbient q)} (hU : IsOpen U)
(hmem : βˆ€ x : CounterexampleManifold q, standardEmbedding q x ∈ U)
(hsmooth : ContDiffOn ℝ 1 F U) : IsC1SelfMap q (fromAmbient F hF) := by
have hlocal : βˆ€ x : CounterexampleManifold q,
βˆƒ V : Set (CounterexampleAmbient q),
IsOpen V ∧ standardEmbedding q x ∈ V ∧
βˆƒ G : CounterexampleAmbient q β†’ CounterexampleAmbient q,
ContDiffOn ℝ 1 G V ∧
βˆ€ y : CounterexampleManifold q,
standardEmbedding q y ∈ V β†’
standardEmbedding q (fromAmbient F hF y) = G (standardEmbedding q y) := by
intro x
refine ⟨U ∩ F ⁻¹' domain q,
hsmooth.continuousOn.isOpen_inter_preimage hU (isOpen_domain q),
⟨hmem x, hF x⟩, project q ∘ F, ?_, ?_⟩
Β· exact (contDiffOn_project q 1).comp_inter hsmooth
Β· intro y _
rfl
exact ⟨continuous_of_local_contDiff_extension _ hlocal, hlocal⟩
end Problem340.AmbientRetraction
end
end OAI