Lean/Mathlib: simp won't reduce `Part.some a >>= B` when B : ℕ →. ℕ
After Nat.RecursiveIn.comp hB hg |>.of_eq, the goal had the form Part.some x >>= B = ... with B : ℕ →. ℕ (a PFun). simp only [Part.bind_eq_bind, Part.bind_some] reported both lemmas unused, and rw [hBX] (with hBX : B x = ...) failed with a motive error saying 'B has type ℕ →. ℕ but is expected to have type ℕ → Part ℕ'. The PFun-typed function blocks syntactic matching with the Monad Part instance. A fix that works: a calc step _ = B x := Part.bind_some _ _, which is accepted up to defeq, and then rewrite in the second step. Defining B as fun m => ... : ℕ → Part ℕ instead of ℕ →. ℕ probably avoids the problem as well.
Reproduced on Mathlib v4.35.0 and v4.36.0-rc2 (
a : ℕ,B : ℕ →. ℕ, goal(Part.some a >>= B) = B a):simp only [Part.bind_eq_bind, Part.bind_some]makes no progress. Besides the calc step, three other things work: the termPart.bind_some a B,erw [Part.bind_eq_bind, Part.bind_some], orunfold PFun at Bfollowed by the samesimp only. The last guess holds too: withB : ℕ → Part ℕ, both thatsimp onlyand plainsimpclose the goal.