openAI-math-dataset / lean /OAI /Probability /FreeIsing /Spins /ObservationFusion.lean
roseking's picture
Add lean source and binary files (part 122)
b317718 verified
Raw History Blame Contribute Delete
6.41 kB
import OAI.Probability.FreeIsing.Spins.ObservationLaw
import OAI.Probability.FreeIsing.Spins.PosteriorCertification
import OAI.Probability.FreeIsing.Spins.PosteriorFusion
namespace OAI
noncomputable section
open MeasureTheory ProbabilityTheory
namespace Problem367
def observationFusionJointLaw {A B : Type*} [MeasurableSpace A] [MeasurableSpace B]
(mu : Measure A) (nu : Measure B) (q : A → ℝ) (r : B → ℝ) : Measure (A × B) :=
(mu.prod nu).withDensity (fun p => ENNReal.ofReal (1 + q p.1 * r p.2))
private theorem ae_observation_pair_bounds
{A B : Type*} [MeasurableSpace A] [MeasurableSpace B]
{mu : Measure A} {nu : Measure B} [IsProbabilityMeasure mu] [IsProbabilityMeasure nu]
{q : A → ℝ} {r : B → ℝ}
(hq : ∀ᵐ x ∂mu, |q x| < 1) (hr : ∀ᵐ y ∂nu, |r y| < 1) :
∀ᵐ p ∂mu.prod nu, |q p.1| < 1 ∧ |r p.2| < 1 := by
have hq' : ∀ᵐ p ∂mu.prod nu, |q p.1| < 1 :=
measurePreserving_fst.quasiMeasurePreserving.tendsto_ae hq
have hr' : ∀ᵐ p ∂mu.prod nu, |r p.2| < 1 :=
measurePreserving_snd.quasiMeasurePreserving.tendsto_ae hr
exact hq'.and hr'
theorem observationFusionJointLaw_eq_mixture
{A B : Type*} [MeasurableSpace A] [MeasurableSpace B]
{mu : Measure A} {nu : Measure B} [IsProbabilityMeasure mu] [IsProbabilityMeasure nu]
{q : A → ℝ} {r : B → ℝ} (hq : Measurable q) (hr : Measurable r)
(hqb : ∀ᵐ x ∂mu, |q x| < 1) (hrb : ∀ᵐ y ∂nu, |r y| < 1) :
(1 / 2 : ENNReal) • ((linearSignalTilt mu q 1).prod (linearSignalTilt nu r 1)) +
(1 / 2 : ENNReal) • ((linearSignalTilt mu q (-1)).prod (linearSignalTilt nu r (-1))) =
observationFusionJointLaw mu nu q r := by
unfold linearSignalTilt observationFusionJointLaw
simp only [one_mul, neg_one_mul, ← sub_eq_add_neg]
rw [prod_withDensity (by fun_prop) (by fun_prop),
prod_withDensity (by fun_prop) (by fun_prop),
← withDensity_smul (1 / 2) (by fun_prop),
← withDensity_smul (1 / 2) (by fun_prop),
← withDensity_add_left (by fun_prop)]
apply withDensity_congr_ae
filter_upwards [ae_observation_pair_bounds hqb hrb] with p hp
exact binaryFusion_density_eq_mixture hp.1 hp.2
theorem observationFusion_positive_product_eq_tilt
{A B : Type*} [MeasurableSpace A] [MeasurableSpace B]
{mu : Measure A} {nu : Measure B} [IsProbabilityMeasure mu] [IsProbabilityMeasure nu]
{q : A → ℝ} {r : B → ℝ} (hq : Measurable q) (hr : Measurable r)
(hqb : ∀ᵐ x ∂mu, |q x| < 1) (hrb : ∀ᵐ y ∂nu, |r y| < 1) :
(linearSignalTilt mu q 1).prod (linearSignalTilt nu r 1) =
linearSignalTilt (observationFusionJointLaw mu nu q r)
(fun p => binaryFusion (q p.1) (r p.2)) 1 := by
unfold linearSignalTilt observationFusionJointLaw
rw [prod_withDensity (by fun_prop) (by fun_prop),
← withDensity_mul _ (by fun_prop) (by unfold binaryFusion; fun_prop)]
apply withDensity_congr_ae
filter_upwards [ae_observation_pair_bounds hqb hrb] with p hp
simp only [one_mul, Pi.mul_apply]
have hpq : 0 ≤ 1 + q p.1 := by have := (abs_lt.mp hp.1).1; linarith
have hden := binaryFusion_denominator_pos hp.1 hp.2
rw [← ENNReal.ofReal_mul hpq, ← ENNReal.ofReal_mul hden.le]
congr 1
unfold binaryFusion
field_simp
ring
theorem condExp_spin_given_observation_pair_eq_binaryFusion
{Ω A B : Type*} {mΩ : MeasurableSpace Ω} {mA : MeasurableSpace A}
{mB : MeasurableSpace B} {rho : Measure Ω} [IsProbabilityMeasure rho]
{S : Ω → IsingSpin} (hS : Measurable S)
{X : Ω → A} {Y : Ω → B} (hX : Measurable X) (hY : Measurable Y)
{q : A → ℝ} {r : B → ℝ} (hq : Measurable q) (hr : Measurable r)
(hpostX : rho[fun x => spinSign (S x) | mA.comap X] =ᵐ[rho] fun x => q (X x))
(hpostY : rho[fun x => spinSign (S x) | mB.comap Y] =ᵐ[rho] fun x => r (Y x))
(hqb : ∀ᵐ x ∂rho, |q (X x)| < 1) (hrb : ∀ᵐ x ∂rho, |r (Y x)| < 1)
(hfair : ∀ a : IsingSpin, rho {x | S x = a} = (1 / 2 : ENNReal))
(hInd : ∀ a : IsingSpin, IndepFun X Y (cond rho {x | S x = a})) :
rho[fun x => spinSign (S x) |
(inferInstance : MeasurableSpace (A × B)).comap (fun x => (X x, Y x))] =ᵐ[rho]
fun x => binaryFusion (q (X x)) (r (Y x)) := by
let mu := Measure.map X rho
let nu := Measure.map Y rho
have hqm : ∀ᵐ x ∂mu, |q x| < 1 :=
(ae_map_iff hX.aemeasurable (measurableSet_lt hq.abs measurable_const)).2 hqb
have hrm : ∀ᵐ y ∂nu, |r y| < 1 :=
(ae_map_iff hY.aemeasurable (measurableSet_lt hr.abs measurable_const)).2 hrb
have hpair (a : IsingSpin) : Measure.map (fun x => (X x, Y x)) (cond rho {x | S x = a}) =
(linearSignalTilt mu q (spinSign a)).prod (linearSignalTilt nu r (spinSign a)) := by
let : IsProbabilityMeasure (cond rho {x | S x = a}) :=
cond_isProbabilityMeasure (by rw [hfair]; norm_num)
rw [(hInd a).map_prod_eq_prod_map_map hX.aemeasurable hY.aemeasurable,
map_cond_spin_observation_eq_linearSignalTilt hS hX hq hpostX a (hfair a),
map_cond_spin_observation_eq_linearSignalTilt hS hY hr hpostY a (hfair a)]
have hjoint : Measure.map (fun x => (X x, Y x)) rho =
observationFusionJointLaw mu nu q r := by
calc
_ = Measure.map (fun x => (X x, Y x))
((1 / 2 : ENNReal) • cond rho {x | S x = .pos} +
(1 / 2 : ENNReal) • cond rho {x | S x = .neg}) := by
rw [← measure_eq_fair_spin_mixture hS hfair]
_ = _ := by
rw [Measure.map_add _ _ (hX.prodMk hY),
Measure.map_smul _ (hX.prodMk hY).aemeasurable,
Measure.map_smul _ (hX.prodMk hY).aemeasurable,
hpair .pos, hpair .neg]
exact observationFusionJointLaw_eq_mixture hq hr hqm hrm
apply condExp_spin_eq_of_conditional_linearTilt hS (hX.prodMk hY)
(show Measurable (fun p : A × B => binaryFusion (q p.1) (r p.2)) by
unfold binaryFusion
fun_prop)
· rw [hjoint]
have hb : ∀ᵐ p ∂observationFusionJointLaw mu nu q r, |q p.1| < 1 ∧ |r p.2| < 1 :=
(withDensity_absolutelyContinuous (mu.prod nu)
(fun p => ENNReal.ofReal (1 + q p.1 * r p.2))).ae_le
(ae_observation_pair_bounds hqm hrm)
filter_upwards [hb] with p hp
exact (abs_binaryFusion_lt_one hp.1 hp.2).le
· exact hfair .pos
· rw [hpair .pos, hjoint]
exact observationFusion_positive_product_eq_tilt hq hr hqm hrm
end Problem367
end
end OAI