-- Mathlib/.lake/packages/lean4/src/lean/Init/Data/List/ToArray.lean
theorem findSomeM?_toArray [Monad m] [LawfulMonad m] (f : α → m (Option β)) (l : List α) :
    l.toArray.findSomeM? f = l.findSomeM? f

Proof state:
case cons
m : Type u_1 → Type u_2
α : Type u_3
β : Type u_1
inst✝¹ : Monad m
inst✝ : LawfulMonad m
f : α → m (Option β)
a : α
l : List α
ih :
  (do
      let r ←
        forIn l ⟨none, PUnit.unit⟩ fun a r => do
            let __do_lift ← f a
            match __do_lift with
              | some b => pure (ForInStep.done ⟨some (some b), PUnit.unit⟩)
              | x => pure (ForInStep.yield ⟨none, PUnit.unit⟩)
      match r.fst with
        | none => pure none
        | some a => pure a) =
    findSomeM? f l
⊢ (do
      let r ←
        forIn (a :: l) ⟨none, PUnit.unit⟩ fun a r => do
            let __do_lift ← f a
            match __do_lift with
              | some b => pure (ForInStep.done ⟨some (some b), PUnit.unit⟩)
              | x => pure (ForInStep.yield ⟨none, PUnit.unit⟩)
      match r.fst with
        | none => pure none
        | some a => pure a) =
    findSomeM? f (a :: l)

Tactic:
simp only [forIn_cons, LawfulMonad.bind_assoc, findSomeM?]

Result:
case cons
m : Type u_1 → Type u_2
α : Type u_3
β : Type u_1
inst✝¹ : Monad m
inst✝ : LawfulMonad m
f : α → m (Option β)
a : α
l : List α
ih :
  (do
      let r ←
        forIn l ⟨none, PUnit.unit⟩ fun a r => do
            let __do_lift ← f a
            match __do_lift with
              | some b => pure (ForInStep.done ⟨some (some b), PUnit.unit⟩)
              | x => pure (ForInStep.yield ⟨none, PUnit.unit⟩)
      match r.fst with
        | none => pure none
        | some a => pure a) =
    findSomeM? f l
⊢ (do
      let x ← f a
      let x ←
        match x with
          | some b => pure (ForInStep.done ⟨some (some b), PUnit.unit⟩)
          | x => pure (ForInStep.yield ⟨none, PUnit.unit⟩)
      let r ←
        match x with
          | ForInStep.done b => pure b
          | ForInStep.yield b =>
            forIn l b fun a r => do
              let __do_lift ← f a
              match __do_lift with
                | some b => pure (ForInStep.done ⟨some (some b), PUnit.unit⟩)
                | x => pure (ForInStep.yield ⟨none, PUnit.unit⟩)
      match r.fst with
        | none => pure none
        | some a => pure a) =
    do
    let __do_lift ← f a
    match __do_lift with
      | some b => pure (some b)
      | none => findSomeM? f l

Proof state:
m : Type u_1 → Type u_2
α : Type u_3
β : Type u_1
inst✝¹ : Monad m
inst✝ : LawfulMonad m
f : α → m (Option β)
l : List α
⊢ Array.findSomeM? f l.toArray = findSomeM? f l

Tactic:
rw [Array.findSomeM?]

Result:
m : Type u_1 → Type u_2
α : Type u_3
β : Type u_1
inst✝¹ : Monad m
inst✝ : LawfulMonad m
f : α → m (Option β)
l : List α
⊢ (do
      let r ←
        forIn l.toArray ⟨none, PUnit.unit⟩ fun a r =>
            let r := r.snd;
            do
            let __do_lift ← f a
            match __do_lift with
              | some b => pure (ForInStep.done ⟨some (some b), PUnit.unit⟩)
              | x => do
                pure PUnit.unit
                pure (ForInStep.yield ⟨none, PUnit.unit⟩)
      let __do_jp : PUnit → m (Option β) := fun y => pure none
      match r.fst with
        | none => do
          let y ← pure PUnit.unit
          __do_jp y
        | some a => pure a) =
    findSomeM? f l