File size: 4,726 Bytes
e63eb7f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | import OAI.Combinatorics.EditApproximation.Probability.AdaptiveSeedLaw
namespace OAI
/-! Adaptive passes need the correct marginal for the actual incoming
seed. Independence between unused, counterfactual seed-indexed draws is
unnecessary. This permits one common keyed random source. -/
namespace EditApproximation
open MeasureTheory ProbabilityTheory
section Marginal
variable {Seed : Type*} [Fintype Seed] [DecidableEq Seed]
[MeasurableSpace Seed] [MeasurableSingletonClass Seed]
{Draw : Seed → Type*} [∀ seed, Fintype (Draw seed)]
[∀ seed, MeasurableSpace (Draw seed)] [∀ seed, MeasurableSingletonClass (Draw seed)]
(drawLaw : ∀ seed, Measure (Draw seed)) [∀ seed, IsProbabilityMeasure (drawLaw seed)]
{Ω : Type*} [Fintype Ω] [MeasurableSpace Ω] [MeasurableSingletonClass Ω]
(randomLaw : Measure Ω) [IsProbabilityMeasure randomLaw]
(sample : ∀ seed, Ω → Draw seed)
(hmarginal : ∀ seed, randomLaw.map (sample seed) = drawLaw seed)
include hmarginal in
/-- The common random source can correlate draws for distinct hypothetical
incoming seeds; only its independence from the actual incoming seed matters. -/
theorem adaptiveSeedLaw_eq_of_marginals (incoming : Measure Seed) [IsProbabilityMeasure incoming]
(next : ∀ seed, Draw seed → Seed) :
(incoming.prod randomLaw).map
(fun pair : Seed × Ω => next pair.1 (sample pair.1 pair.2)) =
adaptiveSeedLaw drawLaw incoming next := by
classical
apply Measure.ext
intro event hevent
apply (measureReal_eq_measureReal_iff).mp
rw [adaptiveSeedLaw, map_measureReal_apply (measurable_of_finite _) hevent,
map_measureReal_apply (measurable_of_finite _) hevent]
change (incoming.prod randomLaw).real
{pair : Seed × Ω | next pair.1 (sample pair.1 pair.2) ∈ event} =
(incoming.prod (Measure.pi drawLaw)).real
{pair : Seed × (∀ seed, Draw seed) | next pair.1 (pair.2 pair.1) ∈ event}
rw [← finite_integral_test (incoming.prod randomLaw)
(fun pair : Seed × Ω => next pair.1 (sample pair.1 pair.2) ∈ event),
← finite_integral_test (incoming.prod (Measure.pi drawLaw))
(fun pair : Seed × (∀ seed, Draw seed) => next pair.1 (pair.2 pair.1) ∈ event)]
rw [integral_prod _ (.of_finite), integral_prod _ (.of_finite)]
apply integral_congr_ae
filter_upwards [] with seed
have hmap := integral_map (μ := randomLaw) (φ := sample seed)
(measurable_of_finite _).aemeasurable
(f := fun draw => if next seed draw ∈ event then (1 : ℝ) else 0)
(measurable_of_finite _).aestronglyMeasurable
rw [hmarginal seed] at hmap
rw [← hmap]
symm
exact integral_comp_eval (μ := drawLaw) (i := seed)
(f := fun draw => if next seed draw ∈ event then (1 : ℝ) else 0)
(measurable_of_finite _).aestronglyMeasurable
include hmarginal in
/-- The same replacement preserves the final integer answer law, rather
than only a seed transition. -/
theorem adaptiveAnswerLaw_eq_of_marginals (incoming : Measure Seed) [IsProbabilityMeasure incoming]
(answer : ∀ seed, Draw seed → ℕ) :
(incoming.prod randomLaw).map
(fun pair : Seed × Ω => answer pair.1 (sample pair.1 pair.2)) =
(incoming.prod (Measure.pi drawLaw)).map
(fun pair : Seed × (∀ seed, Draw seed) => answer pair.1 (pair.2 pair.1)) := by
classical
apply Measure.ext
intro event hevent
apply (measureReal_eq_measureReal_iff).mp
rw [map_measureReal_apply (measurable_of_finite _) hevent,
map_measureReal_apply (measurable_of_finite _) hevent]
change (incoming.prod randomLaw).real
{pair : Seed × Ω | answer pair.1 (sample pair.1 pair.2) ∈ event} =
(incoming.prod (Measure.pi drawLaw)).real
{pair : Seed × (∀ seed, Draw seed) | answer pair.1 (pair.2 pair.1) ∈ event}
rw [← finite_integral_test (incoming.prod randomLaw)
(fun pair : Seed × Ω => answer pair.1 (sample pair.1 pair.2) ∈ event),
← finite_integral_test (incoming.prod (Measure.pi drawLaw))
(fun pair : Seed × (∀ seed, Draw seed) => answer pair.1 (pair.2 pair.1) ∈ event)]
rw [integral_prod _ (.of_finite), integral_prod _ (.of_finite)]
apply integral_congr_ae
filter_upwards [] with seed
have hmap := integral_map (μ := randomLaw) (φ := sample seed)
(measurable_of_finite _).aemeasurable
(f := fun draw => if answer seed draw ∈ event then (1 : ℝ) else 0)
(measurable_of_finite _).aestronglyMeasurable
rw [hmarginal seed] at hmap
rw [← hmap]
symm
exact integral_comp_eval (μ := drawLaw) (i := seed)
(f := fun draw => if answer seed draw ∈ event then (1 : ℝ) else 0)
(measurable_of_finite _).aestronglyMeasurable
end Marginal
end EditApproximation
end OAI
|