Graph.Finite­Density.Positive

Strictly positive finite-DAG mechanisms: conditional local laws, edgewise causal-minimality characterizations, stable nonzero local contrasts, and finite-state examples.

Basic 6 core · 1 supporting This module defines compact positive finite-DAG product-density mechanisms and proves the conditional-law formula identifying a node's normalized local factor as its law conditional on its parents. ★ lintegral_node_given_parents

Positive compact-domain DAG product densities: foundations

This module defines compact positive finite-DAG product-density mechanisms and proves the conditional-law formula identifying a node's normalized local factor as its law conditional on its parents. The edge characterization and stable witnesses are in the companion modules.

theorem lintegral_node_given_parents reviewed
Causalean.Graph.FiniteDensity.Factorization

A normalized finite-DAG density factorization, node, parent-coordinate test, node-value test, and measurability of those two tests ensure that integrating their product under the observational law equals integrating the parent test against the node's local conditional density.

Formal statement
V :
Type uV
V → Type uX
(i : V) → Measure (X i)
DAG V
shared
B :
i :
V
h :
(∀ k : G.parents i, X k) → ℝ≥0∞
g :
X i → ℝ≥0∞
hh :
hg :
(∫⁻ x, h (coordinateProjection (X := X) (G.parents i) x) * g (x i) ∂B.observationalMeasure)
= ∫⁻ x, h (coordinateProjection (X := X) (G.parents i) x) * (∫⁻ z, g z * B.factor i (update x i z) ∂μ i) ∂B.observationalMeasure
Proof (Lean source)
theorem Factorization.lintegral_node_given_parents (B : Factorization G X μ) (i : V) (h : (∀ k : G.parents i, X k) → ℝ≥0∞) (g : X i → ℝ≥0∞) (hh : Measurable h) (hg : Measurable g) : (∫⁻ x, h (coordinateProjection (X := X) (G.parents i) x) * g (x i) ∂B.observationalMeasure) = ∫⁻ x, h (coordinateProjection (X := X) (G.parents i) x) * (∫⁻ z, g z * B.factor i (update x i z) ∂μ i) ∂B.observationalMeasure := by /- Use the existing reverse-topological elimination identities to compute the joint marginal of `i ∪ parents i`, then apply Tonelli twice and `B.normalized_factor`. -/ classical let τ := canonicalTopologicalRanking G let P := predecessors τ i let A := insert i P let T := univ \ A let q₁ : (∀ k, X k) → ℝ≥0∞ := fun x ↦ h (coordinateProjection (X := X) (G.parents i) x) * g (x i) let r : (∀ k, X k) → ℝ≥0∞ := fun x ↦ ∫⁻ z, g z * B.factor i (update x i z) ∂μ i let q₂ : (∀ k, X k) → ℝ≥0∞ := fun x ↦ h (coordinateProjection (X := X) (G.parents i) x) * r x have hparentsP : G.parents i ⊆ P := parents_subset_predecessors τ i have hiParents : i ∉ G.parents i := by simpa [mem_parents] using G.irrefl i have hAclosed : ParentClosed G A := by intro j hj k hk rcases Finset.mem_insert.mp hj with rfl | hjP · exact mem_insert_of_mem (hparentsP hk) · exact mem_insert_of_mem (parentClosed_predecessors τ i hjP hk) have hiP : i ∉ P := not_mem_predecessors τ i have hleaf : IsLeafIn G i A := by refine ⟨Finset.mem_insert_self i P, ?_⟩ intro j hj hji hij have hjP : j ∈ P := (Finset.mem_insert.mp hj).resolve_left hji have hjlt : τ.rank j < τ.rank i := by simpa [P, predecessors] using hjP exact (not_lt_of_ge (le_of_lt hjlt)) (τ.edge_lt hij) have hq₁ : Measurable q₁ := by unfold q₁ fun_prop have hr : Measurable r := by unfold r apply Measurable.lintegral_prod_right exact (hg.comp measurable_snd).mul ((B.measurable_factor i).comp measurable_update') have hq₂ : Measurable q₂ := by unfold q₂ fun_prop have hq₁_dep : DependsOn A q₁ := by intro x y hxy unfold q₁ congr 1 · congr 1 funext k exact hxy k (mem_insert_of_mem (hparentsP k.property)) · exact congrArg g (hxy i (mem_insert_self i P)) have hr_dep : DependsOn A r := by intro x y hxy unfold r apply lintegral_congr intro z congr 1 apply B.local_factor i intro k hk rcases Finset.mem_insert.mp hk with rfl | hk · simp · have hki : k ≠ i := fun hki ↦ hiParents (by simpa [hki] using hk) rw [Function.update_of_ne hki, Function.update_of_ne hki] exact hxy k (mem_insert_of_mem (hparentsP hk)) have hq₂_dep : DependsOn A q₂ := by intro x y hxy unfold q₂ congr 1 · congr 1 funext k exact hxy k (mem_insert_of_mem (hparentsP k.property)) · exact hr_dep hxy have hmarginal_mul (q : (∀ k, X k) → ℝ≥0∞) (hq : Measurable q) (hq_dep : DependsOn A q) : (∫⋯∫⁻_T, fun x ↦ B.observationalDensity x * q x ∂μ) = fun x ↦ B.partialDensity A x * q x := by funext x simp only [lmarginal] calc (∫⁻ y, B.observationalDensity (Function.updateFinset x T y) * q (Function.updateFinset x T y) ∂Measure.pi fun j : T ↦ μ j) = ∫⁻ y, B.observationalDensity (Function.updateFinset x T y) * q x ∂Measure.pi fun j : T ↦ μ j := by apply lintegral_congr intro y rw [hq_dep (fun k hk ↦ by simp only [Function.updateFinset] rw [dif_neg] simpa [T] using hk)] _ = (∫⁻ y, B.observationalDensity (Function.updateFinset x T y) ∂Measure.pi fun j : T ↦ μ j) * q x := by rw [lintegral_mul_const] exact B.measurable_observationalDensity.comp measurable_updateFinset _ = B.partialDensity A x * q x := by rw [show (∫⁻ y, B.observationalDensity (Function.updateFinset x T y) ∂Measure.pi fun j : T ↦ μ j) = (∫⋯∫⁻_T, B.observationalDensity ∂μ) x by rfl] exact congrArg (· * q x) (congrFun (B.lmarginal_compl_observationalDensity_eq hAclosed) x) have hsingle : (∫⋯∫⁻_{i}, fun x ↦ B.partialDensity A x * q₁ x ∂μ) = (∫⋯∫⁻_{i}, fun x ↦ B.partialDensity A x * q₂ x ∂μ) := by rw [MeasureTheory.lmarginal_singleton, MeasureTheory.lmarginal_singleton] funext x unfold q₁ q₂ r simp only [Function.update_self] calc (∫⁻ z, B.partialDensity A (update x i z) * (h (fun k ↦ update x i z k) * g z) ∂μ i) = B.partialDensity (A.erase i) x * h (coordinateProjection (X := X) (G.parents i) x) * (∫⁻ z, g z * B.factor i (update x i z) ∂μ i) := by simp_rw [show ∀ z, B.partialDensity A (update x i z) = B.factor i (update x i z) * B.partialDensity (A.erase i) x by intro z calc B.partialDensity A (update x i z) = B.factor i (update x i z) * B.partialDensity (A.erase i) (update x i z) := by unfold Factorization.partialDensity exact (Finset.mul_prod_erase A (fun j ↦ B.factor j (update x i z)) hleaf.1).symm _ = _ := by rw [B.partialDensity_erase_update_leaf hleaf]] simp_rw [show ∀ (z : X i), h (fun k : G.parents i ↦ update x i z k) = h (coordinateProjection (X := X) (G.parents i) x) by intro z congr 1 funext k exact Function.update_of_ne (fun hki ↦ hiParents (by simpa [hki] using k.property)) _ _] rw [← lintegral_const_mul] · congr 1 funext z simp only [mul_assoc, mul_left_comm, mul_comm] · exact hg.mul ((B.measurable_factor i).comp (measurable_update x)) _ = ∫⁻ z, B.partialDensity A (update x i z) * (h (fun k ↦ update x i z k) * ∫⁻ w, g w * B.factor i (update (update x i z) i w) ∂μ i) ∂μ i := by simp_rw [Function.update_idem] simp_rw [show ∀ (z : X i), h (fun k : G.parents i ↦ update x i z k) = h (coordinateProjection (X := X) (G.parents i) x) by intro z congr 1 funext k exact Function.update_of_ne (fun hki ↦ hiParents (by simpa [hki] using k.property)) _ _] rw [lintegral_mul_const] · rw [B.lintegral_partialDensity_leaf hleaf x] simp only [mul_assoc, mul_left_comm, mul_comm] · exact (B.measurable_partialDensity A).comp (measurable_update x) have hweighted : ∫⁻ x, B.observationalDensity x * q₁ x ∂Measure.pi μ = ∫⁻ x, B.observationalDensity x * q₂ x ∂Measure.pi μ := by apply MeasureTheory.lintegral_eq_of_lmarginal_eq (T ∪ {i}) (B.measurable_observationalDensity.mul hq₁) (B.measurable_observationalDensity.mul hq₂) rw [MeasureTheory.lmarginal_union' μ _ (B.measurable_observationalDensity.mul hq₁) (Finset.disjoint_singleton_right.mpr (by simp [T, A])), MeasureTheory.lmarginal_union' μ _ (B.measurable_observationalDensity.mul hq₂) (Finset.disjoint_singleton_right.mpr (by simp [T, A]))] change (∫⋯∫⁻_{i}, ∫⋯∫⁻_T, (fun x ↦ B.observationalDensity x * q₁ x) ∂μ ∂μ) = (∫⋯∫⁻_{i}, ∫⋯∫⁻_T, (fun x ↦ B.observationalDensity x * q₂ x) ∂μ ∂μ) rw [hmarginal_mul q₁ hq₁ hq₁_dep, hmarginal_mul q₂ hq₂ hq₂_dep] exact hsingle change (∫⁻ x, q₁ x ∂B.observationalMeasure) = ∫⁻ x, q₂ x ∂B.observationalMeasure rw [Factorization.observationalMeasure, lintegral_withDensity_eq_lintegral_mul _ B.measurable_observationalDensity hq₁, lintegral_withDensity_eq_lintegral_mul _ B.measurable_observationalDensity hq₂] exact hweighted
Causalean.Graph.FiniteDensity.Factorization.lintegral_node_given_parents · Causalean/Graph/FiniteDensity/Positive/Basic.lean:32 · uses DAG , parents , Factorization , observationalMeasure , coordinateProjection
structure CompactPositiveFactorization reviewed
Causalean.Graph.FiniteDensity

A positive DAG density is a normalized parent-local factorization whose local densities are finite and continuous and all share one explicit strictly positive lower bound. The structure itself does not require the coordinate spaces to be compact; the results about it in this and the companion modules assume compact, nonempty, standard Borel coordinate spaces with open-positive reference measures.

Definition (Lean source)
G :
DAG V
X :
V → Type uX
∀ i, MeasurableSpace (X i)
∀ i, TopologicalSpace (X i)
μ :
∀ i, Measure (X i)
∀ i, SigmaFinite (μ i)
The underlying normalized measurable parent-local DAG factorization.
toFactorization :
The common pointwise lower bound for every local density.
lower :
The common lower bound is strictly positive.
lower_pos :
0 < lower
Every extended-nonnegative local density is finite at every point.
factor_ne_top :
∀ i x, toFactorization.factor i x ≠ ∞
The real value of each local density is continuous on the compact product domain.
factor_continuous :
∀ i, Continuous (fun x : ∀ k, X k ↦ (toFactorization.factor i x).toReal)
Every local density is bounded below by the displayed common positive margin.
lower_le_factor :
∀ i x, lower ≤ (toFactorization.factor i x).toReal
Causalean.Graph.FiniteDensity.CompactPositiveFactorization · Causalean/Graph/FiniteDensity/Positive/Basic.lean:225 · uses DAG
abbrev observationalMeasure reviewed
Causalean.Graph.FiniteDensity.CompactPositiveFactorization

The observational law of a compact positive factorization is the product reference measure weighted by the product of its local densities.

Definition (Lean source)
V :
Type uV
V → Type uX
(i : V) → Measure (X i)
DAG V
shared
M :
shared
observationalMeasure M :
Measure (∀ i, X i)
M.toFactorization.observationalMeasure
Causalean.Graph.FiniteDensity.CompactPositiveFactorization.observationalMeasure · Causalean/Graph/FiniteDensity/Positive/Basic.lean:251 · uses DAG , CompactPositiveFactorization
def CondIndepCoordinates reviewed
Causalean.Graph.FiniteDensity.CompactPositiveFactorization

Coordinate i is conditionally independent of coordinate j given C under the observational product-density law.

Definition (Lean source)
V :
Type uV
V → Type uX
(i : V) → Measure (X i)
DAG V
shared
M :
shared
i j :
V
C :
CondIndepCoordinates M i j C :
Prop
CondIndepFun (comap (coordinateProjection (X := X) C) inferInstance) (coordinateConditioning_comap_le (X := X) C) (fun x : ∀ k, X k ↦ x i) (fun x : ∀ k, X k ↦ x j) M.observationalMeasure
Causalean.Graph.FiniteDensity.CompactPositiveFactorization.CondIndepCoordinates · Causalean/Graph/FiniteDensity/Positive/Basic.lean:255 · uses DAG , CompactPositiveFactorization
def FactorIndependentOf reviewed
Causalean.Graph.FiniteDensity.CompactPositiveFactorization

A child's local conditional density is independent of coordinate j when updating only that coordinate leaves the factor unchanged at every point of the compact product domain.

Definition (Lean source)
V :
Type uV
V → Type uX
(i : V) → Measure (X i)
DAG V
shared
M :
shared
i j :
V
x :
∀ k, X k
xj :
X j
FactorIndependentOf M i j :
Prop
M.toFactorization.factor i (update x j xj) = M.toFactorization.factor i x
Causalean.Graph.FiniteDensity.CompactPositiveFactorization.FactorIndependentOf · Causalean/Graph/FiniteDensity/Positive/Basic.lean:264 · uses DAG , CompactPositiveFactorization
def AEFactorIndependentOf reviewed
Causalean.Graph.FiniteDensity.CompactPositiveFactorization

A child's local factor is almost-everywhere independent of coordinate j when the update identity holds for product-reference-almost every assignment and parent value.

Definition (Lean source)
V :
Type uV
V → Type uX
(i : V) → Measure (X i)
DAG V
shared
M :
shared
i j :
V
AEFactorIndependentOf M i j :
Prop
∀ᵐ x ∂Measure.pi μ, ∀ᵐ xj ∂μ j, M.toFactorization.factor i (update x j xj)
= M.toFactorization.factor i x
Causalean.Graph.FiniteDensity.CompactPositiveFactorization.AEFactorIndependentOf · Causalean/Graph/FiniteDensity/Positive/Basic.lean:270 · uses DAG , CompactPositiveFactorization
1 supporting declaration (lemmas, instances)
  • condDistrib_child_given_parents theorem — A compact positive factorization and node have a regular conditional law of that node given its parents equal to the reference measure weighted by the node's normalized local factor.
    V :
    Type uV
    V → Type uX
    (i : V) → Measure (X i)
    DAG V
    shared
    M :
    shared
    i :
    V
    P :
    G.parents i
    x₀ :
    choice inferInstance (: ∀ k, X k)
    d :
    fun p z ↦ M.toFactorization.factor i (update (coordinateExtension P x₀ p) i z) (: (∀ k : P, X k) → X i → ℝ≥0∞)
    condDistrib (fun x : ∀ k, X k ↦ x i) (coordinateProjection (X := X) P) M.observationalMeasure
    =ᵐ[Measure.map (coordinateProjection (X := X) P) M.observationalMeasure] Kernel.withDensity (Kernel.const (∀ k : P, X k) (μ i)) d
    Proof (Lean source)
    theorem condDistrib_child_given_parents (i : V) : let P := G.parents i let x₀ : ∀ k, X k := Classical.choice inferInstance let d : (∀ k : P, X k) → X i → ℝ≥0∞ := fun p z ↦ M.toFactorization.factor i (update (coordinateExtension P x₀ p) i z) condDistrib (fun x : ∀ k, X k ↦ x i) (coordinateProjection (X := X) P) M.observationalMeasure =ᵐ[Measure.map (coordinateProjection (X := X) P) M.observationalMeasure] Kernel.withDensity (Kernel.const (∀ k : P, X k) (μ i)) d := by classical dsimp only let P := G.parents i let x₀ : ∀ k, X k := Classical.choice inferInstance let d : (∀ k : P, X k) → X i → ℝ≥0∞ := fun p z ↦ M.toFactorization.factor i (update (coordinateExtension P x₀ p) i z) have hd : Measurable (uncurry d) := by unfold d exact (M.toFactorization.measurable_factor i).comp (measurable_update'.comp (((measurable_coordinateExtension P x₀).comp measurable_fst).prodMk measurable_snd)) let κ : Kernel (∀ k : P, X k) (X i) := Kernel.withDensity (Kernel.const (∀ k : P, X k) (μ i)) d have hκ_apply (p : ∀ k : P, X k) : κ p = (μ i).withDensity (d p) := by dsimp [κ] rw [Kernel.withDensity_apply _ hd, Kernel.const_apply] have hd_eq (x : ∀ k, X k) (z : X i) : d (coordinateProjection (X := X) P x) z = M.toFactorization.factor i (update x i z) := by unfold d apply M.toFactorization.local_factor i intro k hk rcases Finset.mem_insert.mp hk with rfl | hk · simp · have hki : k ≠ i := by intro hki subst k exact G.irrefl i (G.mem_parents.mp hk) have hkP : k ∈ P := by simpa [P] using hk simp [coordinateExtension, coordinateProjection, hkP, hki] letI : IsFiniteKernel κ := ⟨1, ENNReal.one_lt_top, fun p ↦ by rw [hκ_apply, withDensity_apply _ MeasurableSet.univ] simp only [Measure.restrict_univ] change ∫⁻ z, M.toFactorization.factor i (update (coordinateExtension P x₀ p) i z) ∂μ i ≤ 1 rw [M.toFactorization.normalized_factor]⟩ apply condDistrib_ae_eq_of_measure_eq_compProd_of_measurable (measurable_coordinateProjection P) (measurable_pi_apply i) apply Measure.ext_prod intro s t hs ht rw [Measure.map_apply (by fun_prop) (hs.prod ht), Measure.compProd_apply_prod hs ht] rw [← lintegral_indicator_one ((hs.prod ht).preimage ((measurable_coordinateProjection P).prodMk (measurable_pi_apply i)))] rw [← lintegral_indicator hs] rw [lintegral_map ((Kernel.measurable_coe κ ht).indicator hs) (measurable_coordinateProjection P)] simp_rw [hκ_apply, withDensity_apply _ ht] calc (∫⁻ a, ((fun x : ∀ k, X k ↦ (coordinateProjection (X := X) P x, x i)) ⁻¹' (s ×ˢ t)).indicator 1 a ∂M.observationalMeasure) = ∫⁻ x, s.indicator 1 (coordinateProjection (X := X) P x) * t.indicator 1 (x i) ∂M.observationalMeasure := by apply lintegral_congr intro x by_cases hp : coordinateProjection (X := X) P x ∈ s <;> by_cases hi : x i ∈ t <;> simp [indicator, hp, hi] _ = ∫⁻ x, s.indicator 1 (coordinateProjection (X := X) P x) * (∫⁻ z, t.indicator 1 z * M.toFactorization.factor i (update x i z) ∂μ i) ∂M.observationalMeasure := _root_.Causalean.Graph.FiniteDensity.Factorization.lintegral_node_given_parents M.toFactorization i (s.indicator 1) (t.indicator 1) (measurable_const.indicator hs) (measurable_const.indicator ht) _ = ∫⁻ a, s.indicator (fun p ↦ ∫⁻ z in t, d p z ∂μ i) (coordinateProjection (X := X) P a) ∂M.observationalMeasure := by apply lintegral_congr intro x by_cases hp : coordinateProjection (X := X) P x ∈ s · simp only [Set.indicator_of_mem hp, Pi.one_apply, one_mul] rw [← lintegral_indicator ht] apply lintegral_congr intro z by_cases hz : z ∈ t <;> simp [indicator, hz, hd_eq] · simp [indicator, hp]
    Causalean.Graph.FiniteDensity.CompactPositiveFactorization.condDistrib_child_given_parents · Causalean/Graph/FiniteDensity/Positive/Basic.lean:276
Finite 8 core · 5 supporting This module gives a pointwise finite-state interface for strictly positive Bayesian-network mechanisms. ★ edge_condIndep_iff_localContrast_zero

Positive finite-state DAG mechanisms

This module gives a pointwise finite-state interface for strictly positive Bayesian-network mechanisms. It defines cylinder marginals and conditional masses directly from the product density, and characterizes a redundant directed edge by independence of the child's local factor. Stable witnesses are in Positive.FiniteWitness.

structure PositiveFiniteDAGMechanism reviewed
Causalean.Graph.FiniteDensity

A positive finite-state DAG mechanism consists of normalized, strictly positive local factors, each depending only on its own coordinate and its graph parents.

Definition (Lean source)
V :
Type uV
shared
G :
DAG V
X :
V → Type uX
∀ i, Fintype (X i)
The local conditional mass factor at each vertex.
factor :
∀ i
if
(∀ k, X k)
then
Every local factor is strictly positive.
factor_pos :
∀ i x, 0 < factor i x
Each local factor sums to one in its own coordinate for every fixed context.
factor_normalized :
∀ i x, ∑ z : X i, factor i (update x i z) = 1
A local factor depends only on its vertex and its parents.
factor_local :
∀ i, DependsOn (X := X) (insert i (G.parents i)) (factor i)
Causalean.Graph.FiniteDensity.PositiveFiniteDAGMechanism · Causalean/Graph/FiniteDensity/Positive/Finite.lean:32 · uses DAG
def jointMass reviewed
Causalean.Graph.FiniteDensity.PositiveFiniteDAGMechanism

The joint mass of an assignment is the product of all local factors.

Definition (Lean source)
V :
Type uV
V → Type uX
DAG V
shared
x :
∀ i, X i
jointMass M x :
∏ i, M.factor i x
Causalean.Graph.FiniteDensity.PositiveFiniteDAGMechanism.jointMass · Causalean/Graph/FiniteDensity/Positive/Finite.lean:49 · uses DAG , PositiveFiniteDAGMechanism
def marginalMass reviewed
Causalean.Graph.FiniteDensity.PositiveFiniteDAGMechanism

The mass of the cylinder fixing the coordinates in S to their values in x is obtained by summing the joint product mass over all compatible full assignments.

Definition (Lean source)
V :
Type uV
V → Type uX
DAG V
shared
S :
x :
∀ i, X i
marginalMass M S x :
∑ y : ∀ i, X i, if coordinateProjection (X := X) S y
= coordinateProjection (X := X) S x then M.jointMass y else 0
Causalean.Graph.FiniteDensity.PositiveFiniteDAGMechanism.marginalMass · Causalean/Graph/FiniteDensity/Positive/Finite.lean:52 · uses DAG , PositiveFiniteDAGMechanism
def conditionalMass reviewed
Causalean.Graph.FiniteDensity.PositiveFiniteDAGMechanism

The pointwise conditional mass of coordinate i taking a given value, given the coordinates in C, is the mass of the cylinder fixing i and C divided by the mass of the cylinder fixing C (zero if that mass is zero). It is the elementary conditional probability when i is not in C, which is how it is used; if i belongs to C, the numerator overrides that conditioning value.

Definition (Lean source)
V :
Type uV
V → Type uX
DAG V
shared
i :
V
C :
x :
∀ i, X i
z :
X i
conditionalMass M i C x z :
M.marginalMass (insert i C) (update x i z) / M.marginalMass C x
Causalean.Graph.FiniteDensity.PositiveFiniteDAGMechanism.conditionalMass · Causalean/Graph/FiniteDensity/Positive/Finite.lean:59 · uses DAG , PositiveFiniteDAGMechanism
def CondIndepCoordinates reviewed
Causalean.Graph.FiniteDensity.PositiveFiniteDAGMechanism

The cross-product conditional-independence identity for two coordinates given a set C: for every assignment and every values of the two coordinates, the cylinder masses satisfy the usual cross-multiplied finite conditional-probability identity. It expresses conditional independence when the two coordinates are distinct and neither lies in C, as in every use here (a child and one of its parents, given the remaining parents); for overlapping arguments the identity is not conditional independence.

Definition (Lean source)
V :
Type uV
V → Type uX
DAG V
shared
i j :
V
C :
x :
∀ k, X k
xi :
X i
xj :
X j
CondIndepCoordinates M i j C :
Prop
M.marginalMass (insert i (insert j C)) (update (update x i xi) j xj) * M.marginalMass C x
= M.marginalMass (insert i C) (update x i xi) * M.marginalMass (insert j C) (update x j xj)
Causalean.Graph.FiniteDensity.PositiveFiniteDAGMechanism.CondIndepCoordinates · Causalean/Graph/FiniteDensity/Positive/Finite.lean:305 · uses DAG , PositiveFiniteDAGMechanism
def FactorIndependentOf reviewed
Causalean.Graph.FiniteDensity.PositiveFiniteDAGMechanism

A local factor is independent of coordinate j when changing only that coordinate never changes the factor.

Definition (Lean source)
V :
Type uV
V → Type uX
DAG V
shared
i j :
V
x :
∀ k, X k
xj :
X j
FactorIndependentOf M i j :
Prop
M.factor i (update x j xj) = M.factor i x
Causalean.Graph.FiniteDensity.PositiveFiniteDAGMechanism.FactorIndependentOf · Causalean/Graph/FiniteDensity/Positive/Finite.lean:318 · uses DAG , PositiveFiniteDAGMechanism
def localContrast reviewed
Causalean.Graph.FiniteDensity.PositiveFiniteDAGMechanism

The four-point local contrast compares the two-by-two cross products of a child's factor as its own value and one candidate parent value vary, with all other coordinates held fixed.

Definition (Lean source)
V :
Type uV
V → Type uX
DAG V
shared
i j :
V
x :
∀ k, X k
xi xi' :
X i
xj xj' :
X j
localContrast M i j x xi xi' xj xj' :
M.factor i (update (update x i xi) j xj) * M.factor i (update (update x i xi') j xj')
- M.factor i (update (update x i xi) j xj') * M.factor i (update (update x i xi') j xj)
Causalean.Graph.FiniteDensity.PositiveFiniteDAGMechanism.localContrast · Causalean/Graph/FiniteDensity/Positive/Finite.lean:323 · uses DAG , PositiveFiniteDAGMechanism
theorem edge_condIndep_iff_localContrast_zero reviewed
Causalean.Graph.FiniteDensity.PositiveFiniteDAGMechanism

A positive finite-state DAG mechanism and directed edge have conditional independence of the endpoints given the other parents exactly when every local four-point factor contrast vanishes.

Formal statement
V :
Type uV
V → Type uX
DAG V
shared
i j :
V
hji :
G.edge j i
M.CondIndepCoordinates i j ((G.parents i).erase j)
↔ ∀ (x : ∀ k, X k) (xi xi' : X i) (xj xj' : X j), M.localContrast i j x xi xi' xj xj' = 0
Proof (Lean source)
theorem edge_condIndep_iff_localContrast_zero {i j : V} (hji : G.edge j i) : M.CondIndepCoordinates i j ((G.parents i).erase j) ↔ ∀ (x : ∀ k, X k) (xi xi' : X i) (xj xj' : X j), M.localContrast i j x xi xi' xj xj' = 0 := by exact (M.edge_condIndep_iff_factorIndependent hji).trans (M.factorIndependent_iff_localContrast_zero hji)
Causalean.Graph.FiniteDensity.PositiveFiniteDAGMechanism.edge_condIndep_iff_localContrast_zero · Causalean/Graph/FiniteDensity/Positive/Finite.lean:546 · uses DAG , parents , PositiveFiniteDAGMechanism , CondIndepCoordinates , localContrast
5 supporting declarations (lemmas, instances)
  • sum_jointMass theorem — The product density of a normalized positive finite DAG mechanism has total mass one.
    V :
    Type uV
    V → Type uX
    DAG V
    shared
    ∑ x : ∀ i, X i, M.jointMass x = 1
    Proof (Lean source)
    theorem sum_jointMass : ∑ x : ∀ i, X i, M.jointMass x = 1 := by letI : ∀ i, MeasurableSpace (X i) := fun _ => ⊤ let μ : ∀ i, Measure (X i) := fun _ => Measure.count haveI : ∀ i, SigmaFinite (μ i) := fun _ => inferInstance let B : Factorization G X μ := { factor := fun i x => ofReal (M.factor i x) measurable_factor := by intro i exact measurable_of_countable _ local_factor := by intro i x y hxy exact congrArg ofReal (M.factor_local i hxy) normalized_factor := by intro i x rw [MeasureTheory.lintegral_count, tsum_fintype, ← ENNReal.ofReal_sum_of_nonneg] · rw [M.factor_normalized] simp · intro z _ exact (M.factor_pos i _).le } have hpi : Measure.pi μ = (Measure.count : Measure (∀ i, X i)) := by apply Measure.ext_of_singleton intro x rw [Measure.pi_singleton, Measure.count_singleton] dsimp [μ] simp have hobs (x : ∀ i, X i) : B.observationalDensity x = ofReal (M.jointMass x) := by change (∏ i ∈ univ, ofReal (M.factor i x)) = ofReal (∏ i ∈ univ, M.factor i x) rw [ENNReal.ofReal_prod_of_nonneg] intro i _ exact (M.factor_pos i x).le let x₀ : ∀ i, X i := fun i => choice (inferInstance : Nonempty (X i)) have hmarg := B.lmarginal_compl_observationalDensity_eq (A := ∅) (by intro i hi simp at hi) have hint : ∫⁻ x, B.observationalDensity x ∂Measure.pi μ = 1 := by rw [MeasureTheory.lintegral_eq_lmarginal_univ x₀] simpa [Factorization.partialDensity] using congrFun hmarg x₀ rw [hpi, MeasureTheory.lintegral_count, tsum_fintype] at hint simp_rw [hobs] at hint rw [← ENNReal.ofReal_sum_of_nonneg] at hint · exact ENNReal.ofReal_eq_one.mp hint · intro x _ exact (Finset.prod_pos fun i _ => M.factor_pos i x).le
    Causalean.Graph.FiniteDensity.PositiveFiniteDAGMechanism.sum_jointMass · Causalean/Graph/FiniteDensity/Positive/Finite.lean:66
  • marginalMass_pos theorem — Every cylinder marginal of a positive finite DAG mechanism is strictly positive.
    V :
    Type uV
    V → Type uX
    DAG V
    shared
    S :
    x :
    ∀ i, X i
    0 < M.marginalMass S x
    Proof (Lean source)
    theorem marginalMass_pos (S : Finset V) (x : ∀ i, X i) : 0 < M.marginalMass S x := by unfold marginalMass apply Finset.sum_pos' · intro y _ split_ifs · exact (Finset.prod_pos fun i _ => M.factor_pos i y).le · exact le_rfl · refine ⟨x, Finset.mem_univ x, ?_⟩ simp only [ite_true] exact Finset.prod_pos fun i _ => M.factor_pos i x
    Causalean.Graph.FiniteDensity.PositiveFiniteDAGMechanism.marginalMass_pos · Causalean/Graph/FiniteDensity/Positive/Finite.lean:115
  • conditionalMass_given_parents theorem — Conditioning a node on all of its parents recovers exactly its normalized local factor.
    V :
    Type uV
    V → Type uX
    DAG V
    shared
    i :
    V
    x :
    ∀ i, X i
    z :
    X i
    M.conditionalMass i (G.parents i) x z = M.factor i (update x i z)
    Proof (Lean source)
    theorem conditionalMass_given_parents (i : V) (x : ∀ i, X i) (z : X i) : M.conditionalMass i (G.parents i) x z = M.factor i (update x i z) := by letI : ∀ i, MeasurableSpace (X i) := fun _ => ⊤ let μ : ∀ i, Measure (X i) := fun _ => Measure.count haveI : ∀ i, SigmaFinite (μ i) := fun _ => inferInstance let B : Factorization G X μ := { factor := fun i x => ofReal (M.factor i x) measurable_factor := by intro i exact measurable_of_countable _ local_factor := by intro i x y hxy exact congrArg ofReal (M.factor_local i hxy) normalized_factor := by intro i x rw [lintegral_count, tsum_fintype, ← ENNReal.ofReal_sum_of_nonneg] · rw [M.factor_normalized] simp · intro w _ exact (M.factor_pos i _).le } have hpi : Measure.pi μ = (Measure.count : Measure (∀ i, X i)) := by apply Measure.ext_of_singleton intro y rw [Measure.pi_singleton, Measure.count_singleton] dsimp [μ] simp have hobs (y : ∀ i, X i) : B.observationalDensity y = ofReal (M.jointMass y) := by change (∏ i ∈ univ, ofReal (M.factor i y)) = ofReal (∏ i ∈ univ, M.factor i y) rw [ENNReal.ofReal_prod_of_nonneg] intro j _ exact (M.factor_pos j y).le have hcyl (S : Finset V) (a : ∀ i, X i) : ofReal (M.marginalMass S a) = ∫⁻ y, (if coordinateProjection (X := X) S y = coordinateProjection (X := X) S a then 1 else 0) ∂B.observationalMeasure := by rw [Factorization.observationalMeasure, lintegral_withDensity_eq_lintegral_mul _ B.measurable_observationalDensity (measurable_of_countable _)] rw [hpi, lintegral_count, tsum_fintype] unfold marginalMass rw [ENNReal.ofReal_sum_of_nonneg] · apply Finset.sum_congr rfl intro y _ change ofReal (if coordinateProjection (X := X) S y = coordinateProjection (X := X) S a then M.jointMass y else 0) = B.observationalDensity y * (if coordinateProjection (X := X) S y = coordinateProjection (X := X) S a then 1 else 0) rw [hobs] by_cases hy : coordinateProjection (X := X) S y = coordinateProjection (X := X) S a · simp [hy] · simp [hy] · intro y _ by_cases hy : coordinateProjection (X := X) S y = coordinateProjection (X := X) S a · simp [hy] exact (Finset.prod_pos fun j _ => M.factor_pos j y).le · simp [hy] let h : (∀ k : G.parents i, X k) → ℝ≥0∞ := fun p => if p = coordinateProjection (X := X) (G.parents i) x then 1 else 0 let g : X i → ℝ≥0∞ := fun w => if w = z then 1 else 0 have hnode := _root_.Causalean.Graph.FiniteDensity.Factorization.lintegral_node_given_parents B i h g (measurable_of_countable _) (measurable_of_countable _) have hinner (y : ∀ i, X i) : (∫⁻ w, g w * B.factor i (update y i w) ∂μ i) = B.factor i (update y i z) := by rw [lintegral_count, tsum_fintype] simp [g] have hmeasure : ofReal (M.marginalMass (insert i (G.parents i)) (update x i z)) = ofReal (M.factor i (update x i z)) * ofReal (M.marginalMass (G.parents i) x) := by rw [hcyl, hcyl] calc (∫⁻ y, (if coordinateProjection (X := X) (insert i (G.parents i)) y = coordinateProjection (X := X) (insert i (G.parents i)) (update x i z) then 1 else 0) ∂B.observationalMeasure) = ∫⁻ y, h (coordinateProjection (X := X) (G.parents i) y) * g (y i) ∂B.observationalMeasure := by apply lintegral_congr intro y by_cases hyi : y i = z <;> by_cases hyp : coordinateProjection (X := X) (G.parents i) y = coordinateProjection (X := X) (G.parents i) x <;> simp [h, g, projection_insert_update_iff, hyi, hyp] _ = ∫⁻ y, h (coordinateProjection (X := X) (G.parents i) y) * (∫⁻ w, g w * B.factor i (update y i w) ∂μ i) ∂B.observationalMeasure := hnode _ = ∫⁻ y, ofReal (M.factor i (update x i z)) * h (coordinateProjection (X := X) (G.parents i) y) ∂B.observationalMeasure := by apply lintegral_congr intro y rw [hinner] by_cases hy : coordinateProjection (X := X) (G.parents i) y = coordinateProjection (X := X) (G.parents i) x · change h _ * ofReal (M.factor i (update y i z)) = _ rw [factor_update_eq_of_projection_eq M i x y z hy] simp [h, hy] · simp [h, hy] _ = ofReal (M.factor i (update x i z)) * ∫⁻ y, h (coordinateProjection (X := X) (G.parents i) y) ∂B.observationalMeasure := by rw [lintegral_const_mul] exact measurable_of_countable _ _ = ofReal (M.factor i (update x i z)) * ∫⁻ y, (if coordinateProjection (X := X) (G.parents i) y = coordinateProjection (X := X) (G.parents i) x then 1 else 0) ∂B.observationalMeasure := by rfl have hreal : M.marginalMass (insert i (G.parents i)) (update x i z) = M.factor i (update x i z) * M.marginalMass (G.parents i) x := by rw [← ENNReal.ofReal_eq_ofReal_iff] · rw [ENNReal.ofReal_mul (M.factor_pos i _).le] exact hmeasure · exact (M.marginalMass_pos _ _).le · exact mul_nonneg (M.factor_pos i _).le (M.marginalMass_pos _ _).le unfold conditionalMass rw [hreal] exact mul_div_cancel_right₀ _ (ne_of_gt (M.marginalMass_pos (G.parents i) x))
    Causalean.Graph.FiniteDensity.PositiveFiniteDAGMechanism.conditionalMass_given_parents · Causalean/Graph/FiniteDensity/Positive/Finite.lean:178
  • edge_condIndep_iff_factorIndependent theorem — For a directed edge j → i, conditional independence of its endpoints given the other parents is equivalent to pointwise independence of the child's local factor from j.
    V :
    Type uV
    V → Type uX
    DAG V
    shared
    i j :
    V
    hji :
    G.edge j i
    M.CondIndepCoordinates i j ((G.parents i).erase j) ↔ M.FactorIndependentOf i j
    Proof (Lean source)
    theorem edge_condIndep_iff_factorIndependent {i j : V} (hji : G.edge j i) : M.CondIndepCoordinates i j ((G.parents i).erase j) ↔ M.FactorIndependentOf i j := by classical let C := (G.parents i).erase j have hij : i ≠ j := by intro hij subst j exact G.irrefl i hji have hparents : insert j C = G.parents i := Finset.insert_erase (G.mem_parents.mpr hji) constructor · intro hCI x xj have heq (z : X j) : M.factor i (update x j z) * M.marginalMass C x = M.marginalMass (insert i C) x := by have h := hCI x (x i) z rw [show (G.parents i).erase j = C from rfl, hparents] at h have hnum : M.marginalMass (insert i (G.parents i)) (update (update x i (x i)) j z) = M.factor i (update x j z) * M.marginalMass (G.parents i) (update x j z) := by have hcoord : update x j z i = x i := Function.update_of_ne hij z x have hidem : update (update x j z) i (x i) = update x j z := by rw [← hcoord, Function.update_eq_self] simpa [hidem] using marginalMass_insert_parents_eq_factor_mul M i (update x j z) (x i) rw [hnum] at h simp only [Function.update_eq_self] at h apply (mul_right_cancel₀ (ne_of_gt (M.marginalMass_pos (G.parents i) (update x j z)))) ring_nf at h ⊢ exact h have hnew := heq xj have hold := heq (x j) simp only [Function.update_eq_self] at hold apply (mul_right_cancel₀ (ne_of_gt (M.marginalMass_pos C x))) exact hnew.trans hold.symm · intro hind x xi xj rw [show (G.parents i).erase j = C from rfl, hparents] have hnum : M.marginalMass (insert i (G.parents i)) (update (update x i xi) j xj) = M.factor i (update (update x i xi) j xj) * M.marginalMass (G.parents i) (update x j xj) := by simpa [Function.update_comm hij] using marginalMass_insert_parents_eq_factor_mul M i (update x j xj) xi rw [hnum, marginalMass_insert_child_eq_factor_mul_of_independent M hji hind] rw [hind (update x i xi) xj] ring
    Causalean.Graph.FiniteDensity.PositiveFiniteDAGMechanism.edge_condIndep_iff_factorIndependent · Causalean/Graph/FiniteDensity/Positive/Finite.lean:428
  • factorIndependent_iff_localContrast_zero theorem — For a directed edge j → i, independence of the child's factor from j is equivalent to vanishing of every local four-point cross-product contrast.
    V :
    Type uV
    V → Type uX
    DAG V
    shared
    i j :
    V
    hji :
    G.edge j i
    M.FactorIndependentOf i j
    ↔ ∀ (x : ∀ k, X k) (xi xi' : X i) (xj xj' : X j), M.localContrast i j x xi xi' xj xj' = 0
    Proof (Lean source)
    theorem factorIndependent_iff_localContrast_zero {i j : V} (hji : G.edge j i) : M.FactorIndependentOf i j ↔ ∀ (x : ∀ k, X k) (xi xi' : X i) (xj xj' : X j), M.localContrast i j x xi xi' xj xj' = 0 := by constructor · intro hind x xi xi' xj xj' have hij : i ≠ j := by intro hij subst j exact G.irrefl i hji unfold localContrast rw [hind (update x i xi) xj, hind (update x i xi') xj', hind (update x i xi) xj', hind (update x i xi') xj] ring · intro hzero x xj have hij : i ≠ j := by intro hij subst j exact G.irrefl i hji have hcross (z w : X i) : M.factor i (update (update x j xj) i z) * M.factor i (update x i w) = M.factor i (update x i z) * M.factor i (update (update x j xj) i w) := by apply sub_eq_zero.mp simpa [localContrast, Function.update_comm hij] using hzero x z w xj (x j) have hsum (z : X i) : M.factor i (update (update x j xj) i z) = M.factor i (update x i z) := by have hs := Finset.sum_congr rfl (fun w (_ : w ∈ univ) ↦ hcross z w) calc M.factor i (update (update x j xj) i z) = M.factor i (update (update x j xj) i z) * 1 := by ring _ = M.factor i (update (update x j xj) i z) * ∑ w : X i, M.factor i (update x i w) := by rw [M.factor_normalized] _ = ∑ w : X i, M.factor i (update (update x j xj) i z) * M.factor i (update x i w) := Finset.mul_sum _ _ _ _ = ∑ w : X i, M.factor i (update x i z) * M.factor i (update (update x j xj) i w) := hs _ = M.factor i (update x i z) * ∑ w : X i, M.factor i (update (update x j xj) i w) := (Finset.mul_sum _ _ _).symm _ = M.factor i (update x i z) := by rw [M.factor_normalized] ring have hz := hsum (x i) have hcoord : update x j xj i = x i := Function.update_of_ne hij xj x have hidem : update (update x j xj) i (x i) = update x j xj := by rw [← hcoord, Function.update_eq_self] simpa [hidem] using hz
    Causalean.Graph.FiniteDensity.PositiveFiniteDAGMechanism.factorIndependent_iff_localContrast_zero · Causalean/Graph/FiniteDensity/Positive/Finite.lean:485
Edge 2 core · 11 supporting This module characterizes a redundant edge in a compact strictly positive finite-DAG density: conditional independence given the other parents is exactly pointwise independence of the child's local factor, equivalently v ★ edge_condIndep_iff_factorIndependent

Edge minimality for compact positive DAG densities

This module characterizes a redundant edge in a compact strictly positive finite-DAG density: conditional independence given the other parents is exactly pointwise independence of the child's local factor, equivalently vanishing of its four-point contrast.

def localContrast reviewed
Causalean.Graph.FiniteDensity.CompactPositiveFactorization

The real four-point cross-product contrast of a child's local density varies its own coordinate and one other coordinate while holding all remaining coordinates fixed. The other coordinate is arbitrary here; the edge characterization applies it to a parent of the child, and if it equals the child's own coordinate the contrast is identically zero.

Definition (Lean source)
V :
Type uV
V → Type uX
(i : V) → Measure (X i)
DAG V
shared
M :
shared
i j :
V
x :
∀ k, X k
xi xi' :
X i
xj xj' :
X j
localContrast M i j x xi xi' xj xj' :
(M.toFactorization.factor i (update (update x i xi) j xj)).toReal * (M.toFactorization.factor i (update (update x i xi') j xj')).toReal
- (M.toFactorization.factor i (update (update x i xi) j xj')).toReal * (M.toFactorization.factor i (update (update x i xi') j xj)).toReal
Causalean.Graph.FiniteDensity.CompactPositiveFactorization.localContrast · Causalean/Graph/FiniteDensity/Positive/Edge.lean:99 · uses DAG , CompactPositiveFactorization
theorem edge_condIndep_iff_factorIndependent reviewed
Causalean.Graph.FiniteDensity.CompactPositiveFactorization

A compact positive factorization and directed edge have conditional independence of its endpoints given the child's other parents exactly when the child's local factor is pointwise unchanged by changing the parent coordinate.

Formal statement
V :
Type uV
V → Type uX
(i : V) → Measure (X i)
DAG V
shared
M :
shared
i j :
V
hji :
G.edge j i
M.CondIndepCoordinates i j ((G.parents i).erase j) ↔ M.FactorIndependentOf i j
Proof (Lean source)
theorem edge_condIndep_iff_factorIndependent {i j : V} (hji : G.edge j i) : M.CondIndepCoordinates i j ((G.parents i).erase j) ↔ M.FactorIndependentOf i j := by exact (M.edge_condIndep_iff_aeFactorIndependent hji).trans M.aeFactorIndependent_iff_factorIndependent
Causalean.Graph.FiniteDensity.CompactPositiveFactorization.edge_condIndep_iff_factorIndependent · Causalean/Graph/FiniteDensity/Positive/Edge.lean:563 · uses DAG , parents , CompactPositiveFactorization , CondIndepCoordinates , FactorIndependentOf
11 supporting declarations (lemmas, instances)
  • aeFactorIndependent_of_edge_condIndep theorem — For an edge j → i, conditional independence of the endpoints given the other parents forces reference-almost-everywhere independence of the child's local factor from j.
    V :
    Type uV
    V → Type uX
    (i : V) → Measure (X i)
    DAG V
    shared
    M :
    shared
    i j :
    V
    hji :
    G.edge j i
    M.CondIndepCoordinates i j ((G.parents i).erase j)
    M.AEFactorIndependentOf i j
    Proof (Lean source)
    theorem aeFactorIndependent_of_edge_condIndep {i j : V} (hji : G.edge j i) : M.CondIndepCoordinates i j ((G.parents i).erase j) → M.AEFactorIndependentOf i j := by /- Use `lintegral_node_given_parents` with bounded indicator tests to identify the conditional law of `i` given all parents. Conditional independence drops `j` from that law. Strict positivity makes the observational law equivalent to the product reference law, after which uniqueness of Radon–Nikodym densities gives the iterated-a.e. update identity. Useful library bridges are `condIndepFun_iff_condDistrib_prod_ae_eq_prodMkRight` (after `CondIndepFun.symm`) for dropping `j` from the conditional kernel, and `MeasureTheory.withDensity_ae_eq` (or `withDensity_absolutelyContinuous'`) for transferring the resulting observational-a.e. statement to `Measure.pi μ`. -/ intro hCI classical let C := (G.parents i).erase j let P := G.parents i let Y : (∀ k, X k) → X i := fun x ↦ x i let J : (∀ k, X k) → X j := fun x ↦ x j let K := coordinateProjection (X := X) C let R := coordinateProjection (X := X) P let e := parentSplitEquiv (X := X) hji have he : e ∘ R = fun x ↦ (K x, J x) := by funext x change e (R x) = (K x, J x) rw [show e (R x) = (fun k : (G.parents i).erase j ↦ R x ⟨k, mem_of_mem_erase k.property⟩, R x ⟨j, G.mem_parents.mpr hji⟩) by exact parentSplitEquiv_apply (X := X) hji (R x)] rfl have hdrop : condDistrib Y (fun x ↦ (K x, J x)) M.observationalMeasure =ᵐ[Measure.map (fun x ↦ (K x, J x)) M.observationalMeasure] (condDistrib Y K M.observationalMeasure).prodMkRight _ := by apply (condIndepFun_iff_condDistrib_prod_ae_eq_prodMkRight (f := Y) (g := J) (k := K) (by fun_prop) (by fun_prop) (by fun_prop)).mp simpa [CondIndepCoordinates, Y, J, K, C] using hCI.symm have hreparam := condDistrib_comp_right_measurableEquiv M.observationalMeasure e (Y := Y) (X := R) (by fun_prop) (by fun_prop) have hparent := M.condDistrib_child_given_parents i change condDistrib Y R M.observationalMeasure =ᵐ[Measure.map R M.observationalMeasure] _ at hparent have hmap : Measure.map e (Measure.map R M.observationalMeasure) = Measure.map (fun x ↦ (K x, J x)) M.observationalMeasure := by rw [Measure.map_map e.measurable (by fun_prop), he] have hdrop' : (fun p ↦ condDistrib Y (fun x ↦ (K x, J x)) M.observationalMeasure (e p)) =ᵐ[Measure.map R M.observationalMeasure] fun p ↦ condDistrib Y K M.observationalMeasure (e p).1 := by have h := ae_of_ae_map (μ := Measure.map R M.observationalMeasure) e.measurable.aemeasurable (by rw [hmap]; exact hdrop) filter_upwards [h] with p hp simpa using hp have hparent_drop : (fun p ↦ (Kernel.withDensity (Kernel.const (∀ k : P, X k) (μ i)) (fun p z ↦ M.toFactorization.factor i (update (coordinateExtension P (Classical.choice inferInstance) p) i z))) p) =ᵐ[Measure.map R M.observationalMeasure] fun p ↦ condDistrib Y K M.observationalMeasure (e p).1 := by filter_upwards [hparent, hreparam, hdrop'] with p hp hr hd exact hp.symm.trans (hr.symm.trans hd) have hobs := ae_of_ae_map (μ := M.observationalMeasure) (show AEMeasurable R M.observationalMeasure by fun_prop) hparent_drop have hfactor_ne_zero (k : V) (x : ∀ l, X l) : M.toFactorization.factor k x ≠ 0 := by intro hk have hle := M.lower_le_factor k x rw [hk] at hle simp only [ENNReal.toReal_zero] at hle exact (not_lt_of_ge hle) M.lower_pos have hdensity_ne_zero : ∀ᵐ x ∂Measure.pi μ, M.toFactorization.observationalDensity x ≠ 0 := Filter.Eventually.of_forall fun x ↦ Finset.prod_ne_zero_iff.mpr fun k _ ↦ hfactor_ne_zero k x have hpi : (fun x ↦ (Kernel.withDensity (Kernel.const (∀ k : P, X k) (μ i)) (fun p z ↦ M.toFactorization.factor i (update (coordinateExtension P (Classical.choice inferInstance) p) i z))) (R x)) =ᵐ[Measure.pi μ] fun x ↦ condDistrib Y K M.observationalMeasure (e (R x)).1 := (withDensity_ae_eq M.toFactorization.measurable_observationalDensity.aemeasurable hdensity_ne_zero).mp (by change (fun x ↦ (Kernel.withDensity (Kernel.const (∀ k : P, X k) (μ i)) (fun p z ↦ M.toFactorization.factor i (update (coordinateExtension P (Classical.choice inferInstance) p) i z))) (R x)) =ᵐ[M.observationalMeasure] fun x ↦ condDistrib Y K M.observationalMeasure (e (R x)).1 exact hobs) let split := MeasurableEquiv.piEquivPiSubtypeProd X (fun k ↦ k ∈ C) let μC : Measure (∀ k : {k // k ∈ C}, X k) := @Measure.pi {k : V // k ∈ C} (fun k ↦ X k) (fintype fun k ↦ k ∈ C) (fun k ↦ inferInstance) (fun k ↦ μ k) let μD : Measure (∀ k : {k // k ∉ C}, X k) := @Measure.pi {k : V // k ∉ C} (fun k ↦ X k) (fintype fun k ↦ k ∉ C) (fun k ↦ inferInstance) (fun k ↦ μ k) have hsplit_pres : MeasurePreserving split (Measure.pi μ) (μC.prod μD) := by simpa [split, μC, μD] using measurePreserving_piEquivPiSubtypeProd μ (fun k ↦ k ∈ C) have hsplit : ∀ᵐ q ∂μC.prod μD, (Kernel.withDensity (Kernel.const (∀ k : P, X k) (μ i)) (fun p z ↦ M.toFactorization.factor i (update (coordinateExtension P (Classical.choice inferInstance) p) i z))) (R (split.symm q)) = condDistrib Y K M.observationalMeasure q.1 := by have hs := ae_of_ae_map (μ := μC.prod μD) split.symm.measurable.aemeasurable (by rw [(MeasurePreserving.symm split hsplit_pres).map_eq] exact hpi) filter_upwards [hs] with q hq rw [hq] congr 1 change ((e ∘ R) (split.symm q)).1 = q.1 rw [he] change K (split.symm q) = q.1 funext k simp [K, coordinateProjection, split] have hsplit_nested := Measure.ae_ae_of_ae_prod hsplit let x₀ : ∀ k, X k := Classical.choice inferInstance let d : (∀ k : P, X k) → X i → ℝ≥0∞ := fun p z ↦ M.toFactorization.factor i (update (coordinateExtension P x₀ p) i z) have hd : Measurable (uncurry d) := by unfold d exact (M.toFactorization.measurable_factor i).comp (measurable_update'.comp (((measurable_coordinateExtension P x₀).comp measurable_fst).prodMk measurable_snd)) let κ : Kernel (∀ k : P, X k) (X i) := Kernel.withDensity (Kernel.const (∀ k : P, X k) (μ i)) d have hκ_apply (p : ∀ k : P, X k) : κ p = (μ i).withDensity (d p) := by dsimp [κ] rw [Kernel.withDensity_apply _ hd, Kernel.const_apply] have hd_eq (x : ∀ k, X k) (z : X i) : d (R x) z = M.toFactorization.factor i (update x i z) := by unfold d apply M.toFactorization.local_factor i intro k hk rcases Finset.mem_insert.mp hk with rfl | hk · simp · have hki : k ≠ i := by intro hki subst k exact G.irrefl i (G.mem_parents.mp hk) have hkP : k ∈ P := by simpa [P] using hk simp [R, coordinateProjection, coordinateExtension, hkP, hki] have hsection_ae : ∀ᵐ c ∂μC, ∀ᵐ r₁ ∂μD, ∀ᵐ r₂ ∂μD, ∀ᵐ z ∂μ i, M.toFactorization.factor i (update (split.symm (c, r₁)) i z) = M.toFactorization.factor i (update (split.symm (c, r₂)) i z) := by filter_upwards [hsplit_nested] with c hc filter_upwards [hc] with r₁ hr₁ filter_upwards [hc] with r₂ hr₂ have hκ : κ (R (split.symm (c, r₁))) = κ (R (split.symm (c, r₂))) := by exact hr₁.trans hr₂.symm have hden : d (R (split.symm (c, r₁))) =ᵐ[μ i] d (R (split.symm (c, r₂))) := (withDensity_eq_iff_of_sigmaFinite (Measurable.of_uncurry_left hd (x := R (split.symm (c, r₁)))).aemeasurable (Measurable.of_uncurry_left hd (x := R (split.symm (c, r₂)))).aemeasurable).mp (by rw [← hκ_apply, ← hκ_apply] exact hκ) filter_upwards [hden] with z hz simpa only [hd_eq] using hz let f : ((∀ k : {k // k ∈ C}, X k) × ((∀ k : {k // k ∉ C}, X k) × ((∀ k : {k // k ∉ C}, X k) × X i))) → ℝ := fun q ↦ (M.toFactorization.factor i (update (split.symm (q.1, q.2.1)) i q.2.2.2)).toReal let g : ((∀ k : {k // k ∈ C}, X k) × ((∀ k : {k // k ∉ C}, X k) × ((∀ k : {k // k ∉ C}, X k) × X i))) → ℝ := fun q ↦ (M.toFactorization.factor i (update (split.symm (q.1, q.2.2.1)) i q.2.2.2)).toReal have hsplit_cont : Continuous split.symm := by change Continuous (Homeomorph.piEquivPiSubtypeProd (fun k ↦ k ∈ C) X).symm exact (Homeomorph.piEquivPiSubtypeProd (fun k ↦ k ∈ C) X).symm.continuous have hf : Continuous f := by unfold f exact (M.factor_continuous i).comp ((hsplit_cont.comp (continuous_fst.prodMk continuous_snd.fst)).update i continuous_snd.snd.snd) have hg : Continuous g := by unfold g exact (M.factor_continuous i).comp ((hsplit_cont.comp (continuous_fst.prodMk continuous_snd.snd.fst)).update i continuous_snd.snd.snd) have hfm : Measurable f := by unfold f exact ((M.toFactorization.measurable_factor i).comp (measurable_update'.comp ((split.symm.measurable.comp (measurable_fst.prodMk measurable_snd.fst)).prodMk measurable_snd.snd.snd))).ennreal_toReal have hgm : Measurable g := by unfold g exact ((M.toFactorization.measurable_factor i).comp (measurable_update'.comp ((split.symm.measurable.comp (measurable_fst.prodMk measurable_snd.snd.fst)).prodMk measurable_snd.snd.snd))).ennreal_toReal have hfg_ae : f =ᵐ[μC.prod (μD.prod (μD.prod (μ i)))] g := by apply (Measure.ae_prod_iff_ae_ae (measurableSet_eq_fun hfm hgm)).2 filter_upwards [hsection_ae] with c hc have hfm_c : Measurable (fun y ↦ f (c, y)) := hfm.comp (measurable_const.prodMk measurable_id) have hgm_c : Measurable (fun y ↦ g (c, y)) := hgm.comp (measurable_const.prodMk measurable_id) apply (Measure.ae_prod_iff_ae_ae (measurableSet_eq_fun hfm_c hgm_c)).2 filter_upwards [hc] with r₁ hr₁ have hfm_cr₁ : Measurable (fun y ↦ f (c, r₁, y)) := hfm.comp (measurable_const.prodMk (measurable_const.prodMk measurable_id)) have hgm_cr₁ : Measurable (fun y ↦ g (c, r₁, y)) := hgm.comp (measurable_const.prodMk (measurable_const.prodMk measurable_id)) apply (Measure.ae_prod_iff_ae_ae (measurableSet_eq_fun hfm_cr₁ hgm_cr₁)).2 filter_upwards [hr₁] with r₂ hr₂ filter_upwards [hr₂] with z hz exact congrArg ENNReal.toReal hz have hfg : f = g := (hf.ae_eq_iff_eq (μC.prod (μD.prod (μD.prod (μ i)))) hg).mp hfg_ae have hsections (c : ∀ k : {k // k ∈ C}, X k) (r₁ r₂ : ∀ k : {k // k ∉ C}, X k) (z : X i) : M.toFactorization.factor i (update (split.symm (c, r₁)) i z) = M.toFactorization.factor i (update (split.symm (c, r₂)) i z) := by apply (ENNReal.toReal_eq_toReal_iff' (M.factor_ne_top i (update (split.symm (c, r₁)) i z)) (M.factor_ne_top i (update (split.symm (c, r₂)) i z))).mp exact congrFun hfg (c, r₁, r₂, z) -- … truncated; follow the source link for the rest …
    Causalean.Graph.FiniteDensity.CompactPositiveFactorization.aeFactorIndependent_of_edge_condIndep · Causalean/Graph/FiniteDensity/Positive/Edge.lean:114
  • aeFactorIndependent_of_factorIndependent theorem — Pointwise independence of a local factor from one coordinate implies the corresponding iterated product-reference almost-everywhere update identity.
    V :
    Type uV
    V → Type uX
    (i : V) → Measure (X i)
    DAG V
    shared
    M :
    shared
    i j :
    V
    M.FactorIndependentOf i j
    M.AEFactorIndependentOf i j
    Proof (Lean source)
    theorem aeFactorIndependent_of_factorIndependent {i j : V} : M.FactorIndependentOf i j → M.AEFactorIndependentOf i j := by intro h exact Filter.Eventually.of_forall fun x ↦ Filter.Eventually.of_forall fun xj ↦ h x xj
    Causalean.Graph.FiniteDensity.CompactPositiveFactorization.aeFactorIndependent_of_factorIndependent · Causalean/Graph/FiniteDensity/Positive/Edge.lean:392
  • factorIndependent_of_aeFactorIndependent theorem — Continuity and full support upgrade the iterated product-reference almost-everywhere update identity for a local factor to pointwise independence on the whole compact product domain.
    V :
    Type uV
    V → Type uX
    (i : V) → Measure (X i)
    DAG V
    shared
    M :
    shared
    i j :
    V
    M.AEFactorIndependentOf i j
    M.FactorIndependentOf i j
    Proof (Lean source)
    theorem factorIndependent_of_aeFactorIndependent {i j : V} : M.AEFactorIndependentOf i j → M.FactorIndependentOf i j := by /- Regard the two sides as continuous real functions on `(∀ k, X k) × X j`. Convert the iterated a.e. hypothesis to product-measure a.e. equality, apply full-support extensionality, and use `factor_ne_top` to reflect equality through `ENNReal.toReal`. -/ intro h let f : ((∀ k, X k) × X j) → ℝ := fun z ↦ (M.toFactorization.factor i (update z.1 j z.2)).toReal let g : ((∀ k, X k) × X j) → ℝ := fun z ↦ (M.toFactorization.factor i z.1).toReal have hf : Continuous f := (M.factor_continuous i).comp (continuous_fst.update j continuous_snd) have hg : Continuous g := (M.factor_continuous i).comp continuous_fst have hae : f =ᵐ[(Measure.pi μ).prod (μ j)] g := by have hfm : Measurable f := ((M.toFactorization.measurable_factor i).comp measurable_update').ennreal_toReal have hgm : Measurable g := ((M.toFactorization.measurable_factor i).comp measurable_fst).ennreal_toReal apply (Measure.ae_prod_iff_ae_ae (measurableSet_eq_fun hfm hgm)).2 filter_upwards [h] with x hx filter_upwards [hx] with xj hxj exact congrArg ENNReal.toReal hxj have hfg : f = g := (hf.ae_eq_iff_eq ((Measure.pi μ).prod (μ j)) hg).mp hae intro x xj apply (ENNReal.toReal_eq_toReal_iff' (M.factor_ne_top i (update x j xj)) (M.factor_ne_top i x)).mp exact congrFun hfg (x, xj)
    Causalean.Graph.FiniteDensity.CompactPositiveFactorization.factorIndependent_of_aeFactorIndependent · Causalean/Graph/FiniteDensity/Positive/Edge.lean:400
  • aeFactorIndependent_iff_factorIndependent theorem — Continuity and full support upgrade almost-everywhere independence of a local density factor from one coordinate to pointwise independence on the entire compact product domain.
    V :
    Type uV
    V → Type uX
    (i : V) → Measure (X i)
    DAG V
    shared
    M :
    shared
    i j :
    V
    M.AEFactorIndependentOf i j ↔ M.FactorIndependentOf i j
    Proof (Lean source)
    theorem aeFactorIndependent_iff_factorIndependent {i j : V} : M.AEFactorIndependentOf i j ↔ M.FactorIndependentOf i j := by exact ⟨M.factorIndependent_of_aeFactorIndependent, M.aeFactorIndependent_of_factorIndependent⟩
    Causalean.Graph.FiniteDensity.CompactPositiveFactorization.aeFactorIndependent_iff_factorIndependent · Causalean/Graph/FiniteDensity/Positive/Edge.lean:431
  • edge_condIndep_of_factorIndependent theorem — For an edge j → i, pointwise independence of the child's local factor from j implies conditional independence of the endpoints given the other parents.
    V :
    Type uV
    V → Type uX
    (i : V) → Measure (X i)
    DAG V
    shared
    M :
    shared
    i j :
    V
    hji :
    G.edge j i
    M.FactorIndependentOf i j
    M.CondIndepCoordinates i j ((G.parents i).erase j)
    Proof (Lean source)
    theorem edge_condIndep_of_factorIndependent {i j : V} (hji : G.edge j i) : M.FactorIndependentOf i j → M.CondIndepCoordinates i j ((G.parents i).erase j) := by /- Delete the single edge `j → i`, reuse the same normalized factors as a factorization of the resulting sub-DAG (the new locality obligation is exactly factor independence), and apply the ordered local-Markov theorem in that sub-DAG. Its parent set at `i` is `(G.parents i).erase j`; contract the predecessor residual to coordinate `j`. -/ intro hind classical let H : DAG V := { edge := fun u v ↦ G.edge u v ∧ ¬ (u = j ∧ v = i) decEdge := inferInstance acyclic := by intro v hv exact G.acyclic v ((Relation.TransGen.mono (r := fun u v ↦ G.edge u v ∧ ¬ (u = j ∧ v = i)) (p := G.edge) (fun _ _ h ↦ h.1)) v v hv) } let B : Factorization H X μ := { factor := M.toFactorization.factor measurable_factor := M.toFactorization.measurable_factor normalized_factor := M.toFactorization.normalized_factor local_factor := by intro k x y hxy by_cases hki : k = i · have hxyi : ∀ l, l ∈ insert i (H.parents i) → x l = y l := by intro l hl apply hxy l simpa only [hki] using hl have hi : M.toFactorization.factor i x = M.toFactorization.factor i y := by calc M.toFactorization.factor i x = M.toFactorization.factor i (update x j (y j)) := (hind x (y j)).symm _ = M.toFactorization.factor i y := by apply M.toFactorization.local_factor i intro l hl rcases Finset.mem_insert.mp hl with hli | hl · have hlj : l ≠ j := by intro h have hij : i ≠ j := fun hij ↦ G.irrefl i (hij ▸ hji) exact hij (hli.symm.trans h) rw [Function.update_of_ne hlj] exact hxyi l (Finset.mem_insert.mpr (inl hli)) · by_cases hlj : l = j · subst l simp · rw [Function.update_of_ne hlj] apply hxyi l apply mem_insert_of_mem rw [H.mem_parents] exact ⟨G.mem_parents.mp hl, fun h ↦ hlj h.1⟩ simpa only [hki] using hi · apply M.toFactorization.local_factor k intro l hl apply hxy l rcases Finset.mem_insert.mp hl with hl | hl · exact Finset.mem_insert.mpr (inl hl) · apply mem_insert_of_mem rw [H.mem_parents] refine ⟨G.mem_parents.mp hl, ?_⟩ rintro ⟨rfl, rfl⟩ exact hki rfl } let τG := canonicalTopologicalRanking G let τ : TopologicalRanking H := { rank := τG.rank injective_rank := τG.injective_rank edge_lt := fun h ↦ τG.edge_lt h.1 } let C := (G.parents i).erase j have hparents : H.parents i = C := by ext k simp only [H.mem_parents, C, G.mem_parents, Finset.mem_erase] constructor · rintro ⟨hk, hdel⟩ exact ⟨fun hkj ↦ hdel ⟨hkj, rfl⟩, hk⟩ · rintro ⟨hkj, hk⟩ exact ⟨hk, fun h ↦ hkj h.1⟩ have hCpred : C ⊆ predecessors τ i := by intro k hk rw [predecessors, mem_filter] exact ⟨Finset.mem_univ k, τG.edge_lt (G.mem_parents.mp (mem_of_mem_erase hk))⟩ have hmarkov := B.orderedLocalMarkov τ i C hCpred (by simpa [hparents]) have hjpred : j ∈ predecessors τ i := by rw [predecessors, mem_filter] exact ⟨Finset.mem_univ j, τG.edge_lt hji⟩ have hjC : j ∉ C := by simp [C] let e : (∀ k : ↑(predecessors τ i \ C), X k) → X j := fun z ↦ z ⟨j, Finset.mem_sdiff.mpr ⟨hjpred, hjC⟩⟩ have hcomp := hmarkov.comp measurable_id (measurable_pi_apply (⟨j, Finset.mem_sdiff.mpr ⟨hjpred, hjC⟩⟩ : ↑(predecessors τ i \ C))) have heval : e ∘ coordinateProjection (X := X) (predecessors τ i \ C) = fun x : ∀ k, X k ↦ x j := by funext x rfl rw [heval] at hcomp change CondIndepFun (comap (coordinateProjection (X := X) C) inferInstance) (coordinateConditioning_comap_le (X := X) C) (fun x : ∀ k, X k ↦ x i) (fun x : ∀ k, X k ↦ x j) M.observationalMeasure simp only [Function.id_comp] at hcomp have hmeasure : B.observationalMeasure = M.observationalMeasure := by rfl cases hmeasure exact hcomp
    Causalean.Graph.FiniteDensity.CompactPositiveFactorization.edge_condIndep_of_factorIndependent · Causalean/Graph/FiniteDensity/Positive/Edge.lean:438
  • edge_condIndep_of_aeFactorIndependent theorem — For an edge j → i, reference-almost-everywhere independence of the child's local factor from j implies conditional independence of the endpoints given the other parents.
    V :
    Type uV
    V → Type uX
    (i : V) → Measure (X i)
    DAG V
    shared
    M :
    shared
    i j :
    V
    hji :
    G.edge j i
    M.AEFactorIndependentOf i j
    M.CondIndepCoordinates i j ((G.parents i).erase j)
    Proof (Lean source)
    theorem edge_condIndep_of_aeFactorIndependent {i j : V} (hji : G.edge j i) : M.AEFactorIndependentOf i j → M.CondIndepCoordinates i j ((G.parents i).erase j) := by intro h exact M.edge_condIndep_of_factorIndependent hji (M.factorIndependent_of_aeFactorIndependent h)
    Causalean.Graph.FiniteDensity.CompactPositiveFactorization.edge_condIndep_of_aeFactorIndependent · Causalean/Graph/FiniteDensity/Positive/Edge.lean:545
  • edge_condIndep_iff_aeFactorIndependent theorem — For an edge j → i in a compact positive DAG density, conditional independence of i and j given the other parents is equivalent to reference-almost-everywhere independence of the child's local factor from j.
    V :
    Type uV
    V → Type uX
    (i : V) → Measure (X i)
    DAG V
    shared
    M :
    shared
    i j :
    V
    hji :
    G.edge j i
    M.CondIndepCoordinates i j ((G.parents i).erase j) ↔ M.AEFactorIndependentOf i j
    Proof (Lean source)
    theorem edge_condIndep_iff_aeFactorIndependent {i j : V} (hji : G.edge j i) : M.CondIndepCoordinates i j ((G.parents i).erase j) ↔ M.AEFactorIndependentOf i j := by exact ⟨M.aeFactorIndependent_of_edge_condIndep hji, M.edge_condIndep_of_aeFactorIndependent hji⟩
    Causalean.Graph.FiniteDensity.CompactPositiveFactorization.edge_condIndep_iff_aeFactorIndependent · Causalean/Graph/FiniteDensity/Positive/Edge.lean:554
  • localContrast_zero_of_factorIndependent theorem — Pointwise independence of a child's factor from a parent coordinate forces every associated four-point local cross-product contrast to vanish.
    V :
    Type uV
    V → Type uX
    (i : V) → Measure (X i)
    DAG V
    shared
    M :
    shared
    i j :
    V
    hji :
    G.edge j i
    M.FactorIndependentOf i j
    x :
    ∀ k, X k
    xi xi' :
    X i
    xj xj' :
    X j
    M.localContrast i j x xi xi' xj xj' = 0
    Proof (Lean source)
    theorem localContrast_zero_of_factorIndependent {i j : V} (hji : G.edge j i) : M.FactorIndependentOf i j → ∀ (x : ∀ k, X k) (xi xi' : X i) (xj xj' : X j), M.localContrast i j x xi xi' xj xj' = 0 := by /- Rewrite all four factor values to a fixed value of coordinate `j`; `hji` supplies `i ≠ j` so the own-coordinate update is not disturbed. -/ intro h x xi xi' xj xj' have hij : i ≠ j := by intro hij subst j exact G.irrefl i hji have hsection (z : X i) (w : X j) : M.toFactorization.factor i (update (update x j w) i z) = M.toFactorization.factor i (update x i z) := by rw [← Function.update_comm hij] exact h (update x i z) w unfold localContrast simp_rw [Function.update_comm hij] rw [hsection xi xj, hsection xi' xj', hsection xi xj', hsection xi' xj] ring
    Causalean.Graph.FiniteDensity.CompactPositiveFactorization.localContrast_zero_of_factorIndependent · Causalean/Graph/FiniteDensity/Positive/Edge.lean:571
  • factorIndependent_of_localContrast_zero theorem — If every four-point local cross-product contrast for an edge vanishes, normalization and strict positivity force the child's factor to be independent of that parent coordinate.
    V :
    Type uV
    V → Type uX
    (i : V) → Measure (X i)
    DAG V
    shared
    M :
    shared
    i j :
    V
    hji :
    G.edge j i
    (∀ (x : ∀ k, X k) (xi xi' : X i) (xj xj' : X j), M.localContrast i j x xi xi' xj xj' = 0)
    M.FactorIndependentOf i j
    Proof (Lean source)
    theorem factorIndependent_of_localContrast_zero {i j : V} (hji : G.edge j i) : (∀ (x : ∀ k, X k) (xi xi' : X i) (xj xj' : X j), M.localContrast i j x xi xi' xj xj' = 0) → M.FactorIndependentOf i j := by /- Fix the base assignment and the new `j` value. The contrast equations say the two positive own-coordinate density sections are proportional. Integrate the equations in the second own-coordinate variable and use `normalized_factor` twice; the proportionality constant is one. Finiteness reflects the real calculation back to `ENNReal`. -/ intro h x xj have hij : i ≠ j := by intro hij subst j exact G.irrefl i hji let a : X i → ℝ≥0∞ := fun z ↦ M.toFactorization.factor i (update (update x j xj) i z) let b : X i → ℝ≥0∞ := fun z ↦ M.toFactorization.factor i (update x i z) have ha_meas : Measurable a := (M.toFactorization.measurable_factor i).comp (measurable_update (update x j xj)) have hb_meas : Measurable b := (M.toFactorization.measurable_factor i).comp (measurable_update x) have hab (z w : X i) : a z * b w = b z * a w := by apply (ENNReal.toReal_eq_toReal_iff' (ENNReal.mul_ne_top (M.factor_ne_top i (update (update x j xj) i z)) (M.factor_ne_top i (update x i w))) (ENNReal.mul_ne_top (M.factor_ne_top i (update x i z)) (M.factor_ne_top i (update (update x j xj) i w)))).mp rw [ENNReal.toReal_mul, ENNReal.toReal_mul] apply sub_eq_zero.mp simpa [localContrast, a, b, Function.update_comm hij] using h x z w xj (x j) have ha_norm : ∫⁻ z, a z ∂μ i = 1 := by exact M.toFactorization.normalized_factor i (update x j xj) have hb_norm : ∫⁻ z, b z ∂μ i = 1 := by exact M.toFactorization.normalized_factor i x have hab_eq (z : X i) : a z = b z := by have hint : a z * (∫⁻ w, b w ∂μ i) = b z * (∫⁻ w, a w ∂μ i) := by calc a z * (∫⁻ w, b w ∂μ i) = ∫⁻ w, a z * b w ∂μ i := by exact (lintegral_const_mul (a z) hb_meas).symm _ = ∫⁻ w, b z * a w ∂μ i := lintegral_congr (hab z) _ = b z * (∫⁻ w, a w ∂μ i) := by exact lintegral_const_mul (b z) ha_meas simpa [ha_norm, hb_norm] using hint have hz := hab_eq (x i) change M.toFactorization.factor i (update (update x j xj) i (x i)) = M.toFactorization.factor i (update x i (x i)) at hz rw [Function.update_eq_self] at hz have hcoord : update x j xj i = x i := Function.update_of_ne hij _ _ rw [← hcoord, Function.update_eq_self] at hz exact hz
    Causalean.Graph.FiniteDensity.CompactPositiveFactorization.factorIndependent_of_localContrast_zero · Causalean/Graph/FiniteDensity/Positive/Edge.lean:595
  • factorIndependent_iff_localContrast_zero theorem — For an edge j → i, pointwise independence of the child's factor from j is equivalent to vanishing of all its local four-point cross-product contrasts.
    V :
    Type uV
    V → Type uX
    (i : V) → Measure (X i)
    DAG V
    shared
    M :
    shared
    i j :
    V
    hji :
    G.edge j i
    M.FactorIndependentOf i j
    ↔ ∀ (x : ∀ k, X k) (xi xi' : X i) (xj xj' : X j), M.localContrast i j x xi xi' xj xj' = 0
    Proof (Lean source)
    theorem factorIndependent_iff_localContrast_zero {i j : V} (hji : G.edge j i) : M.FactorIndependentOf i j ↔ ∀ (x : ∀ k, X k) (xi xi' : X i) (xj xj' : X j), M.localContrast i j x xi xi' xj xj' = 0 := by exact ⟨M.localContrast_zero_of_factorIndependent hji, M.factorIndependent_of_localContrast_zero hji⟩
    Causalean.Graph.FiniteDensity.CompactPositiveFactorization.factorIndependent_iff_localContrast_zero · Causalean/Graph/FiniteDensity/Positive/Edge.lean:654
  • edge_condIndep_iff_localContrast_zero theorem — For an edge j → i, conditional independence given the other parents is equivalent to vanishing of every local factor cross-product contrast.
    V :
    Type uV
    V → Type uX
    (i : V) → Measure (X i)
    DAG V
    shared
    M :
    shared
    i j :
    V
    hji :
    G.edge j i
    M.CondIndepCoordinates i j ((G.parents i).erase j)
    ↔ ∀ (x : ∀ k, X k) (xi xi' : X i) (xj xj' : X j), M.localContrast i j x xi xi' xj xj' = 0
    Proof (Lean source)
    theorem edge_condIndep_iff_localContrast_zero {i j : V} (hji : G.edge j i) : M.CondIndepCoordinates i j ((G.parents i).erase j) ↔ ∀ (x : ∀ k, X k) (xi xi' : X i) (xj xj' : X j), M.localContrast i j x xi xi' xj xj' = 0 := by exact (M.edge_condIndep_iff_factorIndependent hji).trans (M.factorIndependent_iff_localContrast_zero hji)
    Causalean.Graph.FiniteDensity.CompactPositiveFactorization.edge_condIndep_iff_localContrast_zero · Causalean/Graph/FiniteDensity/Positive/Edge.lean:663
Examples 2 core · 0 supporting This module exercises the two reusable APIs on a binary two-node DAG and on the scalar pair q(x) = exp(x), p(x) = 1 over the unit interval.

Examples for positive-mechanism stratum openness

This module exercises the two reusable APIs on a binary two-node DAG and on the scalar pair q(x) = exp(x), p(x) = 1 over the unit interval.

def binaryEdgeDAG reviewed
Causalean.Graph.FiniteDensity

The two-node DAG has the single directed edge 0 → 1.

Definition (Lean source)
binaryEdgeDAG :
DAG (Fin 2)
clause 1
edge i j := i = 0 ∧ j = 1
clause 2
decEdge := inferInstance
clause 3
acyclic := by apply DAG.acyclic_of_topoOrder (r := (· < ·)) (τ := fun i : Fin 2 ↦ i.val) rintro u v ⟨rfl, rfl⟩ norm_num
Causalean.Graph.FiniteDensity.binaryEdgeDAG · Causalean/Graph/FiniteDensity/Positive/Examples.lean:20 · uses DAG
def binaryMechanism reviewed
Causalean.Graph.FiniteDensity

The binary example has a fair root and a child which matches its parent with probability three quarters.

Definition (Lean source)
binaryMechanism :
clause 1
factor i x := if i
= 0 then (1 / 2 : ℝ) else if x 1 = x 0 then (3 / 4 : ℝ) else (1 / 4 : ℝ)
clause 2
factor_pos := by intro i x split_ifs <;> norm_num
clause 3
factor_normalized := by intro i x fin_cases i · simp · cases h : x 0 <;> simp [h] <;> norm_num
clause 4
factor_local := by intro i x y hxy fin_cases i · simp · have h0 : x 0
= y 0 := hxy 0 (by simp [binaryEdgeDAG, DAG.mem_parents]) have h1 : x 1 = y 1 := hxy 1 (by simp) simp [h0, h1]
Finite­Witness 3 core · 2 supporting This module packages nonzero finite-state local contrasts and proves that their nonvanishing, and therefore edgewise conditional dependence, persists throughout one uniform factor neighborhood. ★ all_edge_witnesses_open

Stable finite-state DAG edge witnesses

This module packages nonzero finite-state local contrasts and proves that their nonvanishing, and therefore edgewise conditional dependence, persists throughout one uniform factor neighborhood.

structure EdgeWitness reviewed
Causalean.Graph.FiniteDensity.PositiveFiniteDAGMechanism

A local edge witness records four coordinate values at which the child's cross-product contrast is nonzero.

Definition (Lean source)
V :
Type uV
shared
X :
V → Type uX
shared
G :
DAG V
shared
i j :
V
The common assignment fixing every coordinate not explicitly varied by the witness.
base :
∀ k, X k
The first child-coordinate value.
child₀ :
X i
The second child-coordinate value.
child₁ :
X i
The first parent-coordinate value.
parent₀ :
X j
The second parent-coordinate value.
parent₁ :
X j
The displayed factor contrast is nonzero.
nonzero :
M.localContrast i j base child₀ child₁ parent₀ parent₁ ≠ 0
Causalean.Graph.FiniteDensity.PositiveFiniteDAGMechanism.EdgeWitness · Causalean/Graph/FiniteDensity/Positive/FiniteWitness.lean:30 · uses DAG , PositiveFiniteDAGMechanism
def FactorSupClose reviewed
Causalean.Graph.FiniteDensity.PositiveFiniteDAGMechanism

Two finite DAG mechanisms are uniformly factor-close when every local factor differs by less than the prescribed radius at every full assignment.

Definition (Lean source)
V :
Type uV
V → Type uX
DAG V
shared
ε :
i x :
FactorSupClose M N ε :
Prop
|N.factor i x - M.factor i x| < ε
Causalean.Graph.FiniteDensity.PositiveFiniteDAGMechanism.FactorSupClose · Causalean/Graph/FiniteDensity/Positive/FiniteWitness.lean:55 · uses DAG , PositiveFiniteDAGMechanism
theorem all_edge_witnesses_open reviewed
Causalean.Graph.FiniteDensity.PositiveFiniteDAGMechanism

A positive finite-state DAG mechanism and a nonzero local-contrast witness for each directed edge have one positive uniform factor neighborhood in which all edge conditional dependences persist.

Formal statement
V :
Type uV
V → Type uX
DAG V
shared
w :
∀ i j
if
G.edge j i
then
M.EdgeWitness i j
∃ ε > 0,
M.FactorSupClose N ε → ∀ i j (hji : G.edge j i), ¬ N.CondIndepCoordinates i j ((G.parents i).erase j)
Proof (Lean source)
theorem all_edge_witnesses_open (w : ∀ i j, G.edge j i → M.EdgeWitness i j) : ∃ ε > 0, ∀ N : PositiveFiniteDAGMechanism G X, M.FactorSupClose N ε → ∀ i j (hji : G.edge j i), ¬ N.CondIndepCoordinates i j ((G.parents i).erase j) := by classical cases isEmpty_or_nonempty V with | inl hV => letI := hV refine ⟨1, zero_lt_one, ?_⟩ intro N hclose i exact isEmptyElim i | inr hV => letI := hV let radius : V × V → ℝ := fun p ↦ if hp : G.edge p.2 p.1 then choose (EdgeWitness.eventually_nonzero M (w p.1 p.2 hp)) else 1 have hradius_pos (p : V × V) : 0 < radius p := by by_cases hp : G.edge p.2 p.1 · simp only [radius, dif_pos hp] exact (Classical.choose_spec (EdgeWitness.eventually_nonzero M (w p.1 p.2 hp))).1 · simp [radius, hp] have hradius_spec (i j : V) (hji : G.edge j i) : ∀ N : PositiveFiniteDAGMechanism G X, M.FactorSupClose N (radius (i, j)) → N.localContrast i j (w i j hji).base (w i j hji).child₀ (w i j hji).child₁ (w i j hji).parent₀ (w i j hji).parent₁ ≠ 0 := by simp only [radius, dif_pos hji] exact (Classical.choose_spec (EdgeWitness.eventually_nonzero M (w i j hji))).2 let ε := Finset.univ.inf' Finset.univ_nonempty radius have hε : 0 < ε := by exact (Finset.lt_inf'_iff Finset.univ_nonempty).2 fun p _ ↦ hradius_pos p refine ⟨ε, hε, ?_⟩ intro N hclose i j hji let wN : N.EdgeWitness i j := { base := (w i j hji).base child₀ := (w i j hji).child₀ child₁ := (w i j hji).child₁ parent₀ := (w i j hji).parent₀ parent₁ := (w i j hji).parent₁ nonzero := hradius_spec i j hji N (fun k x ↦ (hclose k x).trans_le (Finset.inf'_le radius (Finset.mem_univ (i, j)))) } exact EdgeWitness.not_condIndep N hji wN
2 supporting declarations (lemmas, instances)
  • not_condIndep theorem — A nonzero local factor contrast on an edge proves failure of conditional independence of the edge endpoints given the child's other parents.
    V :
    Type uV
    V → Type uX
    DAG V
    shared
    i j :
    V
    hji :
    G.edge j i
    w :
    M.EdgeWitness i j
    ¬ M.CondIndepCoordinates i j ((G.parents i).erase j)
    Proof (Lean source)
    theorem EdgeWitness.not_condIndep {i j : V} (hji : G.edge j i) (w : M.EdgeWitness i j) : ¬ M.CondIndepCoordinates i j ((G.parents i).erase j) := by intro hCI exact w.nonzero ((M.edge_condIndep_iff_localContrast_zero hji).mp hCI w.base w.child₀ w.child₁ w.parent₀ w.parent₁)
    Causalean.Graph.FiniteDensity.PositiveFiniteDAGMechanism.EdgeWitness.not_condIndep · Causalean/Graph/FiniteDensity/Positive/FiniteWitness.lean:46
  • eventually_nonzero theorem — A fixed nonzero local contrast remains nonzero for every sufficiently small uniform perturbation of all local factors.
    V :
    Type uV
    V → Type uX
    DAG V
    shared
    i j :
    V
    w :
    M.EdgeWitness i j
    ∃ ε > 0,
    M.FactorSupClose N ε → N.localContrast i j w.base w.child₀ w.child₁ w.parent₀ w.parent₁
    ≠ 0
    Proof (Lean source)
    theorem EdgeWitness.eventually_nonzero {i j : V} (w : M.EdgeWitness i j) : ∃ ε > 0, ∀ N : PositiveFiniteDAGMechanism G X, M.FactorSupClose N ε → N.localContrast i j w.base w.child₀ w.child₁ w.parent₀ w.parent₁ ≠ 0 := by let a : Fin 4 → ℝ := ![ M.factor i (update (update w.base i w.child₀) j w.parent₀), M.factor i (update (update w.base i w.child₁) j w.parent₁), M.factor i (update (update w.base i w.child₀) j w.parent₁), M.factor i (update (update w.base i w.child₁) j w.parent₀)] let q : (Fin 4 → ℝ) → ℝ := fun z ↦ z 0 * z 1 - z 2 * z 3 have hqa : q a ≠ 0 := by simpa [q, a, localContrast] using w.nonzero have hq : Continuous q := by unfold q fun_prop have hne : {z | q z ≠ 0} ∈ nhds a := hq.continuousAt.eventually_ne hqa rcases Metric.mem_nhds_iff.mp hne with ⟨ε, hε, hball⟩ refine ⟨ε, hε, ?_⟩ intro N hclose let b : Fin 4 → ℝ := ![ N.factor i (update (update w.base i w.child₀) j w.parent₀), N.factor i (update (update w.base i w.child₁) j w.parent₁), N.factor i (update (update w.base i w.child₀) j w.parent₁), N.factor i (update (update w.base i w.child₁) j w.parent₀)] have hba : dist b a < ε := by rw [dist_pi_lt_iff hε] intro k fin_cases k · simpa [b, a, Real.dist_eq] using hclose i (update (update w.base i w.child₀) j w.parent₀) · simpa [b, a, Real.dist_eq] using hclose i (update (update w.base i w.child₁) j w.parent₁) · simpa [b, a, Real.dist_eq] using hclose i (update (update w.base i w.child₀) j w.parent₁) · simpa [b, a, Real.dist_eq] using hclose i (update (update w.base i w.child₁) j w.parent₀) have hqb : q b ≠ 0 := hball (Metric.mem_ball.mpr hba) simpa [q, b, localContrast] using hqb
    Causalean.Graph.FiniteDensity.PositiveFiniteDAGMechanism.EdgeWitness.eventually_nonzero · Causalean/Graph/FiniteDensity/Positive/FiniteWitness.lean:60
Witness 3 core · 2 supporting This module packages nonzero four-point local-factor contrasts as witnesses that an edge is not conditionally independent given the other parents, and proves that finitely many such witnesses persist under one uniform fa ★ all_edge_witnesses_open

Stable contrast witnesses for compact positive DAG densities

This module packages nonzero four-point local-factor contrasts as witnesses that an edge is not conditionally independent given the other parents, and proves that finitely many such witnesses persist under one uniform factor neighborhood.

structure EdgeWitness reviewed
Causalean.Graph.FiniteDensity.CompactPositiveFactorization

A compact-density edge witness records four domain points at which the child's local cross-product contrast is nonzero.

Definition (Lean source)
V :
Type uV
shared
X :
V → Type uX
shared
μ :
(i : V) → Measure (X i)
shared
G :
DAG V
shared
M :
shared
i j :
V
The assignment fixing coordinates not explicitly varied by the witness.
base :
∀ k, X k
The first child value.
child₀ :
X i
The second child value.
child₁ :
X i
The first parent value.
parent₀ :
X j
The second parent value.
parent₁ :
X j
The resulting local contrast is nonzero.
nonzero :
M.localContrast i j base child₀ child₁ parent₀ parent₁ ≠ 0
Causalean.Graph.FiniteDensity.CompactPositiveFactorization.EdgeWitness · Causalean/Graph/FiniteDensity/Positive/Witness.lean:34 · uses DAG , CompactPositiveFactorization
def FactorSupClose reviewed
Causalean.Graph.FiniteDensity.CompactPositiveFactorization

Two compact positive mechanisms are uniformly close when the real values of all local density factors differ by less than one common radius over every node and domain point.

Definition (Lean source)
V :
Type uV
V → Type uX
(i : V) → Measure (X i)
DAG V
shared
M :
shared
ε :
i x :
FactorSupClose M N ε :
Prop
|(N.toFactorization.factor i x).toReal - (M.toFactorization.factor i x).toReal| < ε
Causalean.Graph.FiniteDensity.CompactPositiveFactorization.FactorSupClose · Causalean/Graph/FiniteDensity/Positive/Witness.lean:59 · uses DAG , CompactPositiveFactorization
theorem all_edge_witnesses_open reviewed
Causalean.Graph.FiniteDensity.CompactPositiveFactorization

A compact positive factorization and a nonzero local-contrast witness for each directed edge have one positive uniform factor neighborhood in which every edge remains conditionally dependent given its other parents.

Formal statement
V :
Type uV
V → Type uX
(i : V) → Measure (X i)
DAG V
shared
M :
shared
w :
∀ i j
if
G.edge j i
then
M.EdgeWitness i j
∃ ε > 0,
M.FactorSupClose N ε → ∀ i j (hji : G.edge j i), ¬ N.CondIndepCoordinates i j ((G.parents i).erase j)
Proof (Lean source)
theorem all_edge_witnesses_open (w : ∀ i j, G.edge j i → M.EdgeWitness i j) : ∃ ε > 0, ∀ N : CompactPositiveFactorization G X μ, M.FactorSupClose N ε → ∀ i j (hji : G.edge j i), ¬ N.CondIndepCoordinates i j ((G.parents i).erase j) := by classical cases isEmpty_or_nonempty V with | inl hV => letI := hV refine ⟨1, zero_lt_one, ?_⟩ intro N hclose i exact isEmptyElim i | inr hV => letI := hV let radius : V × V → ℝ := fun p ↦ if hp : G.edge p.2 p.1 then choose (EdgeWitness.eventually_not_condIndep M hp (w p.1 p.2 hp)) else 1 have hradius_pos (p : V × V) : 0 < radius p := by by_cases hp : G.edge p.2 p.1 · simp only [radius, dif_pos hp] exact (Classical.choose_spec (EdgeWitness.eventually_not_condIndep M hp (w p.1 p.2 hp))).1 · simp [radius, hp] have hradius_spec (i j : V) (hji : G.edge j i) : ∀ N : CompactPositiveFactorization G X μ, M.FactorSupClose N (radius (i, j)) → ¬ N.CondIndepCoordinates i j ((G.parents i).erase j) := by simp only [radius, dif_pos hji] exact (Classical.choose_spec (EdgeWitness.eventually_not_condIndep M hji (w i j hji))).2 let ε := Finset.univ.inf' Finset.univ_nonempty radius have hε : 0 < ε := by exact (Finset.lt_inf'_iff Finset.univ_nonempty).2 fun p _ ↦ hradius_pos p refine ⟨ε, hε, ?_⟩ intro N hclose i j hji apply hradius_spec i j hji N intro k x exact (hclose k x).trans_le (Finset.inf'_le radius (Finset.mem_univ (i, j)))
2 supporting declarations (lemmas, instances)
  • not_condIndep theorem — A nonzero local factor contrast on an edge rules out conditional independence of the edge endpoints given the other parents.
    V :
    Type uV
    V → Type uX
    (i : V) → Measure (X i)
    DAG V
    shared
    M :
    shared
    i j :
    V
    hji :
    G.edge j i
    w :
    M.EdgeWitness i j
    ¬ M.CondIndepCoordinates i j ((G.parents i).erase j)
    Proof (Lean source)
    theorem EdgeWitness.not_condIndep {i j : V} (hji : G.edge j i) (w : M.EdgeWitness i j) : ¬ M.CondIndepCoordinates i j ((G.parents i).erase j) := by intro hCI exact w.nonzero ((M.edge_condIndep_iff_localContrast_zero hji).mp hCI w.base w.child₀ w.child₁ w.parent₀ w.parent₁)
    Causalean.Graph.FiniteDensity.CompactPositiveFactorization.EdgeWitness.not_condIndep · Causalean/Graph/FiniteDensity/Positive/Witness.lean:50
  • eventually_not_condIndep theorem — A fixed nonzero compact-domain contrast remains a nonzero witness, and hence continues to rule out edge conditional independence, throughout a sufficiently small uniform neighborhood.
    V :
    Type uV
    V → Type uX
    (i : V) → Measure (X i)
    DAG V
    shared
    M :
    shared
    i j :
    V
    hji :
    G.edge j i
    w :
    M.EdgeWitness i j
    ∃ ε > 0,
    M.FactorSupClose N ε → ¬ N.CondIndepCoordinates i j ((G.parents i).erase j)
    Proof (Lean source)
    theorem EdgeWitness.eventually_not_condIndep {i j : V} (hji : G.edge j i) (w : M.EdgeWitness i j) : ∃ ε > 0, ∀ N : CompactPositiveFactorization G X μ, M.FactorSupClose N ε → ¬ N.CondIndepCoordinates i j ((G.parents i).erase j) := by let a : Fin 4 → ℝ := ![ (M.toFactorization.factor i (update (update w.base i w.child₀) j w.parent₀)).toReal, (M.toFactorization.factor i (update (update w.base i w.child₁) j w.parent₁)).toReal, (M.toFactorization.factor i (update (update w.base i w.child₀) j w.parent₁)).toReal, (M.toFactorization.factor i (update (update w.base i w.child₁) j w.parent₀)).toReal] let q : (Fin 4 → ℝ) → ℝ := fun z ↦ z 0 * z 1 - z 2 * z 3 have hqa : q a ≠ 0 := by simpa [q, a, localContrast] using w.nonzero have hq : Continuous q := by unfold q fun_prop have hne : {z | q z ≠ 0} ∈ nhds a := hq.continuousAt.eventually_ne hqa rcases Metric.mem_nhds_iff.mp hne with ⟨ε, hε, hball⟩ refine ⟨ε, hε, ?_⟩ intro N hclose let b : Fin 4 → ℝ := ![ (N.toFactorization.factor i (update (update w.base i w.child₀) j w.parent₀)).toReal, (N.toFactorization.factor i (update (update w.base i w.child₁) j w.parent₁)).toReal, (N.toFactorization.factor i (update (update w.base i w.child₀) j w.parent₁)).toReal, (N.toFactorization.factor i (update (update w.base i w.child₁) j w.parent₀)).toReal] have hba : dist b a < ε := by rw [dist_pi_lt_iff hε] intro k fin_cases k · simpa [b, a, Real.dist_eq] using hclose i (update (update w.base i w.child₀) j w.parent₀) · simpa [b, a, Real.dist_eq] using hclose i (update (update w.base i w.child₁) j w.parent₁) · simpa [b, a, Real.dist_eq] using hclose i (update (update w.base i w.child₀) j w.parent₁) · simpa [b, a, Real.dist_eq] using hclose i (update (update w.base i w.child₁) j w.parent₀) have hqb : q b ≠ 0 := hball (Metric.mem_ball.mpr hba) let wN : N.EdgeWitness i j := { base := w.base child₀ := w.child₀ child₁ := w.child₁ parent₀ := w.parent₀ parent₁ := w.parent₁ nonzero := by simpa [q, b, localContrast] using hqb } exact EdgeWitness.not_condIndep N hji wN
    Causalean.Graph.FiniteDensity.CompactPositiveFactorization.EdgeWitness.eventually_not_condIndep · Causalean/Graph/FiniteDensity/Positive/Witness.lean:66