Download data/lean/OAI/Combinatorics/EditApproximation/Probability/AdaptiveMarginalLaw.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 4.73 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/EditApproximation/Probability/AdaptiveMarginalLaw.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Combinatorics/EditApproximation/Probability/AdaptiveMarginalLaw.lean
-
curl -L -o AdaptiveMarginalLaw.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/EditApproximation/Probability/AdaptiveMarginalLaw.lean
4.73 kB
| 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 | |