rw[Rand.swap_bind]
R : Type ?u.59471
inst✝¹³ : RealScalar R
X : Type ?u.59474
inst✝¹² : MeasurableSpace X
inst✝¹¹ : AddCommGroup X
inst✝¹⁰ : Module ℝ X
Y : Type ?u.60079
inst✝⁹ : AddCommGroup Y
inst✝⁸ : Module ℝ Y
inst✝⁷ : MeasurableSpace Y
Z : Type ?u.60683
inst✝⁶ : AddCommGroup Z
inst✝⁵ : Module ℝ Z
C : ℕ → Type
inst✝⁴ : (n : ℕ) → AddCommGroup (C n)
inst✝³ : (n : ℕ) → Module ℝ (C n)
inst✝² : (n : ℕ) → MeasurableSpace (C n)
D : ℕ → Type
inst✝¹ inst✝ : (n : ℕ) → MeasurableSpace (D n)
x₀ : C 0
r : (n : ℕ) → Rand (D n)
f : (n : ℕ) → C n → D n → C (n + 1)
hf : ∀ (n : ℕ) (d : D n), IsAffineMap ℝ fun x => f n x d
n : ℕ
hn :
  (Nat.recOn n x₀ fun n x => (r n).𝔼 (f n x)) =
    mean
      (Nat.recOn n (pure x₀) fun n x => do
        let x' ← x
        let y' ← r n
        pure (f n x' y'))
⊢ (mean do
      let x' ← r n
      (Nat.rec (pure x₀)
              (fun n x => do
                let x' ← x
                let y' ← r n
                pure (f n x' y'))
              n).map
          fun x => f n x x') =
    mean do
      let x' ←
        Nat.rec (pure x₀)
            (fun n x => do
              let x' ← x
              let y' ← r n
              pure (f n x' y'))
            n
      let y' ← r n
      pure (f n x' y')
no goals