Discovery.InvariantPrediction.Helpers
Measure-theoretic and structural helper lemmas for invariant prediction, especially target-mechanism factorization and environment-invariance arguments.
MechanismFactor 6 core · 15 supporting This file isolates the measure-theoretic and structural helper facts used by EnvFamily.mechanism_invariant: the target mechanism factors through its observed parents, latent parents, and an explicit fixed-parent value ar ★ condDistrib_eq_mechanismKernel_of_indep★ condDistrib_target_eq_mechanismKernel★ mechanismKernel_cf_env_eq
Mechanism-factor helpers for invariant prediction
This file isolates the measure-theoretic and structural helper facts used by
EnvFamily.mechanism_invariant: the target mechanism factors through its observed
parents, latent parents, and an explicit fixed-parent value argument. This
parameterized fixed-parent kernel supports comparing environments without requiring
their fixed-parent assignments to agree.
The main ingredients are:
* paLat and paLat_eq, the latent parents of the target and their
environment-independence;
* mechanismFun and mechanismFunCf, the target structural function as a map of
observed, latent, and fixed parent values;
* condDistrib_eq_mechanismKernel_of_indep, the abstract conditional-law
factorization under independence of latent noise and predictors;
* condDistrib_target_eq_mechanismKernel, the per-environment specialization to
the target conditional law; and
* mechanismKernel_cf_env_eq, the cross-environment equality of the
fixed-parent-parameterized mechanism kernels.
The latent parents of the target in environment i.
The target mechanism as a measurable map of observed and latent parents.
Definition (Lean source)
The target mechanism as a measurable map of observed and latent parents, parameterized by an explicit fixed-parent value argument cf. Identical to mechanismFun i₀ i except that the fixed-parent branch reads its value from cf instead of from the environment's intervention assignment s i. This lets the mechanism factor be keyed on paFix-values (used by the redesigned Invariant witness κ), so cross-environment agreement no longer needs the environments to assign the same value to a fixed parent.
Definition (Lean source)
Let , , and be measurable random elements of a probability space, with 's value space standard Borel and nonempty, and let be a measurable map such that equals almost everywhere. If is independent of , then the conditional distribution of given agrees, for almost every pushed-forward value of , with the mechanism kernel obtained by pushing the law of forward through paired with that value of .
Formal statement
Proof (Lean source)
For an invariant-prediction environment family and a reference index i₀ together with an environment i, in environment i the conditional law of the target given its observed parents, under the joint kernel restricted to that environment, agrees with the mechanism kernel formed by pushing the latent-parent law of environment i forward through the target's structural mechanism function, paired with the parent value.
Formal statement
Proof (Lean source)
Fix an environment family, a base environment i₀, two environments i and j, and a fixed-parent value assignment cf for environment i. If the latent parents of the target in environment i are among its random variables and likewise for environment j, then the target-mechanism kernel built from environment i at cf equals the target-mechanism kernel built from environment j at the value obtained by transporting cf through the shared fixed-parent set.
Formal statement
Proof (Lean source)
15 supporting declarations (lemmas, instances)
-
valuesProjection_randomToObserved_eqtheorem — Observed-coordinate projection after randomToObserved is the same as the corresponding random-coordinate projection.hypotheses -
obsKernel_map_valuesProjection_eq_jointKernel_maptheorem — The observed marginal of obsKernel is the corresponding random marginal of jointKernel.hypothesesconclusion(M.obsKernel s).map (valuesProjection hSobs)= (M.jointKernel s).map (valuesProjection hSrv)Proof (Lean source)
theorem obsKernel_map_valuesProjection_eq_jointKernel_map (M : SCM N Ω) (s : M.FixedValues) (S : Finset (SWIGNode N)) (hSobs : S ⊆ M.observed) (hSrv : S ⊆ M.randomVars) : (M.obsKernel s).map (valuesProjection hSobs) = (M.jointKernel s).map (valuesProjection hSrv) := by have hcomp := valuesProjection_randomToObserved_eq M S hSobs hSrv unfold SCM.obsKernel rw [ProbabilityTheory.Kernel.map_apply _ M.measurable_randomToObserved] rw [MeasureTheory.Measure.map_map (measurable_valuesProjection hSobs) M.measurable_randomToObserved] rw [hcomp] -
mechanismFunCf_fixedParentValstheorem — At the environment's own fixed-parent values fixedParentVals i, the parameterized mechanism mechanismFunCf coincides with the version that reads fixed-parent values from the environment assignment.hypothesesF :EnvFamily N Ω ιi₀ i :ιconclusionF.mechanismFunCf i₀ i (F.fixedParentVals i) = F.mechanismFun i₀ iProof (Lean source)
theorem mechanismFunCf_fixedParentVals (F : EnvFamily N Ω ι) (i₀ i : ι) : F.mechanismFunCf i₀ i (F.fixedParentVals i) = F.mechanismFun i₀ i := by rfl -
measurable_mechanismFunCftheorem — mechanismFunCf is measurable.hypothesesconclusionMeasurable (F.mechanismFunCf i₀ i cf)Proof (Lean source)
theorem measurable_mechanismFunCf (F : EnvFamily N Ω ι) (i₀ i : ι) (cf : ValuesOn (F.paFix i) (swigΩ Ω)) : Measurable (F.mechanismFunCf i₀ i cf) := by classical refine measurable_pi_lambda _ ?_ rintro ⟨w, hw⟩ have hwy : w = F.yNode := Finset.mem_singleton.mp hw subst hwy apply ((F.M i).structFun_measurable ⟨F.yNode, F.hYobs i⟩).comp exact measurable_pi_lambda _ (fun d => by by_cases hlat : d.val ∈ (F.M i).unobserved · simp only [dif_pos hlat] exact (measurable_pi_apply _).comp measurable_snd · simp only [dif_neg hlat] by_cases hfix : d.val ∈ (F.M i).fixed · simp only [dif_pos hfix] exact measurable_const · simp only [dif_neg hfix] exact (measurable_pi_apply _).comp measurable_fst) -
measurable_mechanismFuntheorem — mechanismFun is measurable.Proof (Lean source)
theorem measurable_mechanismFun (F : EnvFamily N Ω ι) (i₀ i : ι) : Measurable (F.mechanismFun i₀ i) := by classical refine measurable_pi_lambda _ ?_ rintro ⟨w, hw⟩ have hwy : w = F.yNode := Finset.mem_singleton.mp hw subst hwy apply ((F.M i).structFun_measurable ⟨F.yNode, F.hYobs i⟩).comp exact measurable_pi_lambda _ (fun d => by by_cases hlat : d.val ∈ (F.M i).unobserved · simp only [dif_pos hlat] exact (measurable_pi_apply _).comp measurable_snd · simp only [dif_neg hlat] by_cases hfix : d.val ∈ (F.M i).fixed · simp only [dif_pos hfix] exact measurable_const · simp only [dif_neg hfix] exact (measurable_pi_apply _).comp measurable_fst) -
target_projection_evalMap_eq_mechanismFuntheorem — Pointwise structural equation for the target, expressed through mechanismFun on observed and latent parents.hypothesesconclusionvaluesProjection (show ({F.yNode} : Finset (SWIGNode N)) ⊆ (F.M i).randomVars from by intro w hw rw [mem_singleton] at hw subst hw exact mem_union_left _ (F.hYobs i)) ((F.M i).evalMap (F.s i) ℓ)= F.mechanismFun i₀ i (valuesProjection (show F.paObs i₀ ⊆ (F.M i).randomVars from by rw [F.paObs_eq i₀ i] exact (inter_subset_right).trans (by change (F.M i).observed ⊆ (F.M i).observed ∪ (F.M i).unobserved exact subset_union_left)) ((F.M i).evalMap (F.s i) ℓ), valuesProjection (show F.paLat i ⊆ (F.M i).randomVars from by exact (inter_subset_right).trans (by change (F.M i).unobserved ⊆ (F.M i).observed ∪ (F.M i).unobserved exact subset_union_right)) ((F.M i).evalMap (F.s i) ℓ))Proof (Lean source)
theorem target_projection_evalMap_eq_mechanismFun (F : EnvFamily N Ω ι) (i₀ i : ι) (ℓ : (F.M i).LatentValues) : valuesProjection (show ({F.yNode} : Finset (SWIGNode N)) ⊆ (F.M i).randomVars from by intro w hw rw [mem_singleton] at hw subst hw exact mem_union_left _ (F.hYobs i)) ((F.M i).evalMap (F.s i) ℓ) = F.mechanismFun i₀ i (valuesProjection (show F.paObs i₀ ⊆ (F.M i).randomVars from by rw [F.paObs_eq i₀ i] exact (inter_subset_right).trans (by change (F.M i).observed ⊆ (F.M i).observed ∪ (F.M i).unobserved exact subset_union_left)) ((F.M i).evalMap (F.s i) ℓ), valuesProjection (show F.paLat i ⊆ (F.M i).randomVars from by exact (inter_subset_right).trans (by change (F.M i).unobserved ⊆ (F.M i).observed ∪ (F.M i).unobserved exact subset_union_right)) ((F.M i).evalMap (F.s i) ℓ)) := by funext w rcases w with ⟨w, hw⟩ have hwy : w = F.yNode := Finset.mem_singleton.mp hw subst hwy simp only [valuesProjection] change (F.M i).evalMap (F.s i) ℓ ⟨F.yNode, mem_union_left _ (F.hYobs i)⟩ = F.mechanismFun i₀ i (valuesProjection _ ((F.M i).evalMap (F.s i) ℓ), valuesProjection _ ((F.M i).evalMap (F.s i) ℓ)) ⟨F.yNode, hw⟩ rw [evalMap_observed_unfold (M := F.M i) (s := F.s i) (ℓ := ℓ) (v := ⟨F.yNode, F.hYobs i⟩)] unfold mechanismFun simp only congr 1 funext d by_cases hlat : d.val ∈ (F.M i).unobserved · simp only [dif_pos hlat, valuesProjection] rw [SCM.evalMap_unobserved] · simp only [dif_neg hlat] by_cases hfix : d.val ∈ (F.M i).fixed · simp only [dif_pos hfix] · simp only [dif_neg hfix, valuesProjection] -
jointKernel_map_paLat_eq_latentProduct_maptheorem — Projecting the joint kernel to latent parents is the same as projecting the latent product directly to those latent coordinates.hypothesesF :EnvFamily N Ω ιi :ιhLrv :F.paLat i ⊆ (F.M i).randomVarshLun :F.paLat i ⊆ (F.M i).unobservedconclusion= (F.M i).latentProduct.map (valuesProjection hLun)Proof (Lean source)
theorem jointKernel_map_paLat_eq_latentProduct_map (F : EnvFamily N Ω ι) (i : ι) (hLrv : F.paLat i ⊆ (F.M i).randomVars) (hLun : F.paLat i ⊆ (F.M i).unobserved) : ((F.M i).jointKernel (F.s i)).map (valuesProjection hLrv) = (F.M i).latentProduct.map (valuesProjection hLun) := by have hEvalMeas : Measurable (fun ℓ : (F.M i).LatentValues => (F.M i).evalMap (F.s i) ℓ) := by have : (fun ℓ : (F.M i).LatentValues => (F.M i).evalMap (F.s i) ℓ) = fun ℓ => uncurry (F.M i).evalMap (F.s i, ℓ) := rfl rw [this] exact (F.M i).evalMap_measurable.comp (prodMk measurable_const measurable_id) rw [SCM.jointKernel_apply_eq] rw [Measure.map_map (measurable_valuesProjection hLrv) hEvalMeas] congr 1 funext ℓ x simp only [Function.comp_apply, valuesProjection] rw [SCM.evalMap_unobserved] -
map_heq_transporttheorem — Transport a push-forward μ.map g across a propositional equality of the source type together with HEq of the measurable structure, the measure, and the map. Used to identify latent-parent push-forwards across environments whose latent index sets coincide propositionally (via hUnobs) but whose latentDist families and value-space typing match only up to HEq.hypothesesconclusionμ₁.map g₁ = μ₂.map g₂Proof (Lean source)
theorem map_heq_transport {α₁ α₂ δ : Type u} [mα₁ : MeasurableSpace α₁] [mα₂ : MeasurableSpace α₂] [MeasurableSpace δ] {μ₁ : Measure α₁} {μ₂ : Measure α₂} {g₁ : α₁ → δ} {g₂ : α₂ → δ} (hα : α₁ = α₂) (hm : HEq mα₁ mα₂) (hμ : HEq μ₁ μ₂) (hg : HEq g₁ g₂) : μ₁.map g₁ = μ₂.map g₂ := by subst hα; subst hm; rw [eq_of_heq hμ, eq_of_heq hg] -
valuesOn_measurableSpace_heqtheorem — ValuesOn measurable spaces transport heterogeneously across equality of the finite index sets.hypothesesconclusionHEq (inferInstance : MeasurableSpace (ValuesOn I Ω')) (inferInstance : MeasurableSpace (ValuesOn J Ω'))Proof (Lean source)
theorem valuesOn_measurableSpace_heq {M : Type*} [Fintype M] {Ω' : M → Type*} [∀ n, MeasurableSpace (Ω' n)] {I J : Finset M} (h : I = J) : HEq (inferInstance : MeasurableSpace (ValuesOn I Ω')) (inferInstance : MeasurableSpace (ValuesOn J Ω')) := by subst h rfl -
measure_pi_heqtheorem — Measure.pi transports heterogeneously across equality of the finite index sets and heterogeneous equality of the coordinate measure families.hypothesesconclusionHEq (Measure.pi μI) (Measure.pi μJ)Proof (Lean source)
theorem measure_pi_heq {M : Type*} {Ω' : M → Type*} [∀ n, MeasurableSpace (Ω' n)] {I J : Finset M} {μI : (i : {i // i ∈ I}) → Measure (Ω' i.val)} {μJ : (j : {j // j ∈ J}) → Measure (Ω' j.val)} (h : I = J) (hμ : HEq μI μJ) : HEq (Measure.pi μI) (Measure.pi μJ) := by subst h have hμeq : μI = μJ := eq_of_heq hμ subst hμeq rfl -
latentValues_measurableSpace_heqtheorem — Cross-environment measurable-space transport for latent value spaces.hypothesesF :EnvFamily N Ω ιi j :ιconclusionHEq (inferInstance : MeasurableSpace (F.M i).LatentValues) (inferInstance : MeasurableSpace (F.M j).LatentValues)Proof (Lean source)
theorem latentValues_measurableSpace_heq (F : EnvFamily N Ω ι) (i j : ι) : HEq (inferInstance : MeasurableSpace (F.M i).LatentValues) (inferInstance : MeasurableSpace (F.M j).LatentValues) := valuesOn_measurableSpace_heq (Ω' := swigΩ Ω) (F.hUnobs i j) -
latentProduct_heqtheorem — Cross-environment heterogeneous equality of latent product measures.Proof (Lean source)
theorem latentProduct_heq (F : EnvFamily N Ω ι) (i j : ι) : HEq (F.M i).latentProduct (F.M j).latentProduct := by unfold SCM.latentProduct exact measure_pi_heq (F.hUnobs i j) (F.hLatent i j) -
condDistrib_eq_mechanismKernel_of_indep_of_pair_maptheorem — Variant of condDistrib_eq_mechanismKernel_of_indep that takes equality of the joint (X,Y) push-forward measures directly. This avoids needing a MeasurableEq instance for the target when the equality is proved upstream by unfolding a map representation of μ.hypothesesα β γ δ :Type*Nonempty δμ :X :α → βL :α → γY :α → δΦ :β × γ → δhX :hL :hY :hΦ :hind :IndepFun L X μhpair :μ.map (fun ω => (X ω, Y ω)) = μ.map (fun ω => (X ω, Φ (X ω, L ω)))conclusion(fun x => condDistrib Y X μ x)=ᵐ[μ.map X] mechanismKernel (μ.map L) ΦProof (Lean source)
theorem condDistrib_eq_mechanismKernel_of_indep_of_pair_map {α β γ δ : Type*} [MeasurableSpace α] [MeasurableSpace β] [MeasurableSpace γ] [MeasurableSpace δ] [StandardBorelSpace δ] [Nonempty δ] (μ : Measure α) [IsProbabilityMeasure μ] {X : α → β} {L : α → γ} {Y : α → δ} {Φ : β × γ → δ} (hX : Measurable X) (hL : Measurable L) (hY : Measurable Y) (hΦ : Measurable Φ) (hind : IndepFun L X μ) (hpair : μ.map (fun ω => (X ω, Y ω)) = μ.map (fun ω => (X ω, Φ (X ω, L ω)))) : (fun x => condDistrib Y X μ x) =ᵐ[μ.map X] mechanismKernel (μ.map L) Φ := by classical haveI : IsFiniteMeasure μ := inferInstance haveI : IsProbabilityMeasure (μ.map L) := Measure.isProbabilityMeasure_map hL.aemeasurable haveI : IsMarkovKernel (mechanismKernel (μ.map L) Φ) := instIsMarkovKernelMechanismKernel (μ.map L) hΦ have hXL : Measurable (fun ω => (X ω, L ω)) := hX.prodMk hL have hgraph : Measurable (fun p : β × γ => (p.1, Φ p)) := measurable_fst.prodMk hΦ have hprod : μ.map (fun ω => (X ω, L ω)) = (μ.map X).prod (μ.map L) := (indepFun_iff_map_prod_eq_prod_map_map hX.aemeasurable hL.aemeasurable).mp hind.symm refine condDistrib_ae_eq_of_measure_eq_compProd X hY.aemeasurable ?_ calc μ.map (fun ω => (X ω, Y ω)) = μ.map (fun ω => (X ω, Φ (X ω, L ω))) := hpair _ = Measure.map (fun p : β × γ => (p.1, Φ p)) (μ.map (fun ω => (X ω, L ω))) := by rw [Measure.map_map hgraph hXL] rfl _ = Measure.map (fun p : β × γ => (p.1, Φ p)) ((μ.map X).prod (μ.map L)) := by rw [hprod] _ = (μ.map X).compProd (mechanismKernel (μ.map L) Φ) := map_graph_prod_eq_compProd (μ.map X) (μ.map L) hΦ -
structFun_yNode_apply_eqtheorem — Cross-environment equality of the target structural function applied to coordinatewise-equal target-parent tuples.hypothesesF :EnvFamily N Ω ιi j :hξ :∀ (d : SWIGNode N) (hdi : d ∈ (F.M i).dag.parents F.yNode) (hdj : d ∈ (F.M j).dag.parents F.yNode),ξi ⟨d, hdi⟩ = ξj ⟨d, hdj⟩conclusion(F.M i).structFun ⟨F.yNode, F.hYobs i⟩ ξi = (F.M j).structFun ⟨F.yNode, F.hYobs j⟩ ξjProof (Lean source)
theorem structFun_yNode_apply_eq (F : EnvFamily N Ω ι) (i j : ι) {ξi : (w : {w // w ∈ (F.M i).dag.parents F.yNode}) → swigΩ Ω w.val} {ξj : (w : {w // w ∈ (F.M j).dag.parents F.yNode}) → swigΩ Ω w.val} (hξ : ∀ (d : SWIGNode N) (hdi : d ∈ (F.M i).dag.parents F.yNode) (hdj : d ∈ (F.M j).dag.parents F.yNode), ξi ⟨d, hdi⟩ = ξj ⟨d, hdj⟩) : (F.M i).structFun ⟨F.yNode, F.hYobs i⟩ ξi = (F.M j).structFun ⟨F.yNode, F.hYobs j⟩ ξj := by have hParentsEq : (F.M i).dag.parents F.yNode = (F.M j).dag.parents F.yNode := F.hParents i j have hξHeq : HEq ξi ξj := by apply Function.hfunext (by rw [hParentsEq]) rintro ⟨di, hdi⟩ ⟨dj, hdj⟩ hdij have hval : di = dj := by exact (Subtype.heq_iff_coe_eq (by intro x; rw [hParentsEq])).mp hdij subst hval apply heq_of_eq exact hξ di hdi hdj exact congr_heq (F.hStruct i j) hξHeq