-- Mathlib/Probability/Kernel/Disintegration/CDFToKernel.lean
lemma lintegral_toKernel_mem [IsFiniteKernel κ] (hf : IsCondKernelCDF f κ ν)
    (a : α) {s : Set (β × ℝ)} (hs : MeasurableSet s) :
    ∫⁻ b, hf.toKernel f (a, b) {y | (b, y) ∈ s} ∂(ν a) = κ a s

Proof state:
α : Type u_1
β : Type u_2
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ : Kernel α (β × ℝ)
ν : Kernel α β
f : α × β → StieltjesFunction
inst✝ : IsFiniteKernel κ
hf : IsCondKernelCDF f κ ν
a : α
s t : Set (β × ℝ)
ht : MeasurableSet t
ht_eq : ∫⁻ (b : β), ((IsCondKernelCDF.toKernel f hf) (a, b)) {y | (b, y) ∈ t} ∂ν a = (κ a) t
⊢ ∫⁻ (b : β),
      ((IsCondKernelCDF.toKernel f hf) (a, b)) univ - ((IsCondKernelCDF.toKernel f hf) (a, b)) {y | (b, y) ∈ t} ∂ν a =
    ∫⁻ (x : β), ((IsCondKernelCDF.toKernel f hf) (a, x)) univ ∂ν a -
      ∫⁻ (x : β), ((IsCondKernelCDF.toKernel f hf) (a, x)) {y | (x, y) ∈ t} ∂ν a

Tactic:
have h_le : (fun x ↦ hf.toKernel f (a, x) {y : ℝ | (x, y) ∈ t})
      ≤ᵐ[ν a] fun x ↦ hf.toKernel f (a, x) univ :=
  Eventually.of_forall fun _ ↦ measure_mono (subset_univ _)

Result:
α : Type u_1
β : Type u_2
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ : Kernel α (β × ℝ)
ν : Kernel α β
f : α × β → StieltjesFunction
inst✝ : IsFiniteKernel κ
hf : IsCondKernelCDF f κ ν
a : α
s t : Set (β × ℝ)
ht : MeasurableSet t
ht_eq : ∫⁻ (b : β), ((IsCondKernelCDF.toKernel f hf) (a, b)) {y | (b, y) ∈ t} ∂ν a = (κ a) t
h_le :
  (fun x => ((IsCondKernelCDF.toKernel f hf) (a, x)) {y | (x, y) ∈ t}) ≤ᶠ[ae (ν a)] fun x =>
    ((IsCondKernelCDF.toKernel f hf) (a, x)) univ
⊢ ∫⁻ (b : β),
      ((IsCondKernelCDF.toKernel f hf) (a, b)) univ - ((IsCondKernelCDF.toKernel f hf) (a, b)) {y | (b, y) ∈ t} ∂ν a =
    ∫⁻ (x : β), ((IsCondKernelCDF.toKernel f hf) (a, x)) univ ∂ν a -
      ∫⁻ (x : β), ((IsCondKernelCDF.toKernel f hf) (a, x)) {y | (x, y) ∈ t} ∂ν a

Proof state:
case h
α : Type u_1
β : Type u_2
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ : Kernel α (β × ℝ)
ν : Kernel α β
f : α × β → StieltjesFunction
inst✝ : IsFiniteKernel κ
hf : IsCondKernelCDF f κ ν
a✝ : α
s : Set (β × ℝ)
f' : ℕ → Set (β × ℝ)
hf_disj : Pairwise (Disjoint on f')
hf_meas : ∀ (i : ℕ), MeasurableSet (f' i)
hf_eq : ∀ (i : ℕ), ∫⁻ (b : β), ((IsCondKernelCDF.toKernel f hf) (a✝, b)) {y | (b, y) ∈ f' i} ∂ν a✝ = (κ a✝) (f' i)
h_eq : ∀ (a : β), {x | (a, x) ∈ ⋃ i, f' i} = ⋃ i, {x | (a, x) ∈ f' i}
a : β
i j : ℕ
hij : i ≠ j
h_disj : f' i ∩ f' j = ∅
x : ℝ
h_mem_both : (a, x) ∈ f' i ∧ (a, x) ∈ f' j
⊢ (a, x) ∈ ∅

Tactic:
rwa [← h_disj, mem_inter_iff]

Result:
no goals

Proof state:
α : Type u_1
β : Type u_2
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ : Kernel α (β × ℝ)
ν : Kernel α β
f : α × β → StieltjesFunction
inst✝ : IsFiniteKernel κ
hf : IsCondKernelCDF f κ ν
a : α
s : Set (β × ℝ)
t₁ : Set β
ht₁ : MeasurableSet t₁
t₂ : Set ℝ
ht₂ : MeasurableSet t₂
h_prod_eq_snd : ∀ a ∈ t₁, {x | (a, x) ∈ t₁ ×ˢ t₂} = t₂
h_eq1 :
  ∫⁻ (x : β) in t₁, ((IsCondKernelCDF.toKernel f hf) (a, x)) {y | (x, y) ∈ t₁ ×ˢ t₂} ∂ν a =
    ∫⁻ (x : β) in t₁, ((IsCondKernelCDF.toKernel f hf) (a, x)) t₂ ∂ν a
⊢ ∀ x ∈ t₁ᶜ, ((IsCondKernelCDF.toKernel f hf) (a, x)) {y | (x, y) ∈ t₁ ×ˢ t₂} = 0

Tactic:
intro a hat₁

Result:
α : Type u_1
β : Type u_2
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ : Kernel α (β × ℝ)
ν : Kernel α β
f : α × β → StieltjesFunction
inst✝ : IsFiniteKernel κ
hf : IsCondKernelCDF f κ ν
a✝ : α
s : Set (β × ℝ)
t₁ : Set β
ht₁ : MeasurableSet t₁
t₂ : Set ℝ
ht₂ : MeasurableSet t₂
h_prod_eq_snd : ∀ a ∈ t₁, {x | (a, x) ∈ t₁ ×ˢ t₂} = t₂
h_eq1 :
  ∫⁻ (x : β) in t₁, ((IsCondKernelCDF.toKernel f hf) (a✝, x)) {y | (x, y) ∈ t₁ ×ˢ t₂} ∂ν a✝ =
    ∫⁻ (x : β) in t₁, ((IsCondKernelCDF.toKernel f hf) (a✝, x)) t₂ ∂ν a✝
a : β
hat₁ : a ∈ t₁ᶜ
⊢ ((IsCondKernelCDF.toKernel f hf) (a✝, a)) {y | (a, y) ∈ t₁ ×ˢ t₂} = 0

Proof state:
case iUnion
α : Type u_1
β : Type u_2
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ : Kernel α (β × ℝ)
ν : Kernel α β
f : α × β → StieltjesFunction
inst✝ : IsFiniteKernel κ
hf : IsCondKernelCDF f κ ν
a : α
s : Set (β × ℝ)
f' : ℕ → Set (β × ℝ)
hf_disj : Pairwise (Disjoint on f')
hf_meas : ∀ (i : ℕ), MeasurableSet (f' i)
hf_eq : ∀ (i : ℕ), ∫⁻ (b : β), ((IsCondKernelCDF.toKernel f hf) (a, b)) {y | (b, y) ∈ f' i} ∂ν a = (κ a) (f' i)
h_eq : ∀ (a : β), {x | (a, x) ∈ ⋃ i, f' i} = ⋃ i, {x | (a, x) ∈ f' i}
h_disj : ∀ (a : β), Pairwise (Disjoint on fun i => {x | (a, x) ∈ f' i})
⊢ ∫⁻ (b : β), ((IsCondKernelCDF.toKernel f hf) (a, b)) (⋃ i, {x | (b, x) ∈ f' i}) ∂ν a = (κ a) (⋃ i, f' i)

Tactic:
calc ∫⁻ b, hf.toKernel f (a, b) (⋃ i, {y | (b, y) ∈ f' i}) ∂(ν a)
  = ∫⁻ b, ∑' i, hf.toKernel f (a, b) {y | (b, y) ∈ f' i} ∂(ν a) := by
      congr with x : 1
      rw [measure_iUnion (h_disj x) fun i ↦ measurable_prod_mk_left (hf_meas i)]
_ = ∑' i, ∫⁻ b, hf.toKernel f (a, b) {y | (b, y) ∈ f' i} ∂(ν a) :=
      lintegral_tsum fun i ↦ (Kernel.measurable_kernel_prod_mk_left' (hf_meas i) a).aemeasurable
_ = ∑' i, κ a (f' i) := by simp_rw [hf_eq]
_ = κ a (iUnion f') := (measure_iUnion hf_disj hf_meas).symm

Result:
no goals

Proof state:
α : Type u_1
β : Type u_2
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ : Kernel α (β × ℝ)
ν : Kernel α β
f : α × β → StieltjesFunction
inst✝ : IsFiniteKernel κ
hf : IsCondKernelCDF f κ ν
a : α
s t : Set (β × ℝ)
ht : MeasurableSet t
ht_eq : ∫⁻ (b : β), ((IsCondKernelCDF.toKernel f hf) (a, b)) {y | (b, y) ∈ t} ∂ν a = (κ a) t
⊢ ∫⁻ (x : β), ((IsCondKernelCDF.toKernel f hf) (a, x)) univ ∂ν a -
      ∫⁻ (x : β), ((IsCondKernelCDF.toKernel f hf) (a, x)) {y | (x, y) ∈ t} ∂ν a =
    (κ a) univ - (κ a) t

Tactic:
rw [ht_eq, lintegral_toKernel_univ hf]

Result:
no goals

Proof state:
case h
α : Type u_1
β : Type u_2
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ : Kernel α (β × ℝ)
ν : Kernel α β
f : α × β → StieltjesFunction
inst✝ : IsFiniteKernel κ
hf : IsCondKernelCDF f κ ν
a✝ : α
s : Set (β × ℝ)
f' : ℕ → Set (β × ℝ)
hf_disj : Pairwise (Disjoint on f')
hf_meas : ∀ (i : ℕ), MeasurableSet (f' i)
hf_eq : ∀ (i : ℕ), ∫⁻ (b : β), ((IsCondKernelCDF.toKernel f hf) (a✝, b)) {y | (b, y) ∈ f' i} ∂ν a✝ = (κ a✝) (f' i)
h_eq : ∀ (a : β), {x | (a, x) ∈ ⋃ i, f' i} = ⋃ i, {x | (a, x) ∈ f' i}
a : β
i j : ℕ
hij : i ≠ j
h_disj : f' i ∩ f' j = ∅
x : ℝ
h_mem_both : (a, x) ∈ f' i ∧ (a, x) ∈ f' j
⊢ False

Tactic:
suffices (a, x) ∈ ∅ by rwa [mem_empty_iff_false] at this

Result:
case h
α : Type u_1
β : Type u_2
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ : Kernel α (β × ℝ)
ν : Kernel α β
f : α × β → StieltjesFunction
inst✝ : IsFiniteKernel κ
hf : IsCondKernelCDF f κ ν
a✝ : α
s : Set (β × ℝ)
f' : ℕ → Set (β × ℝ)
hf_disj : Pairwise (Disjoint on f')
hf_meas : ∀ (i : ℕ), MeasurableSet (f' i)
hf_eq : ∀ (i : ℕ), ∫⁻ (b : β), ((IsCondKernelCDF.toKernel f hf) (a✝, b)) {y | (b, y) ∈ f' i} ∂ν a✝ = (κ a✝) (f' i)
h_eq : ∀ (a : β), {x | (a, x) ∈ ⋃ i, f' i} = ⋃ i, {x | (a, x) ∈ f' i}
a : β
i j : ℕ
hij : i ≠ j
h_disj : f' i ∩ f' j = ∅
x : ℝ
h_mem_both : (a, x) ∈ f' i ∧ (a, x) ∈ f' j
⊢ (a, x) ∈ ∅

Proof state:
case e_f.h
α : Type u_1
β : Type u_2
mα : MeasurableSpace α
mβ : MeasurableSpace β
κ : Kernel α (β × ℝ)
ν : Kernel α β
f : α × β → StieltjesFunction
inst✝ : IsFiniteKernel κ
hf : IsCondKernelCDF f κ ν
a : α
s t : Set (β × ℝ)
ht : MeasurableSet t
ht_eq : ∫⁻ (b : β), ((IsCondKernelCDF.toKernel f hf) (a, b)) {y | (b, y) ∈ t} ∂ν a = (κ a) t
x : β
⊢ ((IsCondKernelCDF.toKernel f hf) (a, x)) {y | (x, y) ∈ t}ᶜ =
    ((IsCondKernelCDF.toKernel f hf) (a, x)) univ - ((IsCondKernelCDF.toKernel f hf) (a, x)) {y | (x, y) ∈ t}

Tactic:
exact measure_compl (measurable_prod_mk_left ht)
  (measure_ne_top (hf.toKernel f (a, x)) _)

Result:
no goals