-- Mathlib/.lake/packages/lean4/src/lean/Init/Data/List/ToArray.lean
theorem findFinIdx?_loop_toArray (w : l' = l.drop j) :
    Array.findFinIdx?.loop p l.toArray j = List.findFinIdx?.go p l l' j h

Proof state:
α✝ : Type u_1
p : α✝ → Bool
j : Nat
l : List α✝
h' : j < l.toArray.size
a : α✝
l' : List α✝
h : (a :: l').length + j = l.length
w : a :: l' = drop j l
⊢ l[j] = a

Tactic:
rw [drop_eq_getElem_cons] at w

Result:
α✝ : Type u_1
p : α✝ → Bool
j : Nat
l : List α✝
h' : j < l.toArray.size
a : α✝
l' : List α✝
h : (a :: l').length + j = l.length
w✝ : a :: l' = drop j l
w : a :: l' = l[j] :: drop (j + 1) l
⊢ l[j] = a

α✝ : Type u_1
p : α✝ → Bool
j : Nat
l : List α✝
h' : j < l.toArray.size
a : α✝
l' : List α✝
h : (a :: l').length + j = l.length
w : a :: l' = drop j l
⊢ j < l.length

Proof state:
α✝ : Type u_1
l' : List α✝
p : α✝ → Bool
j : Nat
l : List α✝
h : l'.length + j = l.length
w : l' = drop j l
⊢ (if h : j < l.toArray.size then if p l.toArray[j] = true then some ⟨j, h⟩ else findFinIdx?.loop p l.toArray (j + 1)
    else none) =
    findFinIdx?.go p l l' j h

Tactic:
unfold findFinIdx?.go

Result:
α✝ : Type u_1
l' : List α✝
p : α✝ → Bool
j : Nat
l : List α✝
h : l'.length + j = l.length
w : l' = drop j l
⊢ (if h : j < l.toArray.size then if p l.toArray[j] = true then some ⟨j, h⟩ else findFinIdx?.loop p l.toArray (j + 1)
    else none) =
    match l', j, h with
    | [], x, x_1 => none
    | a :: l_1, i, h => if p a = true then some ⟨i, ⋯⟩ else findFinIdx?.go p l l_1 (i + 1) ⋯

Proof state:
case isTrue.cons.isFalse
α✝ : Type u_1
p : α✝ → Bool
j : Nat
l : List α✝
h' : j < l.toArray.size
a : α✝
l' : List α✝
h : (a :: l').length + j = l.length
w : a :: l' = drop j l
this : l[j] = a
h✝ : ¬p a = true
⊢ findFinIdx?.loop p l.toArray (j + 1) = findFinIdx?.go p l l' (j + 1) ⋯

Tactic:
simp only [length_cons] at h

Result:
case isTrue.cons.isFalse
α✝ : Type u_1
p : α✝ → Bool
j : Nat
l : List α✝
h' : j < l.toArray.size
a : α✝
l' : List α✝
h : l'.length + 1 + j = l.length
w : a :: l' = drop j l
this : l[j] = a
h✝ : ¬p a = true
⊢ findFinIdx?.loop p l.toArray (j + 1) = findFinIdx?.go p l l' (j + 1) ⋯

Proof state:
case isTrue.nil
α✝ : Type u_1
p : α✝ → Bool
j : Nat
l : List α✝
h' : j < l.toArray.size
h : [].length + j = l.length
w : [] = drop j l
⊢ (if p l.toArray[j] = true then some ⟨j, h'⟩ else findFinIdx?.loop p l.toArray (j + 1)) =
    match [], j, h with
    | [], x, x_1 => none
    | a :: l_1, i, h => if p a = true then some ⟨i, ⋯⟩ else findFinIdx?.go p l l_1 (i + 1) ⋯

Tactic:
simp at h h'

Result:
case isTrue.nil
α✝ : Type u_1
p : α✝ → Bool
j : Nat
l : List α✝
h'✝ : j < l.toArray.size
h✝ : [].length + j = l.length
w : [] = drop j l
h : j = l.length
h' : j < l.length
⊢ (if p l.toArray[j] = true then some ⟨j, h'✝⟩ else findFinIdx?.loop p l.toArray (j + 1)) =
    match [], j, h✝ with
    | [], x, x_1 => none
    | a :: l_1, i, h => if p a = true then some ⟨i, ⋯⟩ else findFinIdx?.go p l l_1 (i + 1) ⋯

Proof state:
α✝ : Type u_1
l' : List α✝
p : α✝ → Bool
j : Nat
l : List α✝
h : l'.length + j = l.length
w : l' = drop j l
h' : ¬j < l.toArray.size
⊢ l' = []

Tactic:
simp_all

Result:
no goals

Proof state:
case isTrue.cons.isFalse
α✝ : Type u_1
p : α✝ → Bool
j : Nat
l : List α✝
h' : j < l.toArray.size
a : α✝
l' : List α✝
h : l'.length + 1 + j = l.length
w : a :: l' = drop j l
this✝ : l[j] = a
h✝ : ¬p a = true
this : l.length - (j + 1) < l.length - j
⊢ l' = drop (j + 1) l

Tactic:
rw [drop_add_one_eq_tail_drop, ← w, tail_cons]

Result:
no goals

Proof state:
case isTrue.cons.isFalse
α✝ : Type u_1
p : α✝ → Bool
j : Nat
l : List α✝
h' : j < l.toArray.size
a : α✝
l' : List α✝
h : l'.length + 1 + j = l.length
w : a :: l' = drop j l
this✝ : l[j] = a
h✝ : ¬p a = true
this : l.length - (j + 1) < l.length - j
⊢ findFinIdx?.loop p l.toArray (j + 1) = findFinIdx?.go p l l' (j + 1) ⋯

Tactic:
rw [findFinIdx?_loop_toArray]

Result:
case isTrue.cons.isFalse
α✝ : Type u_1
p : α✝ → Bool
j : Nat
l : List α✝
h' : j < l.toArray.size
a : α✝
l' : List α✝
h : l'.length + 1 + j = l.length
w : a :: l' = drop j l
this✝ : l[j] = a
h✝ : ¬p a = true
this : l.length - (j + 1) < l.length - j
⊢ l' = drop (j + 1) l

Proof state:
case isFalse
α✝ : Type u_1
l' : List α✝
p : α✝ → Bool
j : Nat
l : List α✝
h : l'.length + j = l.length
w : l' = drop j l
h' : ¬j < l.toArray.size
this : l' = []
⊢ none =
    match l', j, h with
    | [], x, x_1 => none
    | a :: l_1, i, h => if p a = true then some ⟨i, ⋯⟩ else findFinIdx?.go p l l_1 (i + 1) ⋯

Tactic:
subst this

Result:
case isFalse
α✝ : Type u_1
p : α✝ → Bool
j : Nat
l : List α✝
h' : ¬j < l.toArray.size
h : [].length + j = l.length
w : [] = drop j l
⊢ none =
    match [], j, h with
    | [], x, x_1 => none
    | a :: l_1, i, h => if p a = true then some ⟨i, ⋯⟩ else findFinIdx?.go p l l_1 (i + 1) ⋯

Proof state:
case isTrue.cons
α✝ : Type u_1
p : α✝ → Bool
j : Nat
l : List α✝
h' : j < l.toArray.size
a : α✝
l' : List α✝
h : (a :: l').length + j = l.length
w : a :: l' = drop j l
this : l[j] = a
⊢ (if p a = true then some ⟨j, h'⟩ else findFinIdx?.loop p l.toArray (j + 1)) =
    if p a = true then some ⟨j, ⋯⟩ else findFinIdx?.go p l l' (j + 1) ⋯

Tactic:
split

Result:
case isTrue.cons.isTrue
α✝ : Type u_1
p : α✝ → Bool
j : Nat
l : List α✝
h' : j < l.toArray.size
a : α✝
l' : List α✝
h : (a :: l').length + j = l.length
w : a :: l' = drop j l
this : l[j] = a
h✝ : p a = true
⊢ some ⟨j, h'⟩ = some ⟨j, ⋯⟩

case isTrue.cons.isFalse
α✝ : Type u_1
p : α✝ → Bool
j : Nat
l : List α✝
h' : j < l.toArray.size
a : α✝
l' : List α✝
h : (a :: l').length + j = l.length
w : a :: l' = drop j l
this : l[j] = a
h✝ : ¬p a = true
⊢ findFinIdx?.loop p l.toArray (j + 1) = findFinIdx?.go p l l' (j + 1) ⋯