Theorem: Pmf.bindOnSupport_bindOnSupport
File: Mathlib/Probability/ProbabilityMassFunction/Monad.lean

tactic: refine' Pmf.ext fun a => _
state_before: α : Type u_1
β : Type u_2
γ : Type u_3
p✝ : Pmf α
f✝ : (a : α) → a ∈ support p✝ → Pmf β
p : Pmf α
f : (a : α) → a ∈ support p → Pmf β
g : (b : β) → b ∈ support (bindOnSupport p f) → Pmf γ
⊢ bindOnSupport (bindOnSupport p f) g =
    bindOnSupport p fun a ha => bindOnSupport (f a ha) fun b hb => g b (_ : b ∈ support (bindOnSupport p f))

tactic: dsimp only [bindOnSupport_apply]
state_before: α : Type u_1
β : Type u_2
γ : Type u_3
p✝ : Pmf α
f✝ : (a : α) → a ∈ support p✝ → Pmf β
p : Pmf α
f : (a : α) → a ∈ support p → Pmf β
g : (b : β) → b ∈ support (bindOnSupport p f) → Pmf γ
a : γ
⊢ ↑(bindOnSupport (bindOnSupport p f) g) a =
    ↑(bindOnSupport p fun a ha => bindOnSupport (f a ha) fun b hb => g b (_ : b ∈ support (bindOnSupport p f))) a

tactic: simp only [← tsum_dite_right, ENNReal.tsum_mul_left.symm, ENNReal.tsum_mul_right.symm]
state_before: α : Type u_1
β : Type u_2
γ : Type u_3
p✝ : Pmf α
f✝ : (a : α) → a ∈ support p✝ → Pmf β
p : Pmf α
f : (a : α) → a ∈ support p → Pmf β
g : (b : β) → b ∈ support (bindOnSupport p f) → Pmf γ
a : γ
⊢ (∑' (a_1 : β),
      (∑' (a : α), ↑p a * if h : ↑p a = 0 then 0 else ↑(f a h) a_1) *
        if h : (∑' (a : α), ↑p a * if h : ↑p a = 0 then 0 else ↑(f a h) a_1) = 0 then 0 else ↑(g a_1 h) a) =
    ∑' (a_1 : α),
      ↑p a_1 *
        if h : ↑p a_1 = 0 then 0
        else
          ∑' (a_2 : β),
            ↑(f a_1 h) a_2 * if h : ↑(f a_1 h) a_2 = 0 then 0 else ↑(g a_2 (_ : a_2 ∈ support (bindOnSupport p f))) a

tactic: simp only [ENNReal.tsum_eq_zero, dite_eq_left_iff]
state_before: α : Type u_1
β : Type u_2
γ : Type u_3
p✝ : Pmf α
f✝ : (a : α) → a ∈ support p✝ → Pmf β
p : Pmf α
f : (a : α) → a ∈ support p → Pmf β
g : (b : β) → b ∈ support (bindOnSupport p f) → Pmf γ
a : γ
⊢ (∑' (a_1 : β) (i : α),
      (↑p i * if h : ↑p i = 0 then 0 else ↑(f i h) a_1) *
        if h : (∑' (a : α), ↑p a * if h : ↑p a = 0 then 0 else ↑(f a h) a_1) = 0 then 0 else ↑(g a_1 h) a) =
    ∑' (a_1 : α) (i : β),
      ↑p a_1 *
        if h : ↑p a_1 = 0 then 0
        else ↑(f a_1 h) i * if h : ↑(f a_1 h) i = 0 then 0 else ↑(g i (_ : i ∈ support (bindOnSupport p f))) a

tactic: refine' ENNReal.tsum_comm.trans (tsum_congr fun a' => tsum_congr fun b => _)
state_before: α : Type u_1
β : Type u_2
γ : Type u_3
p✝ : Pmf α
f✝ : (a : α) → a ∈ support p✝ → Pmf β
p : Pmf α
f : (a : α) → a ∈ support p → Pmf β
g : (b : β) → b ∈ support (bindOnSupport p f) → Pmf γ
a : γ
⊢ (∑' (a_1 : β) (i : α),
      (↑p i * if h : ↑p i = 0 then 0 else ↑(f i h) a_1) *
        if h : ∀ (i : α), (↑p i * if h : ↑p i = 0 then 0 else ↑(f i h) a_1) = 0 then 0
        else ↑(g a_1 (_ : ¬(∑' (a : α), ↑p a * if h : ↑p a = 0 then 0 else ↑(f a h) a_1) = 0)) a) =
    ∑' (a_1 : α) (i : β),
      ↑p a_1 *
        if h : ↑p a_1 = 0 then 0
        else ↑(f a_1 h) i * if h : ↑(f a_1 h) i = 0 then 0 else ↑(g i (_ : i ∈ support (bindOnSupport p f))) a

tactic: split_ifs with h _ h_1 _ h_2
state_before: α : Type u_1
β : Type u_2
γ : Type u_3
p✝ : Pmf α
f✝ : (a : α) → a ∈ support p✝ → Pmf β
p : Pmf α
f : (a : α) → a ∈ support p → Pmf β
g : (b : β) → b ∈ support (bindOnSupport p f) → Pmf γ
a : γ
a' : α
b : β
⊢ ((↑p a' * if h : ↑p a' = 0 then 0 else ↑(f a' h) b) *
      if h : ∀ (i : α), (↑p i * if h : ↑p i = 0 then 0 else ↑(f i h) b) = 0 then 0
      else ↑(g b (_ : ¬(∑' (a : α), ↑p a * if h : ↑p a = 0 then 0 else ↑(f a h) b) = 0)) a) =
    ↑p a' *
      if h : ↑p a' = 0 then 0
      else ↑(f a' h) b * if h : ↑(f a' h) b = 0 then 0 else ↑(g b (_ : b ∈ support (bindOnSupport p f))) a

tactic: any_goals ring1
state_before: case inl.inl
α : Type u_1
β : Type u_2
γ : Type u_3
p✝ : Pmf α
f✝ : (a : α) → a ∈ support p✝ → Pmf β
p : Pmf α
f : (a : α) → a ∈ support p → Pmf β
g : (b : β) → b ∈ support (bindOnSupport p f) → Pmf γ
a : γ
a' : α
b : β
h : ↑p a' = 0
h✝ : ∀ (i : α), (↑p i * if h : ↑p i = 0 then 0 else ↑(f i h) b) = 0
⊢ ↑p a' * 0 * 0 = ↑p a' * 0

case inl.inr
α : Type u_1
β : Type u_2
γ : Type u_3
p✝ : Pmf α
f✝ : (a : α) → a ∈ support p✝ → Pmf β
p : Pmf α
f : (a : α) → a ∈ support p → Pmf β
g : (b : β) → b ∈ support (bindOnSupport p f) → Pmf γ
a : γ
a' : α
b : β
h : ↑p a' = 0
h✝ : ¬∀ (i : α), (↑p i * if h : ↑p i = 0 then 0 else ↑(f i h) b) = 0
⊢ ↑p a' * 0 * ↑(g b (_ : ¬(∑' (a : α), ↑p a * if h : ↑p a = 0 then 0 else ↑(f a h) b) = 0)) a = ↑p a' * 0

case inr.inl.inl
α : Type u_1
β : Type u_2
γ : Type u_3
p✝ : Pmf α
f✝ : (a : α) → a ∈ support p✝ → Pmf β
p : Pmf α
f : (a : α) → a ∈ support p → Pmf β
g : (b : β) → b ∈ support (bindOnSupport p f) → Pmf γ
a : γ
a' : α
b : β
h : ¬↑p a' = 0
h_1 : ∀ (i : α), (↑p i * if h : ↑p i = 0 then 0 else ↑(f i h) b) = 0
h✝ : ↑(f a' h) b = 0
⊢ ↑p a' * ↑(f a' h) b * 0 = ↑p a' * (↑(f a' h) b * 0)

case inr.inl.inr
α : Type u_1
β : Type u_2
γ : Type u_3
p✝ : Pmf α
f✝ : (a : α) → a ∈ support p✝ → Pmf β
p : Pmf α
f : (a : α) → a ∈ support p → Pmf β
g : (b : β) → b ∈ support (bindOnSupport p f) → Pmf γ
a : γ
a' : α
b : β
h : ¬↑p a' = 0
h_1 : ∀ (i : α), (↑p i * if h : ↑p i = 0 then 0 else ↑(f i h) b) = 0
h✝ : ¬↑(f a' h) b = 0
⊢ ↑p a' * ↑(f a' h) b * 0 = ↑p a' * (↑(f a' h) b * ↑(g b (_ : b ∈ support (bindOnSupport p f))) a)

case inr.inr.inl
α : Type u_1
β : Type u_2
γ : Type u_3
p✝ : Pmf α
f✝ : (a : α) → a ∈ support p✝ → Pmf β
p : Pmf α
f : (a : α) → a ∈ support p → Pmf β
g : (b : β) → b ∈ support (bindOnSupport p f) → Pmf γ
a : γ
a' : α
b : β
h : ¬↑p a' = 0
h_1 : ¬∀ (i : α), (↑p i * if h : ↑p i = 0 then 0 else ↑(f i h) b) = 0
h_2 : ↑(f a' h) b = 0
⊢ ↑p a' * ↑(f a' h) b * ↑(g b (_ : ¬(∑' (a : α), ↑p a * if h : ↑p a = 0 then 0 else ↑(f a h) b) = 0)) a =
    ↑p a' * (↑(f a' h) b * 0)

case inr.inr.inr
α : Type u_1
β : Type u_2
γ : Type u_3
p✝ : Pmf α
f✝ : (a : α) → a ∈ support p✝ → Pmf β
p : Pmf α
f : (a : α) → a ∈ support p → Pmf β
g : (b : β) → b ∈ support (bindOnSupport p f) → Pmf γ
a : γ
a' : α
b : β
h : ¬↑p a' = 0
h_1 : ¬∀ (i : α), (↑p i * if h : ↑p i = 0 then 0 else ↑(f i h) b) = 0
h_2 : ¬↑(f a' h) b = 0
⊢ ↑p a' * ↑(f a' h) b * ↑(g b (_ : ¬(∑' (a : α), ↑p a * if h : ↑p a = 0 then 0 else ↑(f a h) b) = 0)) a =
    ↑p a' * (↑(f a' h) b * ↑(g b (_ : b ∈ support (bindOnSupport p f))) a)

tactic: ring1
state_before: case inr.inr.inr
α : Type u_1
β : Type u_2
γ : Type u_3
p✝ : Pmf α
f✝ : (a : α) → a ∈ support p✝ → Pmf β
p : Pmf α
f : (a : α) → a ∈ support p → Pmf β
g : (b : β) → b ∈ support (bindOnSupport p f) → Pmf γ
a : γ
a' : α
b : β
h : ¬↑p a' = 0
h_1 : ¬∀ (i : α), (↑p i * if h : ↑p i = 0 then 0 else ↑(f i h) b) = 0
h_2 : ¬↑(f a' h) b = 0
⊢ ↑p a' * ↑(f a' h) b * ↑(g b (_ : ¬(∑' (a : α), ↑p a * if h : ↑p a = 0 then 0 else ↑(f a h) b) = 0)) a =
    ↑p a' * (↑(f a' h) b * ↑(g b (_ : b ∈ support (bindOnSupport p f))) a)

tactic: have := h_1 a'
state_before: case inr.inl.inr
α : Type u_1
β : Type u_2
γ : Type u_3
p✝ : Pmf α
f✝ : (a : α) → a ∈ support p✝ → Pmf β
p : Pmf α
f : (a : α) → a ∈ support p → Pmf β
g : (b : β) → b ∈ support (bindOnSupport p f) → Pmf γ
a : γ
a' : α
b : β
h : ¬↑p a' = 0
h_1 : ∀ (i : α), (↑p i * if h : ↑p i = 0 then 0 else ↑(f i h) b) = 0
h✝ : ¬↑(f a' h) b = 0
⊢ ↑p a' * ↑(f a' h) b * 0 = ↑p a' * (↑(f a' h) b * ↑(g b (_ : b ∈ support (bindOnSupport p f))) a)

tactic: simp [h] at this
state_before: case inr.inl.inr
α : Type u_1
β : Type u_2
γ : Type u_3
p✝ : Pmf α
f✝ : (a : α) → a ∈ support p✝ → Pmf β
p : Pmf α
f : (a : α) → a ∈ support p → Pmf β
g : (b : β) → b ∈ support (bindOnSupport p f) → Pmf γ
a : γ
a' : α
b : β
h : ¬↑p a' = 0
h_1 : ∀ (i : α), (↑p i * if h : ↑p i = 0 then 0 else ↑(f i h) b) = 0
h✝ : ¬↑(f a' h) b = 0
this : (↑p a' * if h : ↑p a' = 0 then 0 else ↑(f a' h) b) = 0
⊢ ↑p a' * ↑(f a' h) b * 0 = ↑p a' * (↑(f a' h) b * ↑(g b (_ : b ∈ support (bindOnSupport p f))) a)

tactic: contradiction
state_before: case inr.inl.inr
α : Type u_1
β : Type u_2
γ : Type u_3
p✝ : Pmf α
f✝ : (a : α) → a ∈ support p✝ → Pmf β
p : Pmf α
f : (a : α) → a ∈ support p → Pmf β
g : (b : β) → b ∈ support (bindOnSupport p f) → Pmf γ
a : γ
a' : α
b : β
h : ¬↑p a' = 0
h_1 : ∀ (i : α), (↑p i * if h : ↑p i = 0 then 0 else ↑(f i h) b) = 0
h✝ : ¬↑(f a' h) b = 0
this : ↑(f a' (_ : ¬↑p a' = 0)) b = 0
⊢ ↑p a' * ↑(f a' h) b * 0 = ↑p a' * (↑(f a' h) b * ↑(g b (_ : b ∈ support (bindOnSupport p f))) a)

tactic: simp [h_2]
state_before: case inr.inr.inl
α : Type u_1
β : Type u_2
γ : Type u_3
p✝ : Pmf α
f✝ : (a : α) → a ∈ support p✝ → Pmf β
p : Pmf α
f : (a : α) → a ∈ support p → Pmf β
g : (b : β) → b ∈ support (bindOnSupport p f) → Pmf γ
a : γ
a' : α
b : β
h : ¬↑p a' = 0
h_1 : ¬∀ (i : α), (↑p i * if h : ↑p i = 0 then 0 else ↑(f i h) b) = 0
h_2 : ↑(f a' h) b = 0
⊢ ↑p a' * ↑(f a' h) b * ↑(g b (_ : ¬(∑' (a : α), ↑p a * if h : ↑p a = 0 then 0 else ↑(f a h) b) = 0)) a =
    ↑p a' * (↑(f a' h) b * 0)