Download data/lean/OAI/Probability/FKMaps/MeasuredCoding.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 23.4 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/FKMaps/MeasuredCoding.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Probability/FKMaps/MeasuredCoding.lean
-
curl -L -o MeasuredCoding.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/FKMaps/MeasuredCoding.lean
23.4 kB
| import OAI.Probability.FKMaps.CornerMass | |
| namespace OAI | |
| noncomputable section | |
| open Set MeasureTheory | |
| open scoped BigOperators ENNReal | |
| namespace FKCRT | |
| attribute [local instance] Classical.propDecidable | |
| /-- Equal-Lebesgue-mass time cells. The endpoint one is assigned to the last | |
| cell; this retains a total, surjective coding without changing any mass. -/ | |
| def timeCell (N : β) (hN : 0<N) (t : unitInterval) : Fin N := | |
| β¨min β(N:β)*tββ (N-1),lt_of_le_of_lt (min_le_right _ _) (by omega)β© | |
| lemma timeCell_measurable (N : β) (hN : 0<N) : Measurable (timeCell N hN) := by | |
| apply measurable_to_countable | |
| intro t | |
| have he : timeCell N hN β»ΒΉ' {timeCell N hN t}= | |
| {s : unitInterval | min β(N:β)*sββ (N-1)=(timeCell N hN t).val} := by | |
| ext s | |
| simp only [Set.mem_preimage,Set.mem_singleton_iff,Set.mem_ofPred_eq,Fin.ext_iff,timeCell] | |
| rw [he] | |
| exact measurableSet_eq_fun ((Nat.measurable_floor.comp | |
| (measurable_const.mul measurable_subtype_coe)).min measurable_const) measurable_const | |
| lemma timeCell_of_lt_one (N : β) (hN : 0<N) (t : unitInterval) (ht : (t:β)<1) : | |
| (timeCell N hN t).val=β(N:β)*tββ := by | |
| dsimp [timeCell] | |
| apply min_eq_left | |
| have hf : β(N:β)*tββ<N := (Nat.floor_lt (mul_nonneg (Nat.cast_nonneg _) t.property.1)).mpr (by | |
| have hp : (0:β)<N := Nat.cast_pos.mpr hN | |
| nlinarith) | |
| omega | |
| lemma timeCell_eq_iff (N : β) (hN : 0<N) (t : unitInterval) (ht : (t:β)<1) (i : Fin N) : | |
| timeCell N hN t=i β (i.val:β)/(N:β)β€t β§ (t:β)<(i.val+1:β)/(N:β) := by | |
| rw [Fin.ext_iff,timeCell_of_lt_one N hN t ht,Nat.floor_eq_iff (mul_nonneg (Nat.cast_nonneg _) t.property.1)] | |
| have hp : (0:β)<N := Nat.cast_pos.mpr hN | |
| rw [div_le_iffβ hp,lt_div_iffβ hp] | |
| rw [mul_comm (t:β)] | |
| lemma cell_volume (N : β) (hN : 0<N) (i : Fin N) : | |
| (volume : Measure unitInterval) {t | (i.val:β)/(N:β)β€t β§ (t:β)<(i.val+1:β)/(N:β)}= | |
| ENNReal.ofReal (1/(N:β)) := by | |
| rw [volume_set_coe_def,comap_subtype_coe_apply measurableSet_Icc] | |
| have hp : (0:β)<N := Nat.cast_pos.mpr hN | |
| have hi : (i.val+1:β)β€N := by exact_mod_cast i.isLt | |
| have he : Subtype.val '' {t : unitInterval | (i.val:β)/(N:β)β€t β§ | |
| (t:β)<(i.val+1:β)/(N:β)}=Ico ((i.val:β)/(N:β)) ((i.val+1:β)/(N:β)) := by | |
| ext t | |
| constructor | |
| Β· rintro β¨t,ht,rflβ© | |
| exact ht | |
| Β· intro ht | |
| refine β¨β¨t,?_β©,ht,rflβ© | |
| constructor | |
| Β· exact (div_nonneg (Nat.cast_nonneg _) hp.le).trans ht.1 | |
| Β· exact ht.2.le.trans ((div_le_one hp).mpr hi) | |
| rw [he,Real.volume_Ico] | |
| congr 1 | |
| field_simp | |
| ring | |
| lemma timeCell_mass (N : β) (hN : 0<N) (i : Fin N) : | |
| ((volume : Measure unitInterval).map (timeCell N hN)) {i}=ENNReal.ofReal (1/(N:β)) := by | |
| rw [Measure.map_apply (timeCell_measurable N hN) (measurableSet_singleton i)] | |
| have he : timeCell N hN β»ΒΉ' {i}=α΅[volume] | |
| {t : unitInterval | (i.val:β)/(N:β)β€t β§ (t:β)<(i.val+1:β)/(N:β)} := by | |
| have hne : βα΅ t : unitInterval βvolume,tβ 1 := by | |
| rw [ae_iff] | |
| simp | |
| filter_upwards [hne] with t ht | |
| have ht' : (t:β)<1 := lt_of_le_of_ne t.property.2 (fun h => ht (Subtype.ext h)) | |
| exact propext (timeCell_eq_iff N hN t ht' i) | |
| rw [measure_congr he,cell_volume N hN i] | |
| lemma timeCell_map (N : β) (hN : 0<N) : | |
| (volume : Measure unitInterval).map (timeCell N hN)= | |
| β i : Fin N,ENNReal.ofReal (1/(N:β)) β’ Measure.dirac i := by | |
| apply Measure.ext_of_singleton | |
| intro i | |
| rw [timeCell_mass N hN i] | |
| simp [Measure.finsetSum_apply,Pi.single_apply] | |
| lemma timeCell_surjective (N : β) (hN : 0<N) : Function.Surjective (timeCell N hN) := by | |
| intro i | |
| have hp : (0:β)<N := Nat.cast_pos.mpr hN | |
| let t : unitInterval := β¨(i.val:β)/(N:β),by constructor;positivity;exact (div_le_one hp).mpr (by exact_mod_cast i.isLt.le)β© | |
| refine β¨t,(timeCell_eq_iff N hN t (by dsimp [t];exact (div_lt_one hp).mpr (by exact_mod_cast i.isLt)) i).mpr β¨le_rfl,?_β©β© | |
| dsimp [t] | |
| exact (div_lt_div_iff_of_pos_right hp).mpr (by linarith) | |
| lemma timeCell_mono (N : β) (hN : 0<N) : Monotone (timeCell N hN) := by | |
| intro s t hst | |
| change min β(N:β)*sββ (N-1) β€ min β(N:β)*tββ (N-1) | |
| exact min_le_min (Nat.floor_mono (mul_le_mul_of_nonneg_left hst (Nat.cast_nonneg _))) le_rfl | |
| lemma timeCell_bounds (N : β) (hN : 0<N) (t : unitInterval) : | |
| ((timeCell N hN t).val:β)/(N:β)β€t β§ | |
| (t:β)β€((timeCell N hN t).val+1:β)/(N:β) := by | |
| by_cases ht : (t:β)<1 | |
| Β· have hh := (timeCell_eq_iff N hN t ht (timeCell N hN t)).mp rfl | |
| exact β¨hh.1,hh.2.leβ© | |
| Β· have ht : t=1 := Subtype.ext (le_antisymm t.property.2 (le_of_not_gt ht)) | |
| subst t | |
| have he : (timeCell N hN 1).val=N-1 := by simp [timeCell] | |
| rw [he] | |
| have hn : (0:β)<N := Nat.cast_pos.mpr hN | |
| have he' : ((N-1:β):β)+1=N := by exact_mod_cast (show N-1+1=N by omega) | |
| constructor | |
| Β· exact (div_le_one hn).mpr (by linarith) | |
| Β· change (1:β)β€_ | |
| rw [he',div_self hn.ne'] | |
| /-- The positive preorder point lies inside its equal-mass time cell. -/ | |
| def cellPoint (N : β) (hN : 0<N) (i : Fin N) : unitInterval := | |
| β¨(i.val+1:β)/(N+1:β),by constructor;positivity;apply (div_le_one (by positivity)).mpr;exact_mod_cast Nat.add_le_add_right i.isLt.le 1β© | |
| lemma cellPoint_bounds (N : β) (hN : 0<N) (i : Fin N) : | |
| (i.val:β)/Nβ€cellPoint N hN i β§ | |
| (cellPoint N hN i:β)β€(i.val+1:β)/N := by | |
| have hn : (0:β)<N := Nat.cast_pos.mpr hN | |
| have hi : (i.val:β)β€N := by exact_mod_cast i.isLt.le | |
| change _β€(i.val+1:β)/(N+1:β) β§ (i.val+1:β)/(N+1:β)β€_ | |
| constructor | |
| Β· apply (div_le_div_iffβ hn (by positivity)).mpr | |
| nlinarith | |
| Β· apply div_le_div_of_nonneg_left (by positivity) hn | |
| linarith | |
| lemma cellPoint_close (N : β) (hN : 0<N) (t : unitInterval) : | |
| dist (cellPoint N hN (timeCell N hN t)) tβ€1/(N:β) := by | |
| have ht := timeCell_bounds N hN t | |
| have hp := cellPoint_bounds N hN (timeCell N hN t) | |
| have he : (((timeCell N hN t).val:β)+1)/(N:β)-((timeCell N hN t).val:β)/(N:β)=1/(N:β) := by ring | |
| rw [Subtype.dist_eq,Real.dist_eq] | |
| apply abs_le.mpr | |
| constructor <;> linarith | |
| lemma cellPoint_mono (N : β) (hN : 0<N) : Monotone (cellPoint N hN) := by | |
| intro i j hij | |
| change (i.val+1:β)/(N+1:β)β€(j.val+1:β)/(N+1:β) | |
| apply div_le_div_of_nonneg_right _ (by positivity) | |
| exact_mod_cast Nat.add_le_add_right hij 1 | |
| end FKCRT | |
| end | |
| noncomputable section | |
| open List Equiv Equiv.Perm MeasureTheory Set | |
| open scoped BigOperators ENNReal | |
| namespace FKCRT.Inventory.CoreTree | |
| open MapCycles PermutationWedge | |
| attribute [local instance] Classical.propDecidable | |
| /-- The exact degree-mass coding, using every nonroot preorder pole. -/ | |
| def timeVertex (t : CoreTree) {n : β} (M : FKCRT.RootedMap n) | |
| (e : t.Dart β FKCRT.Dart n) (ht : 0<t.word.length) (s : unitInterval) : FKCRT.Vertex M := | |
| t.nonrootVertex M e (FKCRT.timeCell t.word.length ht s) | |
| lemma timeVertex_measurable (t : CoreTree) {n : β} (M : FKCRT.RootedMap n) | |
| (e : t.Dart β FKCRT.Dart n) (ht : 0<t.word.length) : | |
| @Measurable _ _ inferInstance β€ (t.timeVertex M e ht) := by | |
| let : MeasurableSpace (FKCRT.Vertex M) := β€ | |
| exact (measurable_of_finite (t.nonrootVertex M e)).comp (FKCRT.timeCell_measurable _ ht) | |
| lemma timeVertex_surjective (t : CoreTree) {n : β} (M : FKCRT.RootedMap n) | |
| (e : t.Dart β FKCRT.Dart n) (ht : 0<t.word.length) | |
| (hp : β d,FKCRT.rotation M (e d)=e ((t.darts.formPerm*turns t.matching.first) d)) : | |
| Function.Surjective (t.timeVertex M e ht) := | |
| (t.nonrootVertex_surjective M e hp).comp (FKCRT.timeCell_surjective _ ht) | |
| /-- No asymptotic replacement of the degree measure is needed. -/ | |
| theorem timeVertex_mass (t : CoreTree) {n : β} (M : FKCRT.RootedMap n) | |
| (e : t.Dart β FKCRT.Dart n) (ht : 0<t.word.length) | |
| (hp : β d,FKCRT.rotation M (e d)=e ((t.darts.formPerm*turns t.matching.first) d)) | |
| (hlen : t.word.length=2*(n+1)) : | |
| @Measure.map _ _ inferInstance β€ (t.timeVertex M e ht) volume=FKCRT.degreeMass M := by | |
| let : MeasurableSpace (FKCRT.Vertex M) := β€ | |
| change (volume : Measure unitInterval).map ((t.nonrootVertex M e) β FKCRT.timeCell t.word.length ht)=_ | |
| rw [β Measure.map_map (measurable_of_finite (t.nonrootVertex M e)) | |
| (FKCRT.timeCell_measurable _ ht),FKCRT.timeCell_map] | |
| rw [Measure.map_finset_sum' (measurable_of_finite (t.nonrootVertex M e)).aemeasurable] | |
| simp only [Measure.map_smul _ (measurable_of_finite (t.nonrootVertex M e)).aemeasurable, | |
| Measure.map_dirac' (measurable_of_finite (t.nonrootVertex M e))] | |
| rw [β Finset.smul_sum,t.nonroot_dirac_eq M e hp] | |
| rw [FKCRT.degreeMass,β Finset.smul_sum] | |
| congr 1 | |
| rw [hlen] | |
| norm_num | |
| lemma realized_distance_of (t : CoreTree) {n : β} (M : FKCRT.RootedMap n) | |
| (e : t.Dart β FKCRT.Dart n) | |
| (he : β d,FKCRT.reversal M (e d)=e (t.matching.mate d)) | |
| (hp : β d,FKCRT.rotation M (e d)=e ((t.darts.formPerm*turns t.matching.first) d)) (a b : t.Dart) : | |
| ((FKCRT.graph M Set.univ).dist (orbit (FKCRT.rotation M) (e a)) | |
| (orbit (FKCRT.rotation M) (e b)):β)=t.realDistance a b := by | |
| have hh := dartGraph_embedding_edist e e.injective hp he a b | |
| rw [FKCRT.dartGraph_eq_spanning] at hh | |
| change (FKCRT.graph M Set.univ).edist _ _=t.matching.distance a b at hh | |
| change (FKCRT.graph M Set.univ).edist (orbit (FKCRT.rotation M) (e a)) | |
| (orbit (FKCRT.rotation M) (e b))=t.matching.distance a b at hh | |
| rw [t.distance_eq_nat a b] at hh | |
| have hr : (FKCRT.graph M Set.univ).Reachable | |
| (orbit (FKCRT.rotation M) (e a)) (orbit (FKCRT.rotation M) (e b)) := by | |
| apply SimpleGraph.edist_ne_top_iff_reachable.mp | |
| rw [hh] | |
| exact ENat.natCast_ne_top _ | |
| rw [β SimpleGraph.Reachable.coe_dist_eq_edist hr] at hh | |
| dsimp only [realDistance] | |
| exact_mod_cast hh | |
| /-- Direct measured common-coding comparison of the actual finite map with | |
| any continuous excursion metric, with no unmeasured-GH substitution. -/ | |
| theorem ghp_from_time_distortion (t : CoreTree) {n : β} (M : FKCRT.RootedMap n) | |
| (e : t.Dart β FKCRT.Dart n) (ht : 0<t.word.length) | |
| (hp : β d,FKCRT.rotation M (e d)=e ((t.darts.formPerm*turns t.matching.first) d)) | |
| (hlen : t.word.length=2*(n+1)) (f : C(unitInterval,β)) | |
| {scale Ξ΅ : β} (hs : 0<scale) (hΞ΅ : 0<Ξ΅) | |
| (hd : β s u,|scale*((FKCRT.graph M Set.univ).dist (t.timeVertex M e ht s) | |
| (t.timeVertex M e ht u):β)-FKCRT.excursionDist f s u|β€2*Ξ΅) : | |
| FKCRT.ghpEDist (FKCRT.mapSpace scale M) (FKCRT.treeSpace f)β€ENNReal.ofReal Ξ΅ := by | |
| apply FKCRT.ghpEDist_le_of_coding (FKCRT.mapSpace_valid hs M) | |
| (FKCRT.treeSpace_valid f.continuous) (volume : Measure unitInterval) | |
| (t.timeVertex M e ht) (FKCRT.treeProjection f) | |
| (t.timeVertex_measurable M e ht) (FKCRT.treeProjection_measurable f) | |
| (t.timeVertex_surjective M e ht hp) (FKCRT.treeProjection_surjective f) | |
| (t.timeVertex_mass M e ht hp hlen) rfl hΞ΅ | |
| intro s u | |
| change |scale*((FKCRT.graph M Set.univ).dist _ _:β)- | |
| FKCRT.excursionDist f (FKCRT.treeProjection f s).out (FKCRT.treeProjection f u).out|β€_ | |
| rw [FKCRT.excursionDist_out f.continuous] | |
| exact hd s u | |
| end FKCRT.Inventory.CoreTree | |
| end | |
| noncomputable section | |
| open Set | |
| namespace FKCRT | |
| attribute [local instance] Classical.propDecidable | |
| lemma cellPoint_interval_near (N : β) (hN : 0<N) (s t : unitInterval) (hst : s β€ t) | |
| (i : Fin N) (hsi : timeCell N hN s β€ i) (hit : i β€ timeCell N hN t) : | |
| β uβuIcc s t,dist (cellPoint N hN i) u β€ 1/(N:β) := by | |
| let p := cellPoint N hN i | |
| by_cases hs : p<s | |
| Β· refine β¨s,left_mem_uIcc,?_β© | |
| have hh := cellPoint_close N hN s | |
| have ho := cellPoint_mono N hN hsi | |
| change (cellPoint N hN (timeCell N hN s):β) β€ (p:β) at ho | |
| rw [Subtype.dist_eq,Real.dist_eq] at hh β’ | |
| rw [abs_of_nonpos (sub_nonpos.mpr (show (p:β) β€ s from hs.le))] | |
| have hh' := (abs_le.mp hh).1 | |
| linarith | |
| Β· by_cases ht : t<p | |
| Β· refine β¨t,right_mem_uIcc,?_β© | |
| have hh := cellPoint_close N hN t | |
| have ho := cellPoint_mono N hN hit | |
| change (p:β) β€ (cellPoint N hN (timeCell N hN t):β) at ho | |
| rw [Subtype.dist_eq,Real.dist_eq] at hh β’ | |
| rw [abs_of_nonneg (sub_nonneg.mpr (show (t:β) β€ p from ht.le))] | |
| have hh' := (abs_le.mp hh).2 | |
| linarith | |
| Β· refine β¨p,?_,?_β© | |
| Β· rw [uIcc_of_le hst] | |
| exact β¨le_of_not_gt hs,le_of_not_gt htβ© | |
| Β· change dist p p β€ _ | |
| rw [dist_self] | |
| positivity | |
| lemma sampled_minimum_error (N : β) (hN : 0<N) (f : C(unitInterval,β)) | |
| {Ξ· : β} (hmod : β s t,dist s t β€ 1/(N:β) β |f s-f t| β€ Ξ·) | |
| (s t : unitInterval) (hst : s β€ t) (m : Fin N) | |
| (hsm : timeCell N hN s β€ m) (hmt : m β€ timeCell N hN t) | |
| (hm : β i,timeCell N hN s β€ i β i β€ timeCell N hN t β | |
| f (cellPoint N hN m) β€ f (cellPoint N hN i)) : | |
| |f (cellPoint N hN m)-sInf (f '' uIcc s t)| β€ Ξ· := by | |
| obtain β¨u,hu,hduβ© := cellPoint_interval_near N hN s t hst m hsm hmt | |
| have hi := csInf_le (interval_image_bddBelow f.continuous s t) (mem_image_of_mem f hu) | |
| have hmdu := abs_le.mp (hmod _ _ hdu) | |
| have hl : f (cellPoint N hN m)-Ξ· β€ sInf (f '' uIcc s t) := by | |
| apply le_csInf (nonempty_uIcc.image f) | |
| rintro _ β¨r,hr,rflβ© | |
| rw [uIcc_of_le hst] at hr | |
| have hmr := hm (timeCell N hN r) (timeCell_mono N hN hr.1) (timeCell_mono N hN hr.2) | |
| have hclose := abs_le.mp (hmod _ _ (cellPoint_close N hN r)) | |
| linarith | |
| apply abs_le.mpr | |
| constructor <;> linarith | |
| /-- Discrete positive preorder samples and their exact equal-mass coding | |
| approximate the continuous interval-minimum metric with its own modulus. -/ | |
| theorem sampled_excursion_error (N : β) (hN : 0<N) (f : C(unitInterval,β)) | |
| {Ξ· : β} (hmod : β s t,dist s t β€ 1/(N:β) β |f s-f t| β€ Ξ·) | |
| (s t : unitInterval) (hst : s β€ t) (m : Fin N) | |
| (hsm : timeCell N hN s β€ m) (hmt : m β€ timeCell N hN t) | |
| (hm : β i,timeCell N hN s β€ i β i β€ timeCell N hN t β | |
| f (cellPoint N hN m) β€ f (cellPoint N hN i)) : | |
| |(f (cellPoint N hN (timeCell N hN s))+f (cellPoint N hN (timeCell N hN t))- | |
| 2*f (cellPoint N hN m))-excursionDist f s t| β€ 4*Ξ· := by | |
| have hβ := abs_le.mp (hmod _ _ (cellPoint_close N hN s)) | |
| have hβ := abs_le.mp (hmod _ _ (cellPoint_close N hN t)) | |
| have hβ := abs_le.mp (sampled_minimum_error N hN f hmod s t hst m hsm hmt hm) | |
| dsimp only [excursionDist] | |
| apply abs_le.mpr | |
| constructor <;> linarith | |
| end FKCRT | |
| end | |
| noncomputable section | |
| open List Equiv Equiv.Perm MeasureTheory Set | |
| open scoped BigOperators ENNReal | |
| namespace FKCRT.Inventory.CoreTree | |
| open MapCycles PermutationWedge | |
| attribute [local instance] Classical.propDecidable | |
| lemma wordNodeEquiv_val (t : CoreTree) (v : t.Node) : (t.wordNodeEquiv v).val=t.nodeIndex v := rfl | |
| lemma nodeIndex_wordNodeEquiv_symm (t : CoreTree) (i : Fin (t.word.length+1)) : | |
| t.nodeIndex (t.wordNodeEquiv.symm i)=i.val := by | |
| exact congrArg Fin.val (t.wordNodeEquiv.apply_symm_apply i) | |
| /-- Same-code positive mesh, with the omitted root still present at time zero. -/ | |
| def nodePoint (t : CoreTree) (v : t.Node) : unitInterval := | |
| β¨((t.wordNodeEquiv v).val:β)/(t.word.length+1:β),by | |
| constructor | |
| Β· positivity | |
| Β· apply (div_le_one (by positivity)).mpr | |
| exact_mod_cast (t.wordNodeEquiv v).isLt.leβ© | |
| lemma nodePoint_nonroot (t : CoreTree) (ht : 0<t.word.length) (i : Fin t.word.length) : | |
| t.nodePoint (t.wordNodeEquiv.symm i.succ)=FKCRT.cellPoint t.word.length ht i := by | |
| apply Subtype.ext | |
| simp only [nodePoint,t.wordNodeEquiv.apply_symm_apply,Fin.val_succ,FKCRT.cellPoint,Nat.cast_add,Nat.cast_one] | |
| lemma normalized_pole_comparison (t : CoreTree) (v w m : t.Node) (a b : t.Dart) | |
| (ha : t.pole v=some a) (hb : t.pole w=some b) | |
| (hmβ : t.nodeIndex v β€ t.nodeIndex m) (hmβ : t.nodeIndex m β€ t.nodeIndex w) | |
| (f : t.Node β β) {scale Ξ΅ : β} (hs : 0<scale) | |
| (herr : β u,|scale*(t.routeLength u:β)-f u| β€ Ξ΅) | |
| (hmin : β u,t.nodeIndex v β€ t.nodeIndex u β t.nodeIndex u β€ t.nodeIndex w β f m β€ f u) : | |
| |scale*t.realDistance a b-(f v+f w-2*f m)| β€ 4*scale*(t.maxDegree:β)+4*Ξ΅ := by | |
| have he : β u,|(t.routeLength u:β)-(1/scale)*f u| β€ Ξ΅/scale := by | |
| intro u | |
| have heq : (t.routeLength u:β)-(1/scale)*f u=(scale*(t.routeLength u:β)-f u)/scale := by | |
| field_simp | |
| rw [heq,abs_div,abs_of_pos hs] | |
| exact div_le_div_of_nonneg_right (herr u) hs.le | |
| have hh := t.pole_walk_comparison v w m a b ha hb hmβ hmβ f | |
| (Ξ± := 1/scale) (Ξ΅ := Ξ΅/scale) (by positivity) he hmin | |
| calc | |
| |scale*t.realDistance a b-(f v+f w-2*f m)|= | |
| |scale*(t.realDistance a b-(1/scale)*(f v+f w-2*f m))| := by | |
| congr 1 | |
| field_simp | |
| _=scale*|t.realDistance a b-(1/scale)*(f v+f w-2*f m)| := by rw [abs_mul,abs_of_pos hs] | |
| _ β€ scale*(4*(t.maxDegree:β)+4*(Ξ΅/scale)) := mul_le_mul_of_nonneg_left hh hs.le | |
| _=4*scale*(t.maxDegree:β)+4*Ξ΅ := by field_simp | |
| end FKCRT.Inventory.CoreTree | |
| end | |
| noncomputable section | |
| open List Equiv Equiv.Perm MeasureTheory Set | |
| open scoped BigOperators ENNReal | |
| namespace FKCRT.Inventory.CoreTree | |
| open MapCycles PermutationWedge | |
| attribute [local instance] Classical.propDecidable | |
| lemma exists_positive_index (t : CoreTree) (v : t.Node) (hv : 0<t.nodeIndex v) : | |
| β i : Fin t.word.length,t.wordNodeEquiv.symm i.succ=v := by | |
| have hb := (t.wordNodeEquiv v).isLt | |
| rw [wordNodeEquiv_val] at hb | |
| let i : Fin t.word.length := β¨t.nodeIndex v-1,by omegaβ© | |
| refine β¨i,t.wordNodeEquiv.symm_apply_eq.mpr ?_β© | |
| apply Fin.ext | |
| change t.nodeIndex v-1+1=t.nodeIndex v | |
| omega | |
| lemma time_distortion_ordered (t : CoreTree) {n : β} (M : FKCRT.RootedMap n) | |
| (e : t.Dart β FKCRT.Dart n) (ht : 0<t.word.length) | |
| (he : β d,FKCRT.reversal M (e d)=e (t.matching.mate d)) | |
| (hp : β d,FKCRT.rotation M (e d)=e ((t.darts.formPerm*turns t.matching.first) d)) | |
| (f : C(unitInterval,β)) {scale Ξ΅ Ξ· : β} (hs : 0<scale) | |
| (herr : β v,|scale*(t.routeLength v:β)-f (t.nodePoint v)| β€ Ξ΅) | |
| (hmod : β s u,dist s u β€ 1/(t.word.length:β) β |f s-f u| β€ Ξ·) | |
| (s u : unitInterval) (hsu : s β€ u) : | |
| |scale*((FKCRT.graph M Set.univ).dist (t.timeVertex M e ht s) | |
| (t.timeVertex M e ht u):β)-FKCRT.excursionDist f s u| β€ | |
| 4*scale*(t.maxDegree:β)+4*Ξ΅+4*Ξ· := by | |
| let i := FKCRT.timeCell t.word.length ht s | |
| let j := FKCRT.timeCell t.word.length ht u | |
| have hij : i β€ j := FKCRT.timeCell_mono _ ht hsu | |
| obtain β¨k,hk,hminβ© := Finset.exists_min_image (Finset.Icc i j) | |
| (fun k => f (FKCRT.cellPoint t.word.length ht k)) β¨i,Finset.mem_Icc.mpr β¨le_rfl,hijβ©β© | |
| have hki := (Finset.mem_Icc.mp hk).1 | |
| have hkj := (Finset.mem_Icc.mp hk).2 | |
| let v := t.wordNodeEquiv.symm i.succ | |
| let w := t.wordNodeEquiv.symm j.succ | |
| let m := t.wordNodeEquiv.symm k.succ | |
| have hv : t.nodeIndex v=i.val+1 := t.nodeIndex_wordNodeEquiv_symm i.succ | |
| have hw : t.nodeIndex w=j.val+1 := t.nodeIndex_wordNodeEquiv_symm j.succ | |
| have hm : t.nodeIndex m=k.val+1 := t.nodeIndex_wordNodeEquiv_symm k.succ | |
| have hvm : t.nodeIndex v β€ t.nodeIndex m := by rw [hv,hm];omega | |
| have hmw : t.nodeIndex m β€ t.nodeIndex w := by rw [hm,hw];omega | |
| have hn : tβ leaf := by intro h;subst t;simp [word] at ht | |
| obtain β¨a,haβ© := t.pole_some_of_ne_leaf hn v | |
| obtain β¨b,hbβ© := t.pole_some_of_ne_leaf hn w | |
| have hm' : β z,t.nodeIndex v β€ t.nodeIndex z β t.nodeIndex z β€ t.nodeIndex w β | |
| f (t.nodePoint m) β€ f (t.nodePoint z) := by | |
| intro z hzβ hzβ | |
| obtain β¨r,hrβ© := t.exists_positive_index z (by omega) | |
| subst z | |
| rw [t.nodePoint_nonroot ht k,t.nodePoint_nonroot ht r] | |
| apply hmin r | |
| rw [Finset.mem_Icc] | |
| simp only [v,w,t.nodeIndex_wordNodeEquiv_symm,Fin.val_succ] at hzβ hzβ | |
| constructor <;> omega | |
| have hd := t.normalized_pole_comparison v w m a b ha hb hvm hmw | |
| (fun z => f (t.nodePoint z)) hs herr hm' | |
| have hgrid := FKCRT.sampled_excursion_error t.word.length ht f hmod s u hsu k hki hkj | |
| (fun r hrβ hrβ => hmin r (Finset.mem_Icc.mpr β¨hrβ,hrββ©)) | |
| have hvp : t.nodePoint v=FKCRT.cellPoint t.word.length ht i := t.nodePoint_nonroot ht i | |
| have hwp : t.nodePoint w=FKCRT.cellPoint t.word.length ht j := t.nodePoint_nonroot ht j | |
| have hmp : t.nodePoint m=FKCRT.cellPoint t.word.length ht k := t.nodePoint_nonroot ht k | |
| simp only [hvp,hwp,hmp] at hd | |
| change |scale*((FKCRT.graph M Set.univ).dist (t.realizedPole M e v) | |
| (t.realizedPole M e w):β)-FKCRT.excursionDist f s u| β€ _ | |
| rw [t.realizedPole_some M e v a ha,t.realizedPole_some M e w b hb, | |
| t.realized_distance_of M e he hp a b] | |
| exact (abs_sub_le _ _ _).trans (add_le_add hd hgrid) | |
| /-- Uniform measured-space distortion from actual marked ancestral error, | |
| actual largest core, and the modulus of the chosen continuous path. -/ | |
| theorem time_distortion (t : CoreTree) {n : β} (M : FKCRT.RootedMap n) | |
| (e : t.Dart β FKCRT.Dart n) (ht : 0<t.word.length) | |
| (he : β d,FKCRT.reversal M (e d)=e (t.matching.mate d)) | |
| (hp : β d,FKCRT.rotation M (e d)=e ((t.darts.formPerm*turns t.matching.first) d)) | |
| (f : C(unitInterval,β)) {scale Ξ΅ Ξ· : β} (hs : 0<scale) | |
| (herr : β v,|scale*(t.routeLength v:β)-f (t.nodePoint v)| β€ Ξ΅) | |
| (hmod : β s u,dist s u β€ 1/(t.word.length:β) β |f s-f u| β€ Ξ·) | |
| (s u : unitInterval) : | |
| |scale*((FKCRT.graph M Set.univ).dist (t.timeVertex M e ht s) | |
| (t.timeVertex M e ht u):β)-FKCRT.excursionDist f s u| β€ | |
| 4*scale*(t.maxDegree:β)+4*Ξ΅+4*Ξ· := by | |
| rcases le_total s u with h | h | |
| Β· exact t.time_distortion_ordered M e ht he hp f hs herr hmod s u h | |
| Β· rw [SimpleGraph.dist_comm,FKCRT.excursionDist_comm] | |
| exact t.time_distortion_ordered M e ht he hp f hs herr hmod u s h | |
| /-- The measured comparison is oriented from the fixed continuous-tree | |
| space, precisely as required in the continuity tests. -/ | |
| theorem ghp_tree_map_bound (t : CoreTree) {n : β} (M : FKCRT.RootedMap n) | |
| (e : t.Dart β FKCRT.Dart n) (ht : 0<t.word.length) | |
| (he : β d,FKCRT.reversal M (e d)=e (t.matching.mate d)) | |
| (hp : β d,FKCRT.rotation M (e d)=e ((t.darts.formPerm*turns t.matching.first) d)) | |
| (hlen : t.word.length=2*(n+1)) (f : C(unitInterval,β)) | |
| {scale Ξ΅ Ξ· Ξ΄ : β} (hs : 0<scale) (hΞ΄ : 0<Ξ΄) | |
| (herr : β v,|scale*(t.routeLength v:β)-f (t.nodePoint v)| β€ Ξ΅) | |
| (hmod : β s u,dist s u β€ 1/(t.word.length:β) β |f s-f u| β€ Ξ·) | |
| (hsmall : 4*scale*(t.maxDegree:β)+4*Ξ΅+4*Ξ· β€ 2*Ξ΄) : | |
| FKCRT.ghpEDist (FKCRT.treeSpace f) (FKCRT.mapSpace scale M) β€ ENNReal.ofReal Ξ΄ := by | |
| apply FKCRT.ghpEDist_le_of_coding (FKCRT.treeSpace_valid f.continuous) | |
| (FKCRT.mapSpace_valid hs M) (volume : Measure unitInterval) | |
| (FKCRT.treeProjection f) (t.timeVertex M e ht) | |
| (FKCRT.treeProjection_measurable f) (t.timeVertex_measurable M e ht) | |
| (FKCRT.treeProjection_surjective f) (t.timeVertex_surjective M e ht hp) | |
| rfl (t.timeVertex_mass M e ht hp hlen) hΞ΄ | |
| intro s u | |
| change |FKCRT.excursionDist f (FKCRT.treeProjection f s).out (FKCRT.treeProjection f u).out- | |
| scale*((FKCRT.graph M Set.univ).dist _ _:β)| β€ _ | |
| rw [FKCRT.excursionDist_out f.continuous,abs_sub_comm] | |
| exact (t.time_distortion M e ht he hp f hs herr hmod s u).trans hsmall | |
| end FKCRT.Inventory.CoreTree | |
| end | |
| end OAI | |