math / data /lean /OAI /Probability /Ballisticity /Geometry /WindowProjection.lean
introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
7.95 kB
import Mathlib
import OAI.Probability.Ballisticity.Estimates.AnchorFrameReference
import OAI.Probability.Ballisticity.Geometry.RawWindow
import OAI.Probability.Ballisticity.Estimates.InputMarginal
namespace OAI
section
open MeasureTheory ProbabilityTheory InformationTheory
open scoped ENNReal Classical
namespace DirectionalTransience
abbrev CurrentProfiles {d : β„•} (e : Direction d) :=
(β„• Γ— HorizontalSpace e) β†’ Set.Icc (0 : ℝ) 1
abbrev CurrentWindow {d : β„•} (e : Direction d) :=
(ReferenceClasses.Data (HorizontalSpace e) Γ— CurrentProfiles e) Γ—
ReferenceClasses.AllFields (HorizontalSpace e) (Row d)
noncomputable def rawCurrentProfiles {d : β„•} (e : Direction d)
(z : RawCurrentData e) : CurrentProfiles e :=
fun p => globalHorizontalCoordinate e z.1 z.2.1 (z.2.2 p.1 + p.2)
lemma rawCurrentProfileCoordinate_measurable {d : β„•} (e : Direction d)
(a : β„•) (z : HorizontalSpace e) :
Measurable (fun p : RawCurrentData e => globalHorizontalCoordinate e p.1 p.2.1 (p.2.2 a+z)) := by
have hw : Measurable (fun p : RawCurrentData e => p.2.1) := measurable_fst.comp measurable_snd
have hn : Measurable (fun p : RawCurrentData e => p.1) := measurable_fst
have hu : Measurable (fun p : RawCurrentData e => p.2.2 a) :=
(measurable_pi_apply a).comp (measurable_snd.comp measurable_snd)
have ha : Measurable (fun p : RawCurrentData e => ((p.2.1,p.1),p.2.2 a+z)) :=
(hw.prodMk hn).prodMk (hu.add_const z)
have hm := (globalHorizontalCoordinate_joint_measurable e).comp ha
simpa only [Function.comp_def] using hm
lemma rawCurrentProfiles_measurable {d : β„•} (e : Direction d) :
Measurable (rawCurrentProfiles e) :=
Measurable.of_eval fun p => rawCurrentProfileCoordinate_measurable e p.1 p.2
noncomputable def rawCurrentProjection {d : β„•} (e : Direction d)
(p : RawCurrentData e Γ— LocalUpperField e) : CurrentWindow e :=
((ReferenceClasses.anchorOffsets p.1.2.2,rawCurrentProfiles e p.1),
ReferenceClasses.anchorFields p.1.2.2 p.2)
lemma rawCurrentProjection_measurable {d : β„•} (e : Direction d) :
Measurable (rawCurrentProjection e) := by
have hU : Measurable (fun p : RawCurrentData e Γ— LocalUpperField e => p.1.2.2) :=
measurable_snd.comp (measurable_snd.comp measurable_fst)
exact ((ReferenceClasses.anchorOffsets_measurable.comp hU).prodMk
((rawCurrentProfiles_measurable e).comp measurable_fst)).prodMk
(ReferenceClasses.anchorFields_measurable.comp (hU.prodMk measurable_snd))
noncomputable def currentWindowReference {d : β„•} (e : Direction d) (Ξ½ : Measure (Row d))
[IsProbabilityMeasure Ξ½] :
Kernel (ReferenceClasses.Data (HorizontalSpace e) Γ— CurrentProfiles e)
(ReferenceClasses.AllFields (HorizontalSpace e) (Row d)) :=
(ReferenceClasses.reference Ξ½).comap Prod.fst measurable_fst
instance currentWindowReference_markov {d : β„•} (e : Direction d) (Ξ½ : Measure (Row d))
[IsProbabilityMeasure Ξ½] : IsMarkovKernel (currentWindowReference e Ξ½) := by
unfold currentWindowReference
infer_instance
lemma rawCurrentProjection_kl_le {d : β„•} (e : Direction d)
(Ξ½ : Measure (Row d)) [IsProbabilityMeasure Ξ½]
(ΞΌ : Measure (RawCurrentData e Γ— LocalUpperField e)) [IsFiniteMeasure ΞΌ] :
let out := ΞΌ.map (rawCurrentProjection e)
klDiv out (out.fst.compProd (currentWindowReference e Ξ½)) ≀
klDiv ΞΌ (ΞΌ.fst.prod (Measure.infinitePi (fun _ : β„• Γ— HorizontalSpace e => Ξ½))) := by
exact ReferenceClasses.anchorFrame_kl_le ΞΌ Ξ½ (fun z => z.2.2)
(measurable_snd.comp measurable_snd) (rawCurrentProfiles e) (rawCurrentProfiles_measurable e)
noncomputable def actualCurrentWindow {d : β„•} (e : Direction d)
(t : Environment d β†’ β„€ β†’ β„•) (i : β„€) (m : β„•) (X : EpisodeInput e) : CurrentWindow e :=
((ReferenceClasses.anchorOffsets (fun a => X.1.2 (i,a)),
fun p => globalHorizontalCoordinate e (t X.1.1 i) X.1.1 (X.1.2 (i,p.1)+p.2)),
fun p => episodeSplicedRow e t X i m p.1 p.2.1 p.2.2)
lemma actualCurrentWindow_measurable {d : β„•} (e : Direction d)
(t : Environment d β†’ β„€ β†’ β„•) (ht : βˆ€ i, Measurable fun Ο‰ => t Ο‰ i)
(i : β„€) (m : β„•) : Measurable (actualCurrentWindow e t i m) := by
have hu : Measurable (fun X : EpisodeInput e => fun a => X.1.2 (i,a)) :=
Measurable.of_eval fun a => (measurable_pi_apply (i,a)).comp
(measurable_snd.comp measurable_fst)
have ho := ReferenceClasses.anchorOffsets_measurable.comp hu
have hp : Measurable (fun X : EpisodeInput e => fun p : β„• Γ— HorizontalSpace e =>
globalHorizontalCoordinate e (t X.1.1 i) X.1.1 (X.1.2 (i,p.1)+p.2)) :=
Measurable.of_eval fun p => actualArrayCoordinate_measurable e t ht i (i,p.1) p.2
have hf : Measurable (fun X : EpisodeInput e => fun p : ReferenceClasses.Site (HorizontalSpace e) =>
episodeSplicedRow e t X i m p.1 p.2.1 p.2.2) :=
Measurable.of_eval fun p => episodeSplicedRow_measurable e t ht i m p.1 p.2.1 p.2.2
exact (ho.prodMk hp).prodMk hf
lemma globalHorizontalCoordinate_stoppedObservation {d : β„•} (e : Direction d)
(Ο„ : Environment d β†’ β„•)
(hΟ„ : βˆ€ n : β„•, MeasurableSet[rowSigma (BelowHeight (realPosition (step e)) n)] {Ο‰ | Ο„ Ο‰=n})
(filler Ο‰ : Environment d) (z : HorizontalSpace e) :
globalHorizontalCoordinate e (Ο„ Ο‰)
(stoppedObservation (fun n => BelowHeight (realPosition (step e)) n) Ο„ filler Ο‰) z =
globalHorizontalCoordinate e (Ο„ Ο‰) Ο‰ z := by
have h := currentStoppedProfile_observation e Ο„ hΟ„ filler Ο‰
have hn : Ο„ (stoppedObservation (fun n => BelowHeight (realPosition (step e)) n) Ο„ filler Ο‰) = Ο„ Ο‰ :=
stoppedRowGraft_stop (fun n => BelowHeight (realPosition (step e)) n) Ο„ hΟ„ Ο‰ filler
dsimp only [currentStoppedProfile] at h
rw [hn] at h
apply Subtype.ext
exact congrArg (fun ΞΌ : Measure (HorizontalSpace e) => (ΞΌ {z}).toReal) h
lemma actualCurrentWindow_raw {d : β„•} (e : Direction d)
(t : Environment d β†’ β„€ β†’ β„•) (i : β„€) (m : β„•)
(ht : βˆ€ n : β„•, MeasurableSet[rowSigma (BelowHeight (realPosition (step e)) n)]
{Ο‰ | t Ο‰ i=n}) (filler : Environment d) (X : EpisodeInput e) :
rawCurrentProjection e ((t X.1.1 i,
(stoppedObservation (fun n => BelowHeight (realPosition (step e)) n)
(fun Ο‰ => t Ο‰ i) filler X.1.1,fun a => X.1.2 (i,a))),
localStoppedField e (fun Ο‰ => t Ο‰ i) (fun Ο‰ => t Ο‰ (i+m)) (X.1.1,X.2 (i,m))) =
actualCurrentWindow e t i m X := by
dsimp only [rawCurrentProjection,actualCurrentWindow,rawCurrentProfiles]
refine Prod.ext (Prod.ext rfl ?_) ?_
Β· funext p
exact globalHorizontalCoordinate_stoppedObservation e (fun Ο‰ => t Ο‰ i) ht filler X.1.1 _
Β· funext p
dsimp only [ReferenceClasses.anchorFields,localStoppedField,episodeSplicedRow]
theorem actualCurrentWindow_law {d : β„•} (e : Direction d)
(Ξ½ : Measure (Row d)) [IsProbabilityMeasure Ξ½]
(Q : Measure (Environment d)) [IsFiniteMeasure Q]
(t : Environment d β†’ β„€ β†’ β„•) (ht : βˆ€ i, Measurable fun Ο‰ => t Ο‰ i)
(i : β„€) (m : β„•)
(hi : βˆ€ n : β„•, MeasurableSet[rowSigma (BelowHeight (realPosition (step e)) n)] {Ο‰ | t Ο‰ i=n})
(him : βˆ€ n : β„•, MeasurableSet[rowSigma (BelowHeight (realPosition (step e)) n)] {Ο‰ | t Ο‰ (i+m)=n})
(filler : Environment d) :
(rawCurrentWindow e Ξ½ Q (fun Ο‰ => t Ο‰ i) (fun Ο‰ => t Ο‰ (i+m)) (ht i) filler).map
(rawCurrentProjection e) =
(episodeInputLaw e Ξ½ Q t ht).map (actualCurrentWindow e t i m) := by
unfold rawCurrentWindow
rw [← episodeInputLaw_current e Ξ½ Q t ht i m]
rw [Measure.map_map (rawCurrentWindow_measurable e _ _ hi him filler)
(currentInput_measurable e i m)]
rw [Measure.map_map (rawCurrentProjection_measurable e)]
Β· congr 1
funext X
exact actualCurrentWindow_raw e t i m hi filler X
Β· exact (rawCurrentWindow_measurable e _ _ hi him filler).comp (currentInput_measurable e i m)
end DirectionalTransience
end
end OAI