-- Mathlib/Probability/Kernel/Disintegration/StandardBorel.lean
lemma borelMarkovFromReal_apply' (Ω : Type*) [Nonempty Ω] [MeasurableSpace Ω] [StandardBorelSpace Ω]
    (η : Kernel α ℝ) (a : α) {s : Set Ω} (hs : MeasurableSet s) :
    borelMarkovFromReal Ω η a s
      = if η a (range (embeddingReal Ω))ᶜ = 0 then η a (embeddingReal Ω '' s)
        else (embeddingReal Ω '' s).indicator 1 (range_nonempty (embeddingReal Ω)).choose

Proof state:
case neg
α : Type u_1
mα : MeasurableSpace α
Ω : Type u_5
inst✝² : Nonempty Ω
inst✝¹ : MeasurableSpace Ω
inst✝ : StandardBorelSpace Ω
η : Kernel α ℝ
a : α
s : Set Ω
hs : MeasurableSet s
he : MeasurableEmbedding (embeddingReal Ω)
h : ¬(η a) (range (embeddingReal Ω))ᶜ = 0
⊢ (Measure.comap (embeddingReal Ω) (Measure.dirac (Exists.choose ⋯))) s =
    (embeddingReal Ω '' s).indicator 1 (Exists.choose ⋯)

Tactic:
rw [Measure.comap_apply _ he.injective he.measurableSet_image' _ hs, Measure.dirac_apply]

Result:
no goals

Proof state:
case pos
α : Type u_1
mα : MeasurableSpace α
Ω : Type u_5
inst✝² : Nonempty Ω
inst✝¹ : MeasurableSpace Ω
inst✝ : StandardBorelSpace Ω
η : Kernel α ℝ
a : α
s : Set Ω
hs : MeasurableSet s
he : MeasurableEmbedding (embeddingReal Ω)
h : (η a) (range (embeddingReal Ω))ᶜ = 0
⊢ (Measure.comap (embeddingReal Ω) (η a)) s = (η a) (embeddingReal Ω '' s)

Tactic:
rw [Measure.comap_apply _ he.injective he.measurableSet_image' _ hs]

Result:
no goals

Proof state:
α : Type u_1
mα : MeasurableSpace α
Ω : Type u_5
inst✝² : Nonempty Ω
inst✝¹ : MeasurableSpace Ω
inst✝ : StandardBorelSpace Ω
η : Kernel α ℝ
a : α
s : Set Ω
hs : MeasurableSet s
he : MeasurableEmbedding (embeddingReal Ω)
⊢ ((borelMarkovFromReal Ω η) a) s =
    if (η a) (range (embeddingReal Ω))ᶜ = 0 then (η a) (embeddingReal Ω '' s)
    else (embeddingReal Ω '' s).indicator 1 (Exists.choose ⋯)

Tactic:
rw [borelMarkovFromReal_apply]

Result:
α : Type u_1
mα : MeasurableSpace α
Ω : Type u_5
inst✝² : Nonempty Ω
inst✝¹ : MeasurableSpace Ω
inst✝ : StandardBorelSpace Ω
η : Kernel α ℝ
a : α
s : Set Ω
hs : MeasurableSet s
he : MeasurableEmbedding (embeddingReal Ω)
⊢ (if (η a) (range (embeddingReal Ω))ᶜ = 0 then Measure.comap (embeddingReal Ω) (η a)
      else Measure.comap (embeddingReal Ω) (Measure.dirac (Exists.choose ⋯)))
      s =
    if (η a) (range (embeddingReal Ω))ᶜ = 0 then (η a) (embeddingReal Ω '' s)
    else (embeddingReal Ω '' s).indicator 1 (Exists.choose ⋯)

Proof state:
α : Type u_1
mα : MeasurableSpace α
Ω : Type u_5
inst✝² : Nonempty Ω
inst✝¹ : MeasurableSpace Ω
inst✝ : StandardBorelSpace Ω
η : Kernel α ℝ
a : α
s : Set Ω
hs : MeasurableSet s
he : MeasurableEmbedding (embeddingReal Ω)
⊢ (if (η a) (range (embeddingReal Ω))ᶜ = 0 then Measure.comap (embeddingReal Ω) (η a)
      else Measure.comap (embeddingReal Ω) (Measure.dirac (Exists.choose ⋯)))
      s =
    if (η a) (range (embeddingReal Ω))ᶜ = 0 then (η a) (embeddingReal Ω '' s)
    else (embeddingReal Ω '' s).indicator 1 (Exists.choose ⋯)

Tactic:
split_ifs with h

Result:
case pos
α : Type u_1
mα : MeasurableSpace α
Ω : Type u_5
inst✝² : Nonempty Ω
inst✝¹ : MeasurableSpace Ω
inst✝ : StandardBorelSpace Ω
η : Kernel α ℝ
a : α
s : Set Ω
hs : MeasurableSet s
he : MeasurableEmbedding (embeddingReal Ω)
h : (η a) (range (embeddingReal Ω))ᶜ = 0
⊢ (Measure.comap (embeddingReal Ω) (η a)) s = (η a) (embeddingReal Ω '' s)

case neg
α : Type u_1
mα : MeasurableSpace α
Ω : Type u_5
inst✝² : Nonempty Ω
inst✝¹ : MeasurableSpace Ω
inst✝ : StandardBorelSpace Ω
η : Kernel α ℝ
a : α
s : Set Ω
hs : MeasurableSet s
he : MeasurableEmbedding (embeddingReal Ω)
h : ¬(η a) (range (embeddingReal Ω))ᶜ = 0
⊢ (Measure.comap (embeddingReal Ω) (Measure.dirac (Exists.choose ⋯))) s =
    (embeddingReal Ω '' s).indicator 1 (Exists.choose ⋯)

Proof state:
α : Type u_1
mα : MeasurableSpace α
Ω : Type u_5
inst✝² : Nonempty Ω
inst✝¹ : MeasurableSpace Ω
inst✝ : StandardBorelSpace Ω
η : Kernel α ℝ
a : α
s : Set Ω
hs : MeasurableSet s
⊢ ((borelMarkovFromReal Ω η) a) s =
    if (η a) (range (embeddingReal Ω))ᶜ = 0 then (η a) (embeddingReal Ω '' s)
    else (embeddingReal Ω '' s).indicator 1 (Exists.choose ⋯)

Tactic:
have he := measurableEmbedding_embeddingReal Ω

Result:
α : Type u_1
mα : MeasurableSpace α
Ω : Type u_5
inst✝² : Nonempty Ω
inst✝¹ : MeasurableSpace Ω
inst✝ : StandardBorelSpace Ω
η : Kernel α ℝ
a : α
s : Set Ω
hs : MeasurableSet s
he : MeasurableEmbedding (embeddingReal Ω)
⊢ ((borelMarkovFromReal Ω η) a) s =
    if (η a) (range (embeddingReal Ω))ᶜ = 0 then (η a) (embeddingReal Ω '' s)
    else (embeddingReal Ω '' s).indicator 1 (Exists.choose ⋯)