if hdesc' : Descendant (2*i+1) k then
  have ⟨l,hl,hld,IH⟩ := @IH hk hdesc'
  simp only [IH, Subarray.getElem_swap]
  if hll : 2*i+1 = l then
    cases hll; simp only [ite_true]
    exact ⟨i, hi, .refl i, rfl⟩
  else
    rewrite [if_neg hll, if_neg <| Nat.ne_of_lt <| trans (lt_child_left i) hld.le]
    exact ⟨l, hl, .trans (.child_left i) hld, rfl⟩
else
  simp only [h.get_not_descendant k hdesc', Subarray.getElem_swap]
  rewrite [if_neg (c:=2*i+1=k) fun h => by cases h; exact hdesc' (.refl _)]
  if hik : i = k then
    cases hik; simp only [ite_true]
    exact ⟨2*k+1, hl, .child_left k, rfl⟩
  else
    simp only [if_neg hik]
    exact ⟨k, hk, hdesc, rfl⟩
α : Type u
lt : α → α → Bool
x✝ : Subarray α
i✝ : Nat
y✝ : Subarray α
k : Nat
x : Subarray α
i : Nat
y : Subarray α
hi : i < Subarray.size x
hl : 2 * i + 1 < Subarray.size x
hr : 2 * i + 2 < Subarray.size x
hx' : lt x[2 * i + 2] x[2 * i + 1] = true
hx : lt x[i] x[2 * i + 1] = true
h : heapifyDown.OpSpec lt (Subarray.swap x { val := i, isLt := hi } { val := 2 * i + 1, isLt := hl }) (2 * i + 1) y
IH :
  ∀ (hk : k < Subarray.size (Subarray.swap x { val := i, isLt := hi } { val := 2 * i + 1, isLt := hl })),
    Descendant (2 * i + 1) k →
      ∃ l hl_1,
        Descendant (2 * i + 1) l ∧ y[k] = (Subarray.swap x { val := i, isLt := hi } { val := 2 * i + 1, isLt := hl })[l]
hk : k < Subarray.size x
hdesc : Descendant i k
⊢ ∃ l hl_1, Descendant i l ∧ y[k] = x[l]
no goals