case node_next_right x i y hi hl hr hx' hx h IH =>
  if hdesc' : Descendant (2*i+2) k then
    have ⟨l,hl,hld,IH⟩ := @IH hk hdesc'
    simp only [IH, Subarray.getElem_swap]
    if hrl : 2*i+2 = l then
      cases hrl; simp only [ite_true]
      exact ⟨i, hi, .refl i, rfl⟩
    else
      rewrite [if_neg hrl, if_neg <| Nat.ne_of_lt <| trans (lt_child_right i) hld.le]
      exact ⟨l, hl, .trans (.child_right i) hld, rfl⟩
  else
    simp only [h.get_not_descendant k hdesc', Subarray.getElem_swap]
    rewrite [if_neg (c:=2*i+2=k) fun h => by cases h; exact hdesc' (.refl _)]
    if hik : i = k then
      cases hik; simp only [ite_true]
      exact ⟨2*k+2, hr, .child_right 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] = false
hx : lt x[i] x[2 * i + 2] = true
h : heapifyDown.OpSpec lt (Subarray.swap x { val := i, isLt := hi } { val := 2 * i + 2, isLt := hr }) (2 * i + 2) y
IH :
  ∀ (hk : k < Subarray.size (Subarray.swap x { val := i, isLt := hi } { val := 2 * i + 2, isLt := hr })),
    Descendant (2 * i + 2) k →
      ∃ l hl,
        Descendant (2 * i + 2) l ∧ y[k] = (Subarray.swap x { val := i, isLt := hi } { val := 2 * i + 2, isLt := hr })[l]
hk : k < Subarray.size x
hdesc : Descendant i k
⊢ ∃ l hl_1, Descendant i l ∧ y[k] = x[l]
no goals