l3lab/ntp-mathlib huggingface dataset:
@[simp] theorem lmarginal_univ [Fintype δ] {f : (∀ i, π i) → ℝ≥0∞} :
    ∫⋯∫⁻_univ, f ∂μ = fun _ => ∫⁻ x, f x ∂Measure.pi μ := by
  

Proof state:
δ : Type u_1
δ' : Type u_2
π : δ → Type u_3
inst✝³ : (x : δ) → MeasurableSpace (π x)
μ : (i : δ) → Measure (π i)
inst✝² : ∀ (i : δ), SigmaFinite (μ i)
inst✝¹ : DecidableEq δ
s t : Finset δ
f✝ g : ((i : δ) → π i) → ℝ≥0∞
x y : (i : δ) → π i
i : δ
inst✝ : Fintype δ
f : ((i : δ) → π i) → ℝ≥0∞
⊢ ∫⋯∫⁻_Finset.univ, f ∂μ = fun x => ∫⁻ (x : (i : δ) → π i), f x ∂Measure.pi μ

Next tactic:
let e : { j // j ∈ Finset.univ } ≃ δ := Equiv.subtypeUnivEquiv mem_univ
@[simp] theorem lmarginal_univ [Fintype δ] {f : (∀ i, π i) → ℝ≥0∞} :
    ∫⋯∫⁻_univ, f ∂μ = fun _ => ∫⁻ x, f x ∂Measure.pi μ := by
  let e : { j // j ∈ Finset.univ } ≃ δ := Equiv.subtypeUnivEquiv mem_univ
  

Proof state:
δ : Type u_1
δ' : Type u_2
π : δ → Type u_3
inst✝³ : (x : δ) → MeasurableSpace (π x)
μ : (i : δ) → Measure (π i)
inst✝² : ∀ (i : δ), SigmaFinite (μ i)
inst✝¹ : DecidableEq δ
s t : Finset δ
f✝ g : ((i : δ) → π i) → ℝ≥0∞
x y : (i : δ) → π i
i : δ
inst✝ : Fintype δ
f : ((i : δ) → π i) → ℝ≥0∞
e : { j // j ∈ Finset.univ } ≃ δ := subtypeUnivEquiv (_ : ∀ (x : δ), x ∈ Finset.univ)
⊢ ∫⋯∫⁻_Finset.univ, f ∂μ = fun x => ∫⁻ (x : (i : δ) → π i), f x ∂Measure.pi μ

Next tactic:
ext1 x
@[simp] theorem lmarginal_univ [Fintype δ] {f : (∀ i, π i) → ℝ≥0∞} :
    ∫⋯∫⁻_univ, f ∂μ = fun _ => ∫⁻ x, f x ∂Measure.pi μ := by
  let e : { j // j ∈ Finset.univ } ≃ δ := Equiv.subtypeUnivEquiv mem_univ
  ext1 x
  

Proof state:
case h
δ : Type u_1
δ' : Type u_2
π : δ → Type u_3
inst✝³ : (x : δ) → MeasurableSpace (π x)
μ : (i : δ) → Measure (π i)
inst✝² : ∀ (i : δ), SigmaFinite (μ i)
inst✝¹ : DecidableEq δ
s t : Finset δ
f✝ g : ((i : δ) → π i) → ℝ≥0∞
x✝ y : (i : δ) → π i
i : δ
inst✝ : Fintype δ
f : ((i : δ) → π i) → ℝ≥0∞
e : { j // j ∈ Finset.univ } ≃ δ := subtypeUnivEquiv (_ : ∀ (x : δ), x ∈ Finset.univ)
x : (i : δ) → π i
⊢ (∫⋯∫⁻_Finset.univ, f ∂μ) x = ∫⁻ (x : (i : δ) → π i), f x ∂Measure.pi μ

Next tactic:
simp_rw [lmarginal, measurePreserving_piCongrLeft μ e |>.lintegral_map_equiv, updateFinset_def]
@[simp] theorem lmarginal_univ [Fintype δ] {f : (∀ i, π i) → ℝ≥0∞} :
    ∫⋯∫⁻_univ, f ∂μ = fun _ => ∫⁻ x, f x ∂Measure.pi μ := by
  let e : { j // j ∈ Finset.univ } ≃ δ := Equiv.subtypeUnivEquiv mem_univ
  ext1 x
  simp_rw [lmarginal, measurePreserving_piCongrLeft μ e |>.lintegral_map_equiv, updateFinset_def]
  

Proof state:
case h
δ : Type u_1
δ' : Type u_2
π : δ → Type u_3
inst✝³ : (x : δ) → MeasurableSpace (π x)
μ : (i : δ) → Measure (π i)
inst✝² : ∀ (i : δ), SigmaFinite (μ i)
inst✝¹ : DecidableEq δ
s t : Finset δ
f✝ g : ((i : δ) → π i) → ℝ≥0∞
x✝ y : (i : δ) → π i
i : δ
inst✝ : Fintype δ
f : ((i : δ) → π i) → ℝ≥0∞
e : { j // j ∈ Finset.univ } ≃ δ := subtypeUnivEquiv (_ : ∀ (x : δ), x ∈ Finset.univ)
x : (i : δ) → π i
⊢ (∫⁻ (y : (i : { x // x ∈ Finset.univ }) → π ↑i),
      f fun i => if hi : i ∈ Finset.univ then y { val := i, property := hi } else x i ∂Measure.pi fun i => μ ↑i) =
    ∫⁻ (a : (b : { j // j ∈ Finset.univ }) → π ((subtypeUnivEquiv (_ : ∀ (x : δ), x ∈ Finset.univ)) b)),
      f
        ((MeasurableEquiv.piCongrLeft (fun i => π i) (subtypeUnivEquiv (_ : ∀ (x : δ), x ∈ Finset.univ)))
          a) ∂Measure.pi fun i' => μ ((subtypeUnivEquiv (_ : ∀ (x : δ), x ∈ Finset.univ)) i')

Next tactic:
simp
@[simp] theorem lmarginal_univ [Fintype δ] {f : (∀ i, π i) → ℝ≥0∞} :
    ∫⋯∫⁻_univ, f ∂μ = fun _ => ∫⁻ x, f x ∂Measure.pi μ := by
  let e : { j // j ∈ Finset.univ } ≃ δ := Equiv.subtypeUnivEquiv mem_univ
  ext1 x
  simp_rw [lmarginal, measurePreserving_piCongrLeft μ e |>.lintegral_map_equiv, updateFinset_def]
  simp
  

Proof state:
case h
δ : Type u_1
δ' : Type u_2
π : δ → Type u_3
inst✝³ : (x : δ) → MeasurableSpace (π x)
μ : (i : δ) → Measure (π i)
inst✝² : ∀ (i : δ), SigmaFinite (μ i)
inst✝¹ : DecidableEq δ
s t : Finset δ
f✝ g : ((i : δ) → π i) → ℝ≥0∞
x✝ y : (i : δ) → π i
i : δ
inst✝ : Fintype δ
f : ((i : δ) → π i) → ℝ≥0∞
e : { j // j ∈ Finset.univ } ≃ δ := subtypeUnivEquiv (_ : ∀ (x : δ), x ∈ Finset.univ)
x : (i : δ) → π i
⊢ (∫⁻ (y : (i : { x // x ∈ Finset.univ }) → π ↑i),
      f fun i => y { val := i, property := (_ : i ∈ Finset.univ) } ∂Measure.pi fun i => μ ↑i) =
    ∫⁻ (a : (b : { j // j ∈ Finset.univ }) → π ↑b),
      f
        ((MeasurableEquiv.piCongrLeft (fun i => π i) (subtypeUnivEquiv (_ : ∀ (x : δ), x ∈ Finset.univ)))
          a) ∂Measure.pi fun i => μ ↑i

Next tactic:
rfl
theorem lintegral_eq_lmarginal_univ [Fintype δ] {f : (∀ i, π i) → ℝ≥0∞} (x : ∀ i, π i) :
    ∫⁻ x, f x ∂Measure.pi μ = (∫⋯∫⁻_univ, f ∂μ) x := by 

Proof state:
δ : Type u_1
δ' : Type u_2
π : δ → Type u_3
inst✝³ : (x : δ) → MeasurableSpace (π x)
μ : (i : δ) → Measure (π i)
inst✝² : ∀ (i : δ), SigmaFinite (μ i)
inst✝¹ : DecidableEq δ
s t : Finset δ
f✝ g : ((i : δ) → π i) → ℝ≥0∞
x✝ y : (i : δ) → π i
i : δ
inst✝ : Fintype δ
f : ((i : δ) → π i) → ℝ≥0∞
x : (i : δ) → π i
⊢ ∫⁻ (x : (i : δ) → π i), f x ∂Measure.pi μ = (∫⋯∫⁻_Finset.univ, f ∂μ) x

Next tactic:
simp
theorem lmarginal_image [DecidableEq δ'] {e : δ' → δ} (he : Injective e) (s : Finset δ')
    {f : (∀ i, π (e i)) → ℝ≥0∞} (hf : Measurable f) (x : ∀ i, π i) :
      (∫⋯∫⁻_s.image e, f ∘ (· ∘' e) ∂μ) x = (∫⋯∫⁻_s, f ∂μ ∘' e) (x ∘' e) := by
  

Proof state:
δ : Type u_1
δ' : Type u_2
π : δ → Type u_3
inst✝³ : (x : δ) → MeasurableSpace (π x)
μ : (i : δ) → Measure (π i)
inst✝² : ∀ (i : δ), SigmaFinite (μ i)
inst✝¹ : DecidableEq δ
s✝ t : Finset δ
f✝ g : ((i : δ) → π i) → ℝ≥0∞
x✝ y : (i : δ) → π i
i : δ
inst✝ : DecidableEq δ'
e : δ' → δ
he : Injective e
s : Finset δ'
f : ((i : δ') → π (e i)) → ℝ≥0∞
hf : Measurable f
x : (i : δ) → π i
⊢ (∫⋯∫⁻_Finset.image e s, f ∘ fun x => (fun {x_1} => x) ∘' e ∂μ) x =
    (∫⋯∫⁻_s, f ∂(fun {x} => μ) ∘' e) ((fun {x_1} => x) ∘' e)

Next tactic:
have h : Measurable ((· ∘' e) : (∀ i, π i) → _) :=
    measurable_pi_iff.mpr <| λ i ↦ measurable_pi_apply (e i)
theorem lmarginal_image [DecidableEq δ'] {e : δ' → δ} (he : Injective e) (s : Finset δ')
    {f : (∀ i, π (e i)) → ℝ≥0∞} (hf : Measurable f) (x : ∀ i, π i) :
      (∫⋯∫⁻_s.image e, f ∘ (· ∘' e) ∂μ) x = (∫⋯∫⁻_s, f ∂μ ∘' e) (x ∘' e) := by
  have h : Measurable ((· ∘' e) : (∀ i, π i) → _) :=
    measurable_pi_iff.mpr <| λ i ↦ measurable_pi_apply (e i)
  

Proof state:
δ : Type u_1
δ' : Type u_2
π : δ → Type u_3
inst✝³ : (x : δ) → MeasurableSpace (π x)
μ : (i : δ) → Measure (π i)
inst✝² : ∀ (i : δ), SigmaFinite (μ i)
inst✝¹ : DecidableEq δ
s✝ t : Finset δ
f✝ g : ((i : δ) → π i) → ℝ≥0∞
x✝ y : (i : δ) → π i
i : δ
inst✝ : DecidableEq δ'
e : δ' → δ
he : Injective e
s : Finset δ'
f : ((i : δ') → π (e i)) → ℝ≥0∞
hf : Measurable f
x : (i : δ) → π i
h : Measurable fun x => (fun {x_1} => x) ∘' e
⊢ (∫⋯∫⁻_Finset.image e s, f ∘ fun x => (fun {x_1} => x) ∘' e ∂μ) x =
    (∫⋯∫⁻_s, f ∂(fun {x} => μ) ∘' e) ((fun {x_1} => x) ∘' e)

Next tactic:
induction s using Finset.induction generalizing x
theorem lmarginal_image [DecidableEq δ'] {e : δ' → δ} (he : Injective e) (s : Finset δ')
    {f : (∀ i, π (e i)) → ℝ≥0∞} (hf : Measurable f) (x : ∀ i, π i) :
      (∫⋯∫⁻_s.image e, f ∘ (· ∘' e) ∂μ) x = (∫⋯∫⁻_s, f ∂μ ∘' e) (x ∘' e) := by
  have h : Measurable ((· ∘' e) : (∀ i, π i) → _) :=
    measurable_pi_iff.mpr <| λ i ↦ measurable_pi_apply (e i)
  induction s using Finset.induction generalizing x
  

Proof state:
case empty
δ : Type u_1
δ' : Type u_2
π : δ → Type u_3
inst✝³ : (x : δ) → MeasurableSpace (π x)
μ : (i : δ) → Measure (π i)
inst✝² : ∀ (i : δ), SigmaFinite (μ i)
inst✝¹ : DecidableEq δ
s t : Finset δ
f✝ g : ((i : δ) → π i) → ℝ≥0∞
x✝ y : (i : δ) → π i
i : δ
inst✝ : DecidableEq δ'
e : δ' → δ
he : Injective e
f : ((i : δ') → π (e i)) → ℝ≥0∞
hf : Measurable f
h : Measurable fun x => (fun {x_1} => x) ∘' e
x : (i : δ) → π i
⊢ (∫⋯∫⁻_Finset.image e ∅, f ∘ fun x => (fun {x_1} => x) ∘' e ∂μ) x =
    (∫⋯∫⁻_∅, f ∂(fun {x} => μ) ∘' e) ((fun {x_1} => x) ∘' e)
case insert
δ : Type u_1
δ' : Type u_2
π : δ → Type u_3
inst✝³ : (x : δ) → MeasurableSpace (π x)
μ : (i : δ) → Measure (π i)
inst✝² : ∀ (i : δ), SigmaFinite (μ i)
inst✝¹ : DecidableEq δ
s t : Finset δ
f✝ g : ((i : δ) → π i) → ℝ≥0∞
x✝ y : (i : δ) → π i
i : δ
inst✝ : DecidableEq δ'
e : δ' → δ
he : Injective e
f : ((i : δ') → π (e i)) → ℝ≥0∞
hf : Measurable f
h : Measurable fun x => (fun {x_1} => x) ∘' e
a✝² : δ'
s✝ : Finset δ'
a✝¹ : a✝² ∉ s✝
a✝ :
  ∀ (x : (i : δ) → π i),
    (∫⋯∫⁻_Finset.image e s✝, f ∘ fun x => (fun {x_1} => x) ∘' e ∂μ) x =
      (∫⋯∫⁻_s✝, f ∂(fun {x} => μ) ∘' e) ((fun {x_1} => x) ∘' e)
x : (i : δ) → π i
⊢ (∫⋯∫⁻_Finset.image e (insert a✝² s✝), f ∘ fun x => (fun {x_1} => x) ∘' e ∂μ) x =
    (∫⋯∫⁻_insert a✝² s✝, f ∂(fun {x} => μ) ∘' e) ((fun {x_1} => x) ∘' e)

Next tactic:
case empty => simp
theorem lmarginal_image [DecidableEq δ'] {e : δ' → δ} (he : Injective e) (s : Finset δ')
    {f : (∀ i, π (e i)) → ℝ≥0∞} (hf : Measurable f) (x : ∀ i, π i) :
      (∫⋯∫⁻_s.image e, f ∘ (· ∘' e) ∂μ) x = (∫⋯∫⁻_s, f ∂μ ∘' e) (x ∘' e) := by
  have h : Measurable ((· ∘' e) : (∀ i, π i) → _) :=
    measurable_pi_iff.mpr <| λ i ↦ measurable_pi_apply (e i)
  induction s using Finset.induction generalizing x
  

Proof state:
δ : Type u_1
δ' : Type u_2
π : δ → Type u_3
inst✝³ : (x : δ) → MeasurableSpace (π x)
μ : (i : δ) → Measure (π i)
inst✝² : ∀ (i : δ), SigmaFinite (μ i)
inst✝¹ : DecidableEq δ
s t : Finset δ
f✝ g : ((i : δ) → π i) → ℝ≥0∞
x✝ y : (i : δ) → π i
i : δ
inst✝ : DecidableEq δ'
e : δ' → δ
he : Injective e
f : ((i : δ') → π (e i)) → ℝ≥0∞
hf : Measurable f
h : Measurable fun x => (fun {x_1} => x) ∘' e
x : (i : δ) → π i
⊢ (∫⋯∫⁻_Finset.image e ∅, f ∘ fun x => (fun {x_1} => x) ∘' e ∂μ) x =
    (∫⋯∫⁻_∅, f ∂(fun {x} => μ) ∘' e) ((fun {x_1} => x) ∘' e)

Next tactic:
case empty => simp
theorem lmarginal_image [DecidableEq δ'] {e : δ' → δ} (he : Injective e) (s : Finset δ')
    {f : (∀ i, π (e i)) → ℝ≥0∞} (hf : Measurable f) (x : ∀ i, π i) :
      (∫⋯∫⁻_s.image e, f ∘ (· ∘' e) ∂μ) x = (∫⋯∫⁻_s, f ∂μ ∘' e) (x ∘' e) := by
  have h : Measurable ((· ∘' e) : (∀ i, π i) → _) :=
    measurable_pi_iff.mpr <| λ i ↦ measurable_pi_apply (e i)
  induction s using Finset.induction generalizing x
  case empty => 

Proof state:
δ : Type u_1
δ' : Type u_2
π : δ → Type u_3
inst✝³ : (x : δ) → MeasurableSpace (π x)
μ : (i : δ) → Measure (π i)
inst✝² : ∀ (i : δ), SigmaFinite (μ i)
inst✝¹ : DecidableEq δ
s t : Finset δ
f✝ g : ((i : δ) → π i) → ℝ≥0∞
x✝ y : (i : δ) → π i
i : δ
inst✝ : DecidableEq δ'
e : δ' → δ
he : Injective e
f : ((i : δ') → π (e i)) → ℝ≥0∞
hf : Measurable f
h : Measurable fun x => (fun {x_1} => x) ∘' e
x : (i : δ) → π i
⊢ (∫⋯∫⁻_Finset.image e ∅, f ∘ fun x => (fun {x_1} => x) ∘' e ∂μ) x =
    (∫⋯∫⁻_∅, f ∂(fun {x} => μ) ∘' e) ((fun {x_1} => x) ∘' e)

Next tactic:
simp
theorem lmarginal_image [DecidableEq δ'] {e : δ' → δ} (he : Injective e) (s : Finset δ')
    {f : (∀ i, π (e i)) → ℝ≥0∞} (hf : Measurable f) (x : ∀ i, π i) :
      (∫⋯∫⁻_s.image e, f ∘ (· ∘' e) ∂μ) x = (∫⋯∫⁻_s, f ∂μ ∘' e) (x ∘' e) := by
  have h : Measurable ((· ∘' e) : (∀ i, π i) → _) :=
    measurable_pi_iff.mpr <| λ i ↦ measurable_pi_apply (e i)
  induction s using Finset.induction generalizing x
  case empty => simp
  

Proof state:
case insert
δ : Type u_1
δ' : Type u_2
π : δ → Type u_3
inst✝³ : (x : δ) → MeasurableSpace (π x)
μ : (i : δ) → Measure (π i)
inst✝² : ∀ (i : δ), SigmaFinite (μ i)
inst✝¹ : DecidableEq δ
s t : Finset δ
f✝ g : ((i : δ) → π i) → ℝ≥0∞
x✝ y : (i : δ) → π i
i : δ
inst✝ : DecidableEq δ'
e : δ' → δ
he : Injective e
f : ((i : δ') → π (e i)) → ℝ≥0∞
hf : Measurable f
h : Measurable fun x => (fun {x_1} => x) ∘' e
a✝² : δ'
s✝ : Finset δ'
a✝¹ : a✝² ∉ s✝
a✝ :
  ∀ (x : (i : δ) → π i),
    (∫⋯∫⁻_Finset.image e s✝, f ∘ fun x => (fun {x_1} => x) ∘' e ∂μ) x =
      (∫⋯∫⁻_s✝, f ∂(fun {x} => μ) ∘' e) ((fun {x_1} => x) ∘' e)
x : (i : δ) → π i
⊢ (∫⋯∫⁻_Finset.image e (insert a✝² s✝), f ∘ fun x => (fun {x_1} => x) ∘' e ∂μ) x =
    (∫⋯∫⁻_insert a✝² s✝, f ∂(fun {x} => μ) ∘' e) ((fun {x_1} => x) ∘' e)

Next tactic:
case insert i s hi ih =>
    rw [image_insert, lmarginal_insert _ (hf.comp h) (he.mem_finset_image.not.mpr hi),
      lmarginal_insert _ hf hi]
    simp_rw [ih, ← update_comp_eq_of_injective' x he]
theorem lmarginal_image [DecidableEq δ'] {e : δ' → δ} (he : Injective e) (s : Finset δ')
    {f : (∀ i, π (e i)) → ℝ≥0∞} (hf : Measurable f) (x : ∀ i, π i) :
      (∫⋯∫⁻_s.image e, f ∘ (· ∘' e) ∂μ) x = (∫⋯∫⁻_s, f ∂μ ∘' e) (x ∘' e) := by
  have h : Measurable ((· ∘' e) : (∀ i, π i) → _) :=
    measurable_pi_iff.mpr <| λ i ↦ measurable_pi_apply (e i)
  induction s using Finset.induction generalizing x
  case empty => simp
  

Proof state:
δ : Type u_1
δ' : Type u_2
π : δ → Type u_3
inst✝³ : (x : δ) → MeasurableSpace (π x)
μ : (i : δ) → Measure (π i)
inst✝² : ∀ (i : δ), SigmaFinite (μ i)
inst✝¹ : DecidableEq δ
s✝ t : Finset δ
f✝ g : ((i : δ) → π i) → ℝ≥0∞
x✝ y : (i : δ) → π i
i✝ : δ
inst✝ : DecidableEq δ'
e : δ' → δ
he : Injective e
f : ((i : δ') → π (e i)) → ℝ≥0∞
hf : Measurable f
h : Measurable fun x => (fun {x_1} => x) ∘' e
i : δ'
s : Finset δ'
hi : i ∉ s
ih :
  ∀ (x : (i : δ) → π i),
    (∫⋯∫⁻_Finset.image e s, f ∘ fun x => (fun {x_1} => x) ∘' e ∂μ) x =
      (∫⋯∫⁻_s, f ∂(fun {x} => μ) ∘' e) ((fun {x_1} => x) ∘' e)
x : (i : δ) → π i
⊢ (∫⋯∫⁻_Finset.image e (insert i s), f ∘ fun x => (fun {x_1} => x) ∘' e ∂μ) x =
    (∫⋯∫⁻_insert i s, f ∂(fun {x} => μ) ∘' e) ((fun {x_1} => x) ∘' e)

Next tactic:
case insert i s hi ih =>
    rw [image_insert, lmarginal_insert _ (hf.comp h) (he.mem_finset_image.not.mpr hi),
      lmarginal_insert _ hf hi]
    simp_rw [ih, ← update_comp_eq_of_injective' x he]
theorem lmarginal_image [DecidableEq δ'] {e : δ' → δ} (he : Injective e) (s : Finset δ')
    {f : (∀ i, π (e i)) → ℝ≥0∞} (hf : Measurable f) (x : ∀ i, π i) :
      (∫⋯∫⁻_s.image e, f ∘ (· ∘' e) ∂μ) x = (∫⋯∫⁻_s, f ∂μ ∘' e) (x ∘' e) := by
  have h : Measurable ((· ∘' e) : (∀ i, π i) → _) :=
    measurable_pi_iff.mpr <| λ i ↦ measurable_pi_apply (e i)
  induction s using Finset.induction generalizing x
  case empty => simp
  case insert i s hi ih =>
    

Proof state:
δ : Type u_1
δ' : Type u_2
π : δ → Type u_3
inst✝³ : (x : δ) → MeasurableSpace (π x)
μ : (i : δ) → Measure (π i)
inst✝² : ∀ (i : δ), SigmaFinite (μ i)
inst✝¹ : DecidableEq δ
s✝ t : Finset δ
f✝ g : ((i : δ) → π i) → ℝ≥0∞
x✝ y : (i : δ) → π i
i✝ : δ
inst✝ : DecidableEq δ'
e : δ' → δ
he : Injective e
f : ((i : δ') → π (e i)) → ℝ≥0∞
hf : Measurable f
h : Measurable fun x => (fun {x_1} => x) ∘' e
i : δ'
s : Finset δ'
hi : i ∉ s
ih :
  ∀ (x : (i : δ) → π i),
    (∫⋯∫⁻_Finset.image e s, f ∘ fun x => (fun {x_1} => x) ∘' e ∂μ) x =
      (∫⋯∫⁻_s, f ∂(fun {x} => μ) ∘' e) ((fun {x_1} => x) ∘' e)
x : (i : δ) → π i
⊢ (∫⋯∫⁻_Finset.image e (insert i s), f ∘ fun x => (fun {x_1} => x) ∘' e ∂μ) x =
    (∫⋯∫⁻_insert i s, f ∂(fun {x} => μ) ∘' e) ((fun {x_1} => x) ∘' e)

Next tactic:
rw [image_insert, lmarginal_insert _ (hf.comp h) (he.mem_finset_image.not.mpr hi),
      lmarginal_insert _ hf hi]
theorem lmarginal_image [DecidableEq δ'] {e : δ' → δ} (he : Injective e) (s : Finset δ')
    {f : (∀ i, π (e i)) → ℝ≥0∞} (hf : Measurable f) (x : ∀ i, π i) :
      (∫⋯∫⁻_s.image e, f ∘ (· ∘' e) ∂μ) x = (∫⋯∫⁻_s, f ∂μ ∘' e) (x ∘' e) := by
  have h : Measurable ((· ∘' e) : (∀ i, π i) → _) :=
    measurable_pi_iff.mpr <| λ i ↦ measurable_pi_apply (e i)
  induction s using Finset.induction generalizing x
  case empty => simp
  case insert i s hi ih =>
    rw [image_insert, lmarginal_insert _ (hf.comp h) (he.mem_finset_image.not.mpr hi),
      lmarginal_insert _ hf hi]
    

Proof state:
δ : Type u_1
δ' : Type u_2
π : δ → Type u_3
inst✝³ : (x : δ) → MeasurableSpace (π x)
μ : (i : δ) → Measure (π i)
inst✝² : ∀ (i : δ), SigmaFinite (μ i)
inst✝¹ : DecidableEq δ
s✝ t : Finset δ
f✝ g : ((i : δ) → π i) → ℝ≥0∞
x✝ y : (i : δ) → π i
i✝ : δ
inst✝ : DecidableEq δ'
e : δ' → δ
he : Injective e
f : ((i : δ') → π (e i)) → ℝ≥0∞
hf : Measurable f
h : Measurable fun x => (fun {x_1} => x) ∘' e
i : δ'
s : Finset δ'
hi : i ∉ s
ih :
  ∀ (x : (i : δ) → π i),
    (∫⋯∫⁻_Finset.image e s, f ∘ fun x => (fun {x_1} => x) ∘' e ∂μ) x =
      (∫⋯∫⁻_s, f ∂(fun {x} => μ) ∘' e) ((fun {x_1} => x) ∘' e)
x : (i : δ) → π i
⊢ ∫⁻ (xᵢ : π (e i)), (∫⋯∫⁻_Finset.image e s, f ∘ fun x => (fun {x_1} => x) ∘' e ∂μ) (update x (e i) xᵢ) ∂μ (e i) =
    ∫⁻ (xᵢ : π (e i)), (∫⋯∫⁻_s, f ∂(fun {x} => μ) ∘' e) (update ((fun {x_1} => x) ∘' e) i xᵢ) ∂((fun {x} => μ) ∘' e) i

Next tactic:
simp_rw [ih, ← update_comp_eq_of_injective' x he]
theorem lmarginal_update_of_not_mem {i : δ}
    {f : (∀ i, π i) → ℝ≥0∞} (hf : Measurable f) (hi : i ∉ s) (x : ∀ i, π i) (y : π i) :
    (∫⋯∫⁻_s, f ∂μ) (Function.update x i y) = (∫⋯∫⁻_s, f ∘ (Function.update · i y) ∂μ) x := by
  

Proof state:
δ : Type u_1
δ' : Type u_2
π : δ → Type u_3
inst✝² : (x : δ) → MeasurableSpace (π x)
μ : (i : δ) → Measure (π i)
inst✝¹ : ∀ (i : δ), SigmaFinite (μ i)
inst✝ : DecidableEq δ
s t : Finset δ
f✝ g : ((i : δ) → π i) → ℝ≥0∞
x✝ y✝ : (i : δ) → π i
i✝ i : δ
f : ((i : δ) → π i) → ℝ≥0∞
hf : Measurable f
hi : i ∉ s
x : (i : δ) → π i
y : π i
⊢ (∫⋯∫⁻_s, f ∂μ) (update x i y) = (∫⋯∫⁻_s, f ∘ fun x => update x i y ∂μ) x

Next tactic:
induction s using Finset.induction generalizing x
theorem lmarginal_update_of_not_mem {i : δ}
    {f : (∀ i, π i) → ℝ≥0∞} (hf : Measurable f) (hi : i ∉ s) (x : ∀ i, π i) (y : π i) :
    (∫⋯∫⁻_s, f ∂μ) (Function.update x i y) = (∫⋯∫⁻_s, f ∘ (Function.update · i y) ∂μ) x := by
  induction s using Finset.induction generalizing x
  

Proof state:
case empty
δ : Type u_1
δ' : Type u_2
π : δ → Type u_3
inst✝² : (x : δ) → MeasurableSpace (π x)
μ : (i : δ) → Measure (π i)
inst✝¹ : ∀ (i : δ), SigmaFinite (μ i)
inst✝ : DecidableEq δ
s t : Finset δ
f✝ g : ((i : δ) → π i) → ℝ≥0∞
x✝ y✝ : (i : δ) → π i
i✝ i : δ
f : ((i : δ) → π i) → ℝ≥0∞
hf : Measurable f
y : π i
hi : i ∉ ∅
x : (i : δ) → π i
⊢ (∫⋯∫⁻_∅, f ∂μ) (update x i y) = (∫⋯∫⁻_∅, f ∘ fun x => update x i y ∂μ) x
case insert
δ : Type u_1
δ' : Type u_2
π : δ → Type u_3
inst✝² : (x : δ) → MeasurableSpace (π x)
μ : (i : δ) → Measure (π i)
inst✝¹ : ∀ (i : δ), SigmaFinite (μ i)
inst✝ : DecidableEq δ
s t : Finset δ
f✝ g : ((i : δ) → π i) → ℝ≥0∞
x✝ y✝ : (i : δ) → π i
i✝ i : δ
f : ((i : δ) → π i) → ℝ≥0∞
hf : Measurable f
y : π i
a✝² : δ
s✝ : Finset δ
a✝¹ : a✝² ∉ s✝
a✝ : i ∉ s✝ → ∀ (x : (i : δ) → π i), (∫⋯∫⁻_s✝, f ∂μ) (update x i y) = (∫⋯∫⁻_s✝, f ∘ fun x => update x i y ∂μ) x
hi : i ∉ insert a✝² s✝
x : (i : δ) → π i
⊢ (∫⋯∫⁻_insert a✝² s✝, f ∂μ) (update x i y) = (∫⋯∫⁻_insert a✝² s✝, f ∘ fun x => update x i y ∂μ) x

Next tactic:
case empty => simp
theorem lmarginal_update_of_not_mem {i : δ}
    {f : (∀ i, π i) → ℝ≥0∞} (hf : Measurable f) (hi : i ∉ s) (x : ∀ i, π i) (y : π i) :
    (∫⋯∫⁻_s, f ∂μ) (Function.update x i y) = (∫⋯∫⁻_s, f ∘ (Function.update · i y) ∂μ) x := by
  induction s using Finset.induction generalizing x
  

Proof state:
δ : Type u_1
δ' : Type u_2
π : δ → Type u_3
inst✝² : (x : δ) → MeasurableSpace (π x)
μ : (i : δ) → Measure (π i)
inst✝¹ : ∀ (i : δ), SigmaFinite (μ i)
inst✝ : DecidableEq δ
s t : Finset δ
f✝ g : ((i : δ) → π i) → ℝ≥0∞
x✝ y✝ : (i : δ) → π i
i✝ i : δ
f : ((i : δ) → π i) → ℝ≥0∞
hf : Measurable f
y : π i
hi : i ∉ ∅
x : (i : δ) → π i
⊢ (∫⋯∫⁻_∅, f ∂μ) (update x i y) = (∫⋯∫⁻_∅, f ∘ fun x => update x i y ∂μ) x

Next tactic:
case empty => simp
theorem lmarginal_update_of_not_mem {i : δ}
    {f : (∀ i, π i) → ℝ≥0∞} (hf : Measurable f) (hi : i ∉ s) (x : ∀ i, π i) (y : π i) :
    (∫⋯∫⁻_s, f ∂μ) (Function.update x i y) = (∫⋯∫⁻_s, f ∘ (Function.update · i y) ∂μ) x := by
  induction s using Finset.induction generalizing x
  case empty => 

Proof state:
δ : Type u_1
δ' : Type u_2
π : δ → Type u_3
inst✝² : (x : δ) → MeasurableSpace (π x)
μ : (i : δ) → Measure (π i)
inst✝¹ : ∀ (i : δ), SigmaFinite (μ i)
inst✝ : DecidableEq δ
s t : Finset δ
f✝ g : ((i : δ) → π i) → ℝ≥0∞
x✝ y✝ : (i : δ) → π i
i✝ i : δ
f : ((i : δ) → π i) → ℝ≥0∞
hf : Measurable f
y : π i
hi : i ∉ ∅
x : (i : δ) → π i
⊢ (∫⋯∫⁻_∅, f ∂μ) (update x i y) = (∫⋯∫⁻_∅, f ∘ fun x => update x i y ∂μ) x

Next tactic:
simp
theorem lmarginal_update_of_not_mem {i : δ}
    {f : (∀ i, π i) → ℝ≥0∞} (hf : Measurable f) (hi : i ∉ s) (x : ∀ i, π i) (y : π i) :
    (∫⋯∫⁻_s, f ∂μ) (Function.update x i y) = (∫⋯∫⁻_s, f ∘ (Function.update · i y) ∂μ) x := by
  induction s using Finset.induction generalizing x
  case empty => simp
  

Proof state:
case insert
δ : Type u_1
δ' : Type u_2
π : δ → Type u_3
inst✝² : (x : δ) → MeasurableSpace (π x)
μ : (i : δ) → Measure (π i)
inst✝¹ : ∀ (i : δ), SigmaFinite (μ i)
inst✝ : DecidableEq δ
s t : Finset δ
f✝ g : ((i : δ) → π i) → ℝ≥0∞
x✝ y✝ : (i : δ) → π i
i✝ i : δ
f : ((i : δ) → π i) → ℝ≥0∞
hf : Measurable f
y : π i
a✝² : δ
s✝ : Finset δ
a✝¹ : a✝² ∉ s✝
a✝ : i ∉ s✝ → ∀ (x : (i : δ) → π i), (∫⋯∫⁻_s✝, f ∂μ) (update x i y) = (∫⋯∫⁻_s✝, f ∘ fun x => update x i y ∂μ) x
hi : i ∉ insert a✝² s✝
x : (i : δ) → π i
⊢ (∫⋯∫⁻_insert a✝² s✝, f ∂μ) (update x i y) = (∫⋯∫⁻_insert a✝² s✝, f ∘ fun x => update x i y ∂μ) x

Next tactic:
case insert i' s hi' ih =>
    rw [lmarginal_insert _ hf hi', lmarginal_insert _ (hf.comp measurable_update_left) hi']
    have hii' : i ≠ i' := mt (by rintro rfl; exact mem_insert_self i s) hi
    simp_rw [update_comm hii', ih (mt Finset.mem_insert_of_mem hi)]
theorem lmarginal_update_of_not_mem {i : δ}
    {f : (∀ i, π i) → ℝ≥0∞} (hf : Measurable f) (hi : i ∉ s) (x : ∀ i, π i) (y : π i) :
    (∫⋯∫⁻_s, f ∂μ) (Function.update x i y) = (∫⋯∫⁻_s, f ∘ (Function.update · i y) ∂μ) x := by
  induction s using Finset.induction generalizing x
  case empty => simp
  

Proof state:
δ : Type u_1
δ' : Type u_2
π : δ → Type u_3
inst✝² : (x : δ) → MeasurableSpace (π x)
μ : (i : δ) → Measure (π i)
inst✝¹ : ∀ (i : δ), SigmaFinite (μ i)
inst✝ : DecidableEq δ
s✝ t : Finset δ
f✝ g : ((i : δ) → π i) → ℝ≥0∞
x✝ y✝ : (i : δ) → π i
i✝ i : δ
f : ((i : δ) → π i) → ℝ≥0∞
hf : Measurable f
y : π i
i' : δ
s : Finset δ
hi' : i' ∉ s
ih : i ∉ s → ∀ (x : (i : δ) → π i), (∫⋯∫⁻_s, f ∂μ) (update x i y) = (∫⋯∫⁻_s, f ∘ fun x => update x i y ∂μ) x
hi : i ∉ insert i' s
x : (i : δ) → π i
⊢ (∫⋯∫⁻_insert i' s, f ∂μ) (update x i y) = (∫⋯∫⁻_insert i' s, f ∘ fun x => update x i y ∂μ) x

Next tactic:
case insert i' s hi' ih =>
    rw [lmarginal_insert _ hf hi', lmarginal_insert _ (hf.comp measurable_update_left) hi']
    have hii' : i ≠ i' := mt (by rintro rfl; exact mem_insert_self i s) hi
    simp_rw [update_comm hii', ih (mt Finset.mem_insert_of_mem hi)]
theorem lmarginal_update_of_not_mem {i : δ}
    {f : (∀ i, π i) → ℝ≥0∞} (hf : Measurable f) (hi : i ∉ s) (x : ∀ i, π i) (y : π i) :
    (∫⋯∫⁻_s, f ∂μ) (Function.update x i y) = (∫⋯∫⁻_s, f ∘ (Function.update · i y) ∂μ) x := by
  induction s using Finset.induction generalizing x
  case empty => simp
  case insert i' s hi' ih =>
    

Proof state:
δ : Type u_1
δ' : Type u_2
π : δ → Type u_3
inst✝² : (x : δ) → MeasurableSpace (π x)
μ : (i : δ) → Measure (π i)
inst✝¹ : ∀ (i : δ), SigmaFinite (μ i)
inst✝ : DecidableEq δ
s✝ t : Finset δ
f✝ g : ((i : δ) → π i) → ℝ≥0∞
x✝ y✝ : (i : δ) → π i
i✝ i : δ
f : ((i : δ) → π i) → ℝ≥0∞
hf : Measurable f
y : π i
i' : δ
s : Finset δ
hi' : i' ∉ s
ih : i ∉ s → ∀ (x : (i : δ) → π i), (∫⋯∫⁻_s, f ∂μ) (update x i y) = (∫⋯∫⁻_s, f ∘ fun x => update x i y ∂μ) x
hi : i ∉ insert i' s
x : (i : δ) → π i
⊢ (∫⋯∫⁻_insert i' s, f ∂μ) (update x i y) = (∫⋯∫⁻_insert i' s, f ∘ fun x => update x i y ∂μ) x

Next tactic:
rw [lmarginal_insert _ hf hi', lmarginal_insert _ (hf.comp measurable_update_left) hi']
theorem lmarginal_update_of_not_mem {i : δ}
    {f : (∀ i, π i) → ℝ≥0∞} (hf : Measurable f) (hi : i ∉ s) (x : ∀ i, π i) (y : π i) :
    (∫⋯∫⁻_s, f ∂μ) (Function.update x i y) = (∫⋯∫⁻_s, f ∘ (Function.update · i y) ∂μ) x := by
  induction s using Finset.induction generalizing x
  case empty => simp
  case insert i' s hi' ih =>
    rw [lmarginal_insert _ hf hi', lmarginal_insert _ (hf.comp measurable_update_left) hi']
    

Proof state:
δ : Type u_1
δ' : Type u_2
π : δ → Type u_3
inst✝² : (x : δ) → MeasurableSpace (π x)
μ : (i : δ) → Measure (π i)
inst✝¹ : ∀ (i : δ), SigmaFinite (μ i)
inst✝ : DecidableEq δ
s✝ t : Finset δ
f✝ g : ((i : δ) → π i) → ℝ≥0∞
x✝ y✝ : (i : δ) → π i
i✝ i : δ
f : ((i : δ) → π i) → ℝ≥0∞
hf : Measurable f
y : π i
i' : δ
s : Finset δ
hi' : i' ∉ s
ih : i ∉ s → ∀ (x : (i : δ) → π i), (∫⋯∫⁻_s, f ∂μ) (update x i y) = (∫⋯∫⁻_s, f ∘ fun x => update x i y ∂μ) x
hi : i ∉ insert i' s
x : (i : δ) → π i
⊢ ∫⁻ (xᵢ : π i'), (∫⋯∫⁻_s, f ∂μ) (update (update x i y) i' xᵢ) ∂μ i' =
    ∫⁻ (xᵢ : π i'), (∫⋯∫⁻_s, f ∘ fun x => update x i y ∂μ) (update x i' xᵢ) ∂μ i'

Next tactic:
have hii' : i ≠ i' := mt (by rintro rfl; exact mem_insert_self i s) hi