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 target's latent-parent set isolates the parents whose values must be integrated out when evaluating the target mechanism in environment i of an invariant-prediction family over finite node and environment indices with measurable coordinate outcomes.
The target mechanism function reconstructs the target from observed-parent values chosen by a reference environment, latent-parent values and fixed interventions supplied by the active environment, and the shared mechanism of an invariant-prediction family. It applies to finite node and environment indices with measurable coordinate outcomes.
Definition (Lean source)
The fixed-parent-parameterized target mechanism separates the target's structural rule from the intervention assignment: it combines observed parents selected by a reference environment, latent parents from the active environment, and explicit values for the fixed parents in an invariant-prediction family. It applies to finite node and environment indices with measurable coordinate outcomes.
Definition (Lean source)
Conditioning a structural outcome on its predictors integrates out only the independent latent input. On source, predictor, latent, and outcome spaces with probability law μ, for predictors X, latent input L, outcome Y, and mechanism Φ, this follows from measurability, independence of L and X, and the almost-sure structural equation.
Formal statement
Proof (Lean source)
The target's conditional law given its observed parents equals the structural-mechanism kernel: in environment i, latent-parent uncertainty is pushed through the target mechanism while observed parents are indexed using reference environment i₀ of family F, over finite nodes, finite environments, and measurable coordinate outcomes.
Formal statement
Proof (Lean source)
The target-mechanism kernel is environment-independent once fixed-parent assignments are transported, which is the structural basis for ICP invariance. In family F, this compares base environment i₀ and environments i,j at fixed-parent values cf, assuming the latent parents in each environment are random. The setup has finite nodes, finite environments, and measurable coordinate outcomes.
Formal statement
Proof (Lean source)
15 supporting declarations (lemmas, instances)
-
paLat_eqtheorem — The latent-parent set is environment-independent.hypothesesN :sharedType u_1N → Type u_2ι :sharedType u_3F :EnvFamily N Ω ιi j :ιconclusionF.paLat i = F.paLat j -
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.hypothesesN :sharedType u_1N → Type u_2M :SCM N Ωs :M.FixedValueshSobs :S ⊆ M.observedhSrv :S ⊆ M.randomVarsconclusion(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.hypothesesN :sharedType u_1N → Type u_2ι :sharedType u_3F :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 — Explicitly supplying fixed-parent values preserves measurability of the target mechanism, so it can be pushed forward to form a kernel for family F, reference environment i₀, and active environment i over finite nodes, environments, and measurable coordinate outcomes.hypothesesN :sharedType u_1N → Type u_2ι :sharedType u_3F :EnvFamily N Ω ιi₀ i :ιconclusionMeasurable (F.mechanismFunCf i₀ i cf)Proof (Lean source)
@[fun_prop] 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 — The intervention-indexed target mechanism remains measurable as a function of the observed and latent parents, including when their observed coordinates are selected by reference environment i₀, over finite nodes, finite environments, and measurable coordinate outcomes.hypothesesN :sharedType u_1N → Type u_2ι :sharedType u_3F :EnvFamily N Ω ιi₀ i :ιconclusionMeasurable (F.mechanismFun i₀ i)Proof (Lean source)
@[fun_prop] 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.hypothesesN :sharedType u_1N → Type u_2ι :sharedType u_3F :EnvFamily N Ω ιi₀ i :ιℓ :(F.M i).LatentValuesconclusionvaluesProjection (show ({F.yNode} : Finset (SWIGNode N)) ⊆ (F.M i).randomVars from by intro w hw rw [Finset.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 [Finset.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.hypothesesN :sharedType u_1N → Type u_2ι :sharedType u_3F :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.hypothesesN :sharedType u_1N → Type u_2ι :sharedType u_3F :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.hypothesesN :sharedType u_1N → Type u_2ι :sharedType u_3F :EnvFamily N Ω ιi j :ιconclusionProof (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.hypothesesN :sharedType u_1N → Type u_2ι :sharedType u_3F :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