cases Nat.eq_or_lt_of_le hidx2 with
| inl heq =>
  split at hgo
  . next hsplit =>
    rw [heq] at hsplit
    simp only [hsplit, ↓reduceDite]
    rw [← hgo]
    rw [go_getRef]
    rw [AIG.RefStream.getRef_push_ref_eq']
    . rw [go_denote_mem_prefix]
      . simp [heq]
      . simp [Ref.hgate]
    . omega
  . next hsplit =>
    rw [heq] at hsplit
    simp only [hsplit, ↓reduceDite]
    rw [← hgo]
    rw [go_getRef]
    rw [AIG.RefStream.getRef_push_ref_eq']
    . rw [go_denote_mem_prefix]
      . simp [heq]
      . simp [Ref.hgate]
    . omega
| inr =>
  split at hgo
  . rw [← hgo]
    rw [go_eq_eval_getLsb]
    omega
  . rw [← hgo]
    rw [go_eq_eval_getLsb]
    . split
      . omega
      . rfl
    . omega
case isTrue
α : Type
inst✝² : BEq α
inst✝¹ : Hashable α
inst✝ : DecidableEq α
aig : AIG α
w : Nat
input : aig.RefStream w
newWidth curr : Nat
hcurr : curr ≤ newWidth
s : aig.RefStream curr
assign : α → Bool
idx : Nat
hidx1 : idx < newWidth
hidx2 : curr ≤ idx
res : RefStreamEntry α newWidth
h✝ : curr < newWidth
hgo :
  (if hcurr2 : curr < w then go aig w input newWidth (curr + 1) ⋯ (s.pushRef (input.getRef curr hcurr2))
    else
      go (aig.mkConstCached false).aig w (input.cast ⋯) newWidth (curr + 1) ⋯
        ((s.cast ⋯).pushRef (aig.mkConstCached false).ref)) =
    res
⊢ ⟦{ aig := res.aig, ref := res.stream.getRef idx hidx1 }, assign⟧ =
    if hidx : idx < w then ⟦{ aig := aig, ref := input.getRef idx hidx }, assign⟧ else false
no goals