Skip to content

Commit feff0e0

Browse files
committed
better extend_space: remove the old space
1 parent db6a226 commit feff0e0

4 files changed

Lines changed: 960 additions & 343 deletions

File tree

‎RandomDo/Probability/AlgTrace.lean‎

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ open MeasureTheory ProbabilityTheory Finset Learning
5959
noncomputable section
6060

6161
/-- An algorithm-environment sequence pulls back along a measure-preserving map. With
62-
`extend_space`, this lets one add independent randomness to a space carrying such a sequence. -/
62+
`extend_space`, this lets one add independent randomness to a space carrying such a sequence: as
63+
a `@[transfer_forward]` lemma, it is how the hypothesis is transported to the extended space. -/
64+
@[transfer_forward]
6365
lemma _root_.Learning.IsAlgEnvSeq.comp_measurePreserving {𝓐 𝓨 Ω Ω' : Type*} [MeasurableSpace 𝓐]
6466
[MeasurableSpace 𝓨] {_ : MeasurableSpace Ω} {_ : MeasurableSpace Ω'} {P : Measure Ω}
6567
[IsFiniteMeasure P] {P' : Measure Ω'} [IsFiniteMeasure P'] {A : ℕ → Ω → 𝓐} {Y : ℕ → Ω → 𝓨}
@@ -577,32 +579,37 @@ example (env : Environment (Fin K) ℝ) {Ω₀ : Type} [MeasurableSpace Ω₀] {
577579
Measure.map_map (by fun_prop)
578580
(measurable_trajectory h₂.measurable_action h₂.measurable_feedback), ← e₂, h₀]
579581

580-
/-- **`extend_space` alongside an algorithm-environment sequence.** The sequence pulls back along
581-
the projection `f` by `IsAlgEnvSeq.comp_measurePreserving`, and the larger space also carries a
582-
Gaussian `U` independent of the whole trajectory. The statement does not mention the original
583-
space, so the `transfer` obligation is trivial and `extend_space` closes it. -/
582+
/-- **`extend_space` alongside an algorithm-environment sequence.** After the extension, `Ω`, `P`,
583+
`A` and `Y` live on a larger space that also carries a Gaussian `U` independent of the whole
584+
trajectory, and `h` has been transported by `IsAlgEnvSeq.comp_measurePreserving`. The statement
585+
does not mention the original space, so the `transfer` obligation is trivial and `extend_space`
586+
closes it. The measurability of the sequence is put in the context first, so that the
587+
independence statement `hind` covers `A` and `Y`. -/
584588
example (env : Environment (Fin K) ℝ) {Ω₀ : Type} [MeasurableSpace Ω₀] {P : Measure Ω₀}
585589
[IsProbabilityMeasure P] {A : ℕ → Ω₀ → Fin K} {Y : ℕ → Ω₀ → ℝ}
586590
(h : IsAlgEnvSeq A Y (alg hK) env P) :
587591
∃ (Ω' : Type) (_ : MeasurableSpace Ω') (P' : Measure Ω') (_ : IsProbabilityMeasure P')
588592
(A' : ℕ → Ω' → Fin K) (Y' : ℕ → Ω' → ℝ) (U : Ω' → ℝ),
589593
IsAlgEnvSeq A' Y' (alg hK) env P' ∧ HasLaw U (gaussianReal 0 1) P'
590594
∧ IndepFun (trajectory A' Y') U P' := by
591-
extend_space (gaussianReal 0 1) using P with Ω' P' f hf U hU hind
592-
exact ⟨Ω', inferInstance, P', inferInstance, fun n ω ↦ A n (f ω), fun n ω ↦ Y n (f ω), U,
593-
h.comp_measurePreserving hf, hU,
594-
hind.comp (measurable_trajectory h.measurable_action h.measurable_feedback) measurable_id⟩
595-
596-
/-- **The `transfer` tactic with an algorithm-environment sequence.** The goal mentions the space
597-
through `P` and `A 0`; `transfer` moves it to the new space, with the measurability of the
598-
sequence taken from `h`. In the extended goal, `transfer hf at h` pulls the sequence back. -/
595+
have hA := h.measurable_action
596+
have hY := h.measurable_feedback
597+
extend_space! (gaussianReal 0 1) using P with U hU hind
598+
have hAY : IndepFun (trajectory A Y) U P :=
599+
hind.comp (φ := fun (p : (ℕ → Fin K) × (ℕ → ℝ)) (n : ℕ) ↦ (p.1 n, p.2 n)) (by fun_prop)
600+
measurable_id
601+
exact ⟨Ω₀, inferInstance, P, inferInstance, A, Y, U, h, hU, hAY⟩
602+
603+
/-- **The explicit form, `extend_space_map`.** The goal mentions the space through `P` and `A 0`;
604+
`transfer` moves it to the new space, with the measurability of the sequence taken from `h`. In
605+
the extended goal, `transfer hf at h` pulls the sequence back. -/
599606
example (env : Environment (Fin K) ℝ) {Ω₀ : Type} [MeasurableSpace Ω₀] {P : Measure Ω₀}
600607
[IsProbabilityMeasure P] {A : ℕ → Ω₀ → Fin K} {Y : ℕ → Ω₀ → ℝ}
601608
(h : IsAlgEnvSeq A Y (alg hK) env P) :
602609
P.map (A 0) = Measure.dirac ⟨0, hK⟩ := by
603610
have hA := h.measurable_action
604611
have hY := h.measurable_feedback
605-
extend_space (gaussianReal 0 1) with Ω' P' f hf U hU hind
612+
extend_space_map (gaussianReal 0 1) with Ω' P' f hf U hU hind
606613
transfer hf at h
607614
exact h.hasLaw_action_zero.map_eq
608615

0 commit comments

Comments
 (0)