-- Mathlib/.lake/packages/lean4/src/lean/Init/Data/Array/Lemmas.lean
theorem getElem_extract_loop_ge (as bs : Array α) (size start : Nat) (hge : i ≥ bs.size)
    (h : i < (extract.loop as size start bs).size)
    (h' := getElem_extract_loop_ge_aux as bs size start hge h) :
    (extract.loop as size start bs)[i] = as[start + i - bs.size]

Proof state:
α : Type u_1
as : Array α
size : Nat
bs : Array α
start : Nat
this✝ : start < as.size
ih :
  ∀ (bs_1 : Array α) (start : Nat) (hge : bs.size ≥ bs_1.size) (h : bs.size < (extract.loop as size start bs_1).size)
    (h' : optParam (start + bs.size - bs_1.size < as.size) ⋯),
    (extract.loop as size start bs_1)[bs.size] = as[start + bs.size - bs_1.size]
hge : bs.size ≥ bs.size
h : bs.size < (extract.loop as (size + 1) start bs).size
h' : optParam (start + bs.size - bs.size < as.size) ⋯
this : bs.size < (extract.loop as size (start + 1) (bs.push as[start])).size
heq : (extract.loop as (size + 1) start bs)[bs.size] = (extract.loop as size (start + 1) (bs.push as[start]))[bs.size]
h₁ : bs.size < (bs.push as[start]).size
h₂ : bs.size < (extract.loop as size (start + 1) (bs.push as[start])).size
⊢ (extract.loop as size (start + 1) (bs.push as[start]))[bs.size] = as[start]

Tactic:
rw [getElem_extract_loop_lt as (bs.push as[start]) size (start+1) h₁ h₂, getElem_push_eq]

Result:
no goals

Proof state:
case succ
α : Type u_1
i : Nat
as : Array α
size : Nat
ih :
  ∀ (bs : Array α) (start : Nat) (hge : i ≥ bs.size) (h : i < (extract.loop as size start bs).size)
    (h' : optParam (start + i - bs.size < as.size) ⋯), (extract.loop as size start bs)[i] = as[start + i - bs.size]
bs : Array α
start : Nat
hge : i ≥ bs.size
h : i < (extract.loop as (size + 1) start bs).size
h' : optParam (start + i - bs.size < as.size) ⋯
⊢ (extract.loop as (size + 1) start bs)[i] = as[start + i - bs.size]

Tactic:
have : start < as.size := by
  apply Nat.lt_of_le_of_lt (Nat.le_add_right start (i - bs.size))
  rwa [← Nat.add_sub_assoc hge]

Result:
case succ
α : Type u_1
i : Nat
as : Array α
size : Nat
ih :
  ∀ (bs : Array α) (start : Nat) (hge : i ≥ bs.size) (h : i < (extract.loop as size start bs).size)
    (h' : optParam (start + i - bs.size < as.size) ⋯), (extract.loop as size start bs)[i] = as[start + i - bs.size]
bs : Array α
start : Nat
hge : i ≥ bs.size
h : i < (extract.loop as (size + 1) start bs).size
h' : optParam (start + i - bs.size < as.size) ⋯
this : start < as.size
⊢ (extract.loop as (size + 1) start bs)[i] = as[start + i - bs.size]

Proof state:
case succ
α : Type u_1
i : Nat
as : Array α
size : Nat
ih :
  ∀ (bs : Array α) (start : Nat) (hge : i ≥ bs.size) (h : i < (extract.loop as size start bs).size)
    (h' : optParam (start + i - bs.size < as.size) ⋯), (extract.loop as size start bs)[i] = as[start + i - bs.size]
bs : Array α
start : Nat
hge : i ≥ bs.size
h : i < (extract.loop as (size + 1) start bs).size
h' : optParam (start + i - bs.size < as.size) ⋯
this✝ : start < as.size
this : i < (extract.loop as size (start + 1) (bs.push as[start])).size
⊢ (extract.loop as (size + 1) start bs)[i] = as[start + i - bs.size]

Tactic:
have heq : (extract.loop as (size+1) start bs)[i] =
    (extract.loop as size (start+1) (bs.push as[start]))[i] := by
  congr 1; rw [extract_loop_succ]

Result:
case succ
α : Type u_1
i : Nat
as : Array α
size : Nat
ih :
  ∀ (bs : Array α) (start : Nat) (hge : i ≥ bs.size) (h : i < (extract.loop as size start bs).size)
    (h' : optParam (start + i - bs.size < as.size) ⋯), (extract.loop as size start bs)[i] = as[start + i - bs.size]
bs : Array α
start : Nat
hge : i ≥ bs.size
h : i < (extract.loop as (size + 1) start bs).size
h' : optParam (start + i - bs.size < as.size) ⋯
this✝ : start < as.size
this : i < (extract.loop as size (start + 1) (bs.push as[start])).size
heq : (extract.loop as (size + 1) start bs)[i] = (extract.loop as size (start + 1) (bs.push as[start]))[i]
⊢ (extract.loop as (size + 1) start bs)[i] = as[start + i - bs.size]

Proof state:
case refl
α : Type u_1
as : Array α
size : Nat
bs : Array α
start : Nat
this✝ : start < as.size
ih :
  ∀ (bs_1 : Array α) (start : Nat) (hge : bs.size ≥ bs_1.size) (h : bs.size < (extract.loop as size start bs_1).size)
    (h' : optParam (start + bs.size - bs_1.size < as.size) ⋯),
    (extract.loop as size start bs_1)[bs.size] = as[start + bs.size - bs_1.size]
hge : bs.size ≥ bs.size
h : bs.size < (extract.loop as (size + 1) start bs).size
h' : optParam (start + bs.size - bs.size < as.size) ⋯
this : bs.size < (extract.loop as size (start + 1) (bs.push as[start])).size
heq : (extract.loop as (size + 1) start bs)[bs.size] = (extract.loop as size (start + 1) (bs.push as[start]))[bs.size]
h₁ : bs.size < (bs.push as[start]).size
⊢ (extract.loop as size (start + 1) (bs.push as[start]))[bs.size] = as[start + bs.size - bs.size]

Tactic:
have h₂ : bs.size < (extract.loop as size (start+1) (bs.push as[start])).size := by
  rw [size_extract_loop]; apply Nat.lt_of_lt_of_le h₁; exact Nat.le_add_right ..

Result:
case refl
α : Type u_1
as : Array α
size : Nat
bs : Array α
start : Nat
this✝ : start < as.size
ih :
  ∀ (bs_1 : Array α) (start : Nat) (hge : bs.size ≥ bs_1.size) (h : bs.size < (extract.loop as size start bs_1).size)
    (h' : optParam (start + bs.size - bs_1.size < as.size) ⋯),
    (extract.loop as size start bs_1)[bs.size] = as[start + bs.size - bs_1.size]
hge : bs.size ≥ bs.size
h : bs.size < (extract.loop as (size + 1) start bs).size
h' : optParam (start + bs.size - bs.size < as.size) ⋯
this : bs.size < (extract.loop as size (start + 1) (bs.push as[start])).size
heq : (extract.loop as (size + 1) start bs)[bs.size] = (extract.loop as size (start + 1) (bs.push as[start]))[bs.size]
h₁ : bs.size < (bs.push as[start]).size
h₂ : bs.size < (extract.loop as size (start + 1) (bs.push as[start])).size
⊢ (extract.loop as size (start + 1) (bs.push as[start]))[bs.size] = as[start + bs.size - bs.size]

Proof state:
α : Type u_1
i : Nat
as : Array α
size : Nat
ih :
  ∀ (bs : Array α) (start : Nat) (hge : i ≥ bs.size) (h : i < (extract.loop as size start bs).size)
    (h' : optParam (start + i - bs.size < as.size) ⋯), (extract.loop as size start bs)[i] = as[start + i - bs.size]
bs : Array α
start : Nat
hge : i ≥ bs.size
h : i < (extract.loop as (size + 1) start bs).size
h' : optParam (start + i - bs.size < as.size) ⋯
this✝ : start < as.size
this : i < (extract.loop as size (start + 1) (bs.push as[start])).size
heq : (extract.loop as (size + 1) start bs)[i] = (extract.loop as size (start + 1) (bs.push as[start]))[i]
hi : ¬bs.size = i
⊢ (extract.loop as size (start + 1) (bs.push as[start]))[i] = as[start + i - bs.size]

Tactic:
have hge : bs.size + 1 ≤ i := Nat.lt_of_le_of_ne hge hi

Result:
α : Type u_1
i : Nat
as : Array α
size : Nat
ih :
  ∀ (bs : Array α) (start : Nat) (hge : i ≥ bs.size) (h : i < (extract.loop as size start bs).size)
    (h' : optParam (start + i - bs.size < as.size) ⋯), (extract.loop as size start bs)[i] = as[start + i - bs.size]
bs : Array α
start : Nat
hge✝ : i ≥ bs.size
h : i < (extract.loop as (size + 1) start bs).size
h' : optParam (start + i - bs.size < as.size) ⋯
this✝ : start < as.size
this : i < (extract.loop as size (start + 1) (bs.push as[start])).size
heq : (extract.loop as (size + 1) start bs)[i] = (extract.loop as size (start + 1) (bs.push as[start]))[i]
hi : ¬bs.size = i
hge : bs.size + 1 ≤ i
⊢ (extract.loop as size (start + 1) (bs.push as[start]))[i] = as[start + i - bs.size]