math / data /lean /OAI /Analysis /DiamondDistortion /ModelMaps.lean
introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
16.1 kB
import OAI.Analysis.DiamondDistortion.Incomparable
namespace OAI
universe u v
noncomputable section
open scoped BigOperators Classical Topology
open Set
namespace DiamondDistortion
open scoped ENNReal
namespace RecursiveModel
instance countableCoord (h : β„•) : Countable (Coord h) := by
induction h with
| zero => exact inferInstanceAs (Countable Unit)
| succ h ih => exact inferInstanceAs (Countable (Unit βŠ• (β„• Γ— Coord h)))
lemma aggregate_sq {ΞΉ : Type*} (f : ΞΉ β†’β‚€ ℝ) :
(aggregate 2 f)^2=βˆ‘ i ∈ f.support,f i^2 := by
have hh := lp.norm_rpow_eq_tsum (p := 2) (by norm_num) (finiteLp 2 f)
have he : (aggregate 2 f)^2=βˆ‘' i,f i^2 := by
simpa only [aggregate,ENNReal.toReal_ofNat,Real.rpow_two,finiteLp_apply,Real.norm_eq_abs,sq_abs] using hh
rw [he]
exact tsum_eq_sum (fun i hi => by rw [Finsupp.notMem_support_iff.mp hi]; norm_num)
lemma components_zero (p : ForestVec) (h : β„•) (hh : h βˆ‰ p.support.image Sigma.fst) :
components p h=0 := by
ext i
change p ⟨h,i⟩=0
apply Finsupp.notMem_support_iff.mp
intro hi
exact hh (Finset.mem_image.mpr ⟨⟨h,i⟩,hi,rfl⟩)
lemma outer_support (s : βˆ€ h,Seminorm ℝ (Vec (h+1))) (p : ForestVec) :
(outerValues s p).support βŠ† p.support.image Sigma.fst := by
intro h hh
by_contra hn
have he : outerValues s p h=0 := by rw [outerValues_apply,components_zero p h hn,map_zero]
exact (Finsupp.mem_support_iff.mp hh) he
lemma outer_sq (s : βˆ€ h,Seminorm ℝ (Vec (h+1))) (p : ForestVec) (C : Finset β„•)
(hC : p.support.image Sigma.fst βŠ† C) :
(outerSeminorm s p)^2=βˆ‘ h ∈ C,(s h (components p h))^2 := by
change (aggregate 2 (outerValues s p))^2=_
rw [aggregate_sq]
apply Finset.sum_subset ((outer_support s p).trans hC)
intro h _ hh
rw [Finsupp.notMem_support_iff.mp hh]
norm_num
lemma components_filter (p : ForestVec) (C : Set β„•) (h : β„•) :
components (p.filter (fun i => i.1 ∈ C)) h=if h ∈ C then components p h else 0 := by
ext i
by_cases hh : h ∈ C
Β· rw [ite_eq_left hh]
change (p.filter (fun i => i.1 ∈ C)) ⟨h,i⟩=p ⟨h,i⟩
rw [Finsupp.filter_apply,ite_eq_left hh]
Β· rw [ite_eq_right hh]
change (p.filter (fun i => i.1 ∈ C)) ⟨h,i⟩=0
rw [Finsupp.filter_apply,ite_eq_right hh]
lemma outer_contractive (s : βˆ€ h,Seminorm ℝ (Vec (h+1))) (p : ForestVec) (C : Set β„•) :
outerSeminorm s (p.filter (fun i => i.1 ∈ C)) ≀ outerSeminorm s p := by
apply aggregate_mono 2
Β· exact outerValues_nonneg s _
Β· intro h
rw [outerValues_apply,outerValues_apply,components_filter]
split_ifs
Β· exact le_rfl
Β· rw [map_zero]; exact apply_nonneg _ _
lemma outer_orthogonal (s : βˆ€ h,Seminorm ℝ (Vec (h+1))) (p q : ForestVec)
(hd : Disjoint (p.support.image Sigma.fst) (q.support.image Sigma.fst)) :
(outerSeminorm s (p+q))^2 ≀ (outerSeminorm s p)^2+(outerSeminorm s q)^2 := by
let C := p.support.image Sigma.fst βˆͺ q.support.image Sigma.fst
have hp : p.support.image Sigma.fst βŠ† C := Finset.subset_union_left
have hq : q.support.image Sigma.fst βŠ† C := Finset.subset_union_right
have hpq : (p+q).support.image Sigma.fst βŠ† C := by
intro h hh
obtain ⟨i,hi,rfl⟩ := Finset.mem_image.mp hh
rcases Finset.mem_union.mp (Finsupp.support_add hi) with hi | hi
· exact hp (Finset.mem_image.mpr ⟨i,hi,rfl⟩)
· exact hq (Finset.mem_image.mpr ⟨i,hi,rfl⟩)
rw [outer_sq s p C hp,outer_sq s q C hq,outer_sq s (p+q) C hpq,← Finset.sum_add_distrib]
apply le_of_eq
apply Finset.sum_congr rfl
intro h _
rw [map_add,DFinsupp.add_apply]
by_cases hh : h ∈ p.support.image Sigma.fst
Β· have hhq := Finset.disjoint_left.mp hd hh
rw [components_zero q h hhq,add_zero,map_zero,zero_pow (by decide : 2 β‰  0),add_zero]
Β· rw [components_zero p h hh,zero_add,map_zero,zero_pow (by decide : 2 β‰  0),zero_add]
lemma energy_components (p : ForestVec) (C : Finset β„•) (hC : p.support.image Sigma.fst βŠ† C) :
(βˆ‘ i ∈ p.support,p i^2)=βˆ‘ h ∈ C,βˆ‘ i ∈ (components p h).support,(components p h i)^2 := by
have he (h : β„•) : p.split h=components p h := by ext i; rw [Finsupp.split_apply]; rfl
have hh := p.sigma_sum (fun _ a => a^2)
simp only [Finsupp.sum,he] at hh
rw [hh]
have hes : p.splitSupport=p.support.image Sigma.fst := by
ext h
simp only [Finsupp.splitSupport,Finset.mem_image]
rw [hes]
apply Finset.sum_subset hC
intro h _ hh
have hzero := components_zero p h hh
rw [hzero,Finsupp.support_zero,Finset.sum_empty]
end RecursiveModel
namespace PathModel
open RecursiveModel
lemma path_norm (h : β„•) (ΞΌ : L1 h) : β€–path h ΞΌβ€– ≀ (h+1:ℝ)*β€–ΞΌβ€– := by
have hb : β€–path hβ€– ≀ (h+1:ℝ) :=
LinearMap.mkContinuous_norm_le _ (by positivity : (0:ℝ) ≀ h+1) _
exact ((path h).le_opNorm ΞΌ).trans (mul_le_mul_of_nonneg_right hb (norm_nonneg _))
lemma linear_l2 (h : β„•) (v : L2 h) : β€–vβ€– ≀ (h+1:ℝ)*cost 1 h v := by
apply (presentation 1 h).bound v (by positivity : (0:ℝ) ≀ h+1)
intro d hd
change d.fst+path h d.snd=v at hd
rw [← hd,WithLp.prod_norm_eq_of_L1]
have hb := (norm_add_le d.fst (path h d.snd)).trans (add_le_add le_rfl (path_norm h d.snd))
have hhn : 1 ≀ (h+1:ℝ) := by linarith [Nat.cast_nonneg (Ξ± := ℝ) h]
have hn := norm_nonneg d.fst
nlinarith
lemma finite_l2_sq (h : β„•) (v : Vec h) :
β€–finiteEmbedding h vβ€–^2=βˆ‘ i ∈ v.support,v i^2 := aggregate_sq v
lemma linear_upper (p : ForestVec) :
(linearForestSeminorm p)^2 ≀ βˆ‘ i ∈ p.support,p i^2 := by
let C := p.support.image Sigma.fst
rw [energy_components p C (by rfl)]
change (outerSeminorm (fun h => finiteCost 1 (h+1)) p)^2 ≀ _
rw [outer_sq _ p C (by rfl)]
apply Finset.sum_le_sum
intro h _
rw [← finite_l2_sq]
exact (sq_le_sqβ‚€ (apply_nonneg _ _) (norm_nonneg _)).mpr (linear_le_norm (h+1) _)
lemma linear_lower (C : Finset β„•) (p : ForestVec)
(hp : βˆ€ i ∈ p.support,i.1 ∈ C) :
(βˆ‘ i ∈ p.support,p i^2) ≀ (((C.sup (id : β„• β†’ β„•) : β„•) : ℝ)+2)^2*(linearForestSeminorm p)^2 := by
have hC : p.support.image Sigma.fst βŠ† C := by
rintro _ hh
obtain ⟨i,hi,rfl⟩ := Finset.mem_image.mp hh
exact hp i hi
rw [energy_components p C hC]
change _ ≀ _*(outerSeminorm (fun h => finiteCost 1 (h+1)) p)^2
rw [outer_sq _ p C hC,Finset.mul_sum]
apply Finset.sum_le_sum
intro h hh
rw [← finite_l2_sq]
have hb := linear_l2 (h+1) (finiteEmbedding _ (components p h))
have hm : ((h+1:β„•):ℝ)+1 ≀ ((C.sup (id : β„• β†’ β„•) : β„•) : ℝ)+2 := by
have he : (h:ℝ) ≀ ((C.sup (id : β„• β†’ β„•) : β„•) : ℝ) := by exact_mod_cast Finset.le_sup (f := id) hh
push_cast
linarith
have hpos : 0 ≀ cost 1 (h+1) (finiteEmbedding _ (components p h)) := apply_nonneg _ _
have hb' := hb.trans (mul_le_mul_of_nonneg_right hm hpos)
have hs := (sq_le_sqβ‚€ (norm_nonneg _) (by positivity)).mpr hb'
simpa only [mul_pow,finiteCost,Seminorm.comp_apply] using hs
lemma linearBlocks : linearData.HilbertBlocks Sigma.fst where
orthogonal p q hd := outer_orthogonal _ p q (by
simpa only [Finset.disjoint_left,Finset.mem_image] using hd)
contractive := outer_contractive _
upper C := ⟨1,by norm_num,fun p _ => by simpa only [linearData,one_mul] using linear_upper p⟩
lower C := ⟨(((C.sup (id : β„• β†’ β„•) : β„•) : ℝ)+2)^2,by positivity,
fun p hp => linear_lower C p hp⟩
instance linearDualSeparable : TopologicalSpace.SeparableSpace (StrongDual ℝ LinearSpace) :=
linearData.dual_separable Sigma.fst linearBlocks
/-- The original weak-sequence input on the concrete linear path-cost space. -/
theorem linear_weak_graph (hinput : PathApplications.WeakInput LinearSpace)
{D s : ℝ} (k : β„•) (f : Diamond.Vertex k β†’ LinearSpace) (hf : Diamond.HasDistortion k f D s) :
1+(k:ℝ)/64 ≀ D^2 := PathApplications.weak_linear hinput k f hf
end PathModel
namespace StartModel
open RecursiveModel PathModel
namespace ContractiveMap
variable {E F : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]
[NormedAddCommGroup F] [NormedSpace ℝ F]
def lift (f : E β†’β‚—[ℝ] F) (hf : βˆ€ x,β€–f xβ€– ≀ β€–xβ€–) :
lp (fun _ : β„• => E) 2 β†’β‚—[ℝ] lp (fun _ : β„• => F) 2 where
toFun v := ⟨fun i => f (v i),v.property.mono' (fun i => hf (v i))⟩
map_add' v w := by ext i; exact f.map_add _ _
map_smul' c v := by ext i; exact f.map_smul c _
lemma lift_apply (f : E β†’β‚—[ℝ] F) (hf : βˆ€ x,β€–f xβ€– ≀ β€–xβ€–)
(v : lp (fun _ : β„• => E) 2) (i : β„•) : lift f hf v i=f (v i) := rfl
lemma lift_norm (f : E β†’β‚—[ℝ] F) (hf : βˆ€ x,β€–f xβ€– ≀ β€–xβ€–)
(v : lp (fun _ : β„• => E) 2) : β€–lift f hf vβ€– ≀ β€–vβ€– :=
lp.norm_mono (by norm_num) (fun i => hf (v i))
variable {G H : Type*} [NormedAddCommGroup G] [NormedSpace ℝ G]
[NormedAddCommGroup H] [NormedSpace ℝ H]
def prod₁ (f : E β†’β‚—[ℝ] F) (g : G β†’β‚—[ℝ] H) : WithLp 1 (E Γ— G) β†’β‚—[ℝ] WithLp 1 (F Γ— H) :=
(WithLp.linearEquiv 1 ℝ (F Γ— H)).symm.toLinearMap.comp
((f.prodMap g).comp (WithLp.linearEquiv 1 ℝ (E Γ— G)).toLinearMap)
lemma prod₁_norm (f : E β†’β‚—[ℝ] F) (g : G β†’β‚—[ℝ] H) (hf : βˆ€ x,β€–f xβ€– ≀ β€–xβ€–)
(hg : βˆ€ x,β€–g xβ€– ≀ β€–xβ€–) (d : WithLp 1 (E Γ— G)) : β€–prod₁ f g dβ€– ≀ β€–dβ€– := by
change β€–WithLp.toLp 1 (f d.fst,g d.snd)β€– ≀ β€–dβ€–
rw [WithLp.prod_norm_eq_of_L1,WithLp.prod_norm_eq_of_L1]
exact add_le_add (hf d.fst) (hg d.snd)
def single (E : Type*) [NormedAddCommGroup E] [NormedSpace ℝ E] :
{f : E β†’β‚—[ℝ] lp (fun _ : β„• => E) 1 // βˆ€ d,β€–f dβ€– ≀ β€–dβ€–} :=
⟨lp.lsingle (π•œ := ℝ) (E := fun _ : β„• => E) 1 0,fun d => by
change β€–(lp.single 1 0 d : lp (fun _ : β„• => E) 1)β€– ≀ β€–dβ€–
exact (lp.norm_single (E := fun _ : β„• => E) (p := 1) (by norm_num) 0 d).le⟩
end ContractiveMap
/-- Repetition labels are retained: each start node admits a countable sequence
of signed coefficient arrays over all its possible endpoints. Its mass is
the β„“ΒΉ sum of the β„“ΒΉ norms of these arrays, before any cancellation. -/
abbrev rawRepresentationModel : β„• β†’ RealNormed
| 0 => ⟨lp (fun _ : β„• => ℝ) 1⟩
| h+1 => ⟨WithLp 1 (lp (fun _ : β„• => L1 (h+1)) 1 Γ—
lp (fun _ : β„• => rawRepresentationModel h) 2)⟩
abbrev Raw (h : β„•) := rawRepresentationModel h
/-- Group repetitions at every start/end pair. Triangle inequalities make this
operation contractive, rather than an unjustified equality of costs. -/
def compression : (h : β„•) β†’ {f : Raw h β†’β‚—[ℝ] Rep h // βˆ€ d,β€–f dβ€– ≀ β€–dβ€–}
| 0 => ⟨(lp.tsumCLM ℝ β„• ℝ).toLinearMap,lp.norm_tsum_le⟩
| h+1 =>
let prev := compression h
let rootMap := (lp.tsumCLM ℝ β„• (L1 (h+1))).toLinearMap
let child := ContractiveMap.lift prev.val prev.property
⟨ContractiveMap.prod₁ rootMap child,
ContractiveMap.prod₁_norm rootMap child lp.norm_tsum_le
(ContractiveMap.lift_norm prev.val prev.property)⟩
/-- A representation with no repetitions is also one of the arbitrary countable
representations, by placing all its coefficients in repetition row zero. -/
def expansion : (h : β„•) β†’ {f : Rep h β†’β‚—[ℝ] Raw h // βˆ€ d,β€–f dβ€– ≀ β€–dβ€–}
| 0 => ContractiveMap.single ℝ
| h+1 =>
let prev := expansion h
let rootMap := ContractiveMap.single (L1 (h+1))
let child := ContractiveMap.lift prev.val prev.property
⟨ContractiveMap.prod₁ rootMap.val child,
ContractiveMap.prod₁_norm rootMap.val child rootMap.property
(ContractiveMap.lift_norm prev.val prev.property)⟩
lemma tsum_single_zero {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] [CompleteSpace E] (x : E) :
lp.tsumCLM ℝ β„• E (lp.single 1 0 x)=x := by
change βˆ‘' i,(lp.single 1 0 x : lp (fun _ : β„• => E) 1) i=x
rw [tsum_eq_single 0,lp.single_apply_self]
intro i hi
exact lp.single_apply_ne _ _ _ hi
lemma compression_expansion (h : β„•) (d : Rep h) :
(compression h).val ((expansion h).val d)=d := by
induction h with
| zero => exact tsum_single_zero d
| succ h ih =>
apply WithLp.ofLp_injective
apply Prod.ext
Β· change lp.tsumCLM ℝ β„• (L1 (h+1)) (lp.single 1 0 d.fst)=d.fst
exact tsum_single_zero d.fst
Β· ext i
exact ih (d.snd i)
/-- Literal coordinatewise output of countably many signed segments: first sum
all rows with a common start/end, then use the absolutely summable path map. -/
def rawOutput (h : β„•) : Raw h β†’β‚—[ℝ] (Coord h β†’ ℝ) :=
(output h).comp (compression h).val
def rawRelation (h : β„•) : InfimalCost.Relation (Raw h) (Vec h) (Coord h β†’ ℝ) where
output := rawOutput h
value := (relation h).value
sectionMap := (expansion h).val.comp (finiteSection h)
section_output v := by
change output h ((compression h).val ((expansion h).val (finiteSection h v)))=(relation h).value v
rw [compression_expansion]
exact (relation h).section_output v
lemma raw_cost_eq (h : β„•) (v : Vec h) : (rawRelation h).seminorm v=finiteCost h v := by
apply le_antisymm
Β· apply (relation h).bound v
intro d hd
have he : (rawRelation h).output ((expansion h).val d)=(rawRelation h).value v := by
change output h ((compression h).val ((expansion h).val d))=(relation h).value v
rw [compression_expansion]
exact hd
exact ((rawRelation h).le_representation he).trans ((expansion h).property d)
Β· apply (rawRelation h).bound v
intro d hd
exact ((relation h).le_representation hd).trans ((compression h).property d)
/-- The start-cost infimum is unchanged when arbitrary repetitions are allowed.
No minimizer, finite optimal representation, or attained infimum is assumed. -/
theorem finiteCost_eq_raw_sInf (h : β„•) (v : Vec h) :
finiteCost h v=sInf {r : ℝ | βˆƒ d : Raw h,rawOutput h d=(fun s => v s) ∧ β€–dβ€–=r} := by
rw [← raw_cost_eq]
exact (rawRelation h).eq_sInf v
lemma lp1_norm {ΞΉ E : Type*} [NormedAddCommGroup E] (d : lp (fun _ : ΞΉ => E) 1) :
β€–dβ€–=βˆ‘' i,β€–d iβ€– := by
simpa only [ENNReal.toReal_one,one_div,inv_one,Real.rpow_one] using
lp.norm_eq_tsum_rpow (by norm_num : (0:ℝ)<(1:ℝβ‰₯0∞).toReal) d
lemma raw_norm_zero (d : Raw 0) : β€–dβ€–=βˆ‘' j,|d j| := by
rw [lp1_norm]
simp only [Real.norm_eq_abs]
/-- The exact start masses before any grouping or cancellation. -/
lemma raw_root_mass (h : β„•) (d : Raw (h+1)) :
β€–d.fstβ€–=βˆ‘' j,βˆ‘' s : Coord (h+1),|d.fst j s| := by
rw [lp1_norm]
apply tsum_congr
intro j
rw [lp1_norm]
simp only [Real.norm_eq_abs]
lemma raw_children_cost_sq (h : β„•) (d : Raw (h+1)) :
β€–d.sndβ€–^2=βˆ‘' i,β€–d.snd iβ€–^2 := by
simpa only [ENNReal.toReal_ofNat,Real.rpow_two] using
lp.norm_rpow_eq_tsum (by norm_num : (0:ℝ)<(2:ℝβ‰₯0∞).toReal) d.snd
lemma raw_norm_succ (h : β„•) (d : Raw (h+1)) :
β€–dβ€–=(βˆ‘' j,βˆ‘' s : Coord (h+1),|d.fst j s|)+Real.sqrt (βˆ‘' i,β€–d.snd iβ€–^2) := by
rw [WithLp.prod_norm_eq_of_L1,raw_root_mass,← raw_children_cost_sq,Real.sqrt_sq (norm_nonneg _)]
/-- Absolute convergence of all root-start row outputs, at every coordinate.
The rest of each coordinate's output is the finite ancestral recursion. -/
lemma raw_root_absolute (h : β„•) (d : Raw (h+1)) (r : Coord (h+1)) :
Summable (fun j => β€–path (h+1) (d.fst j) rβ€–) := by
have hs : Summable (fun j => β€–d.fst jβ€–) := by
simpa only [ENNReal.toReal_one,Real.rpow_one] using d.fst.property.summable (by norm_num : (0:ℝ)<(1:ℝβ‰₯0∞).toReal)
apply Summable.of_nonneg_of_le (fun j => norm_nonneg _) (fun j => ?_) hs
simpa only [Real.norm_eq_abs] using path_coordinate (h+1) (d.fst j) r
lemma raw_root_tsum (h : β„•) (d : Raw (h+1)) :
path (h+1) (lp.tsumCLM ℝ β„• (L1 (h+1)) d.fst)=βˆ‘' j,path (h+1) (d.fst j) := by
change path (h+1) (βˆ‘' j,d.fst j)=_
exact (path (h+1)).map_tsum (Summable.of_norm (by
simpa only [ENNReal.toReal_one,Real.rpow_one] using d.fst.property.summable (by norm_num : (0:ℝ)<(1:ℝβ‰₯0∞).toReal)))
end StartModel
end DiamondDistortion
end
end OAI