-- Mathlib/.lake/packages/lean4/src/lean/Std/Tactic/BVDecide/Bitblast/BVExpr/Circuit/Lemmas/Const.lean
theorem go_get_aux (aig : AIG α) (c : BitVec w) (curr : Nat) (hcurr : curr ≤ w)
    (s : AIG.RefVec aig curr) :
    -- `hfoo` makes it possible to `generalize` below. With a concrete proof term this
    -- `generalize` would produce a type incorrect term as the proof term would talk about
    -- a `go` application instead of the fresh variable.
    ∀ (idx : Nat) (hidx : idx < curr) (hfoo),
        (go aig c curr s hcurr).vec.get idx (by omega) = (s.get idx hidx).cast hfoo

Proof state:
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
w : Nat
aig : AIG α
c : BitVec w
curr : Nat
hcurr : curr ≤ w
s : aig.RefVec curr
idx : Nat
hidx : idx < curr
⊢ ∀ (hfoo : aig.decls.size ≤ (go aig c curr s hcurr).aig.decls.size),
    (go aig c curr s hcurr).vec.get idx ⋯ = (s.get idx hidx).cast hfoo

Tactic:
generalize hgo : go aig c curr s hcurr = res

Result:
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
w : Nat
aig : AIG α
c : BitVec w
curr : Nat
hcurr : curr ≤ w
s : aig.RefVec curr
idx : Nat
hidx : idx < curr
res : RefVecEntry α w
hgo : go aig c curr s hcurr = res
⊢ ∀ (hfoo : aig.decls.size ≤ res.aig.decls.size), res.vec.get idx ⋯ = (s.get idx hidx).cast hfoo

Proof state:
case isTrue.hidx
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
w : Nat
aig : AIG α
c : BitVec w
curr : Nat
hcurr : curr ≤ w
s : aig.RefVec curr
idx : Nat
hidx : idx < curr
res : RefVecEntry α w
h✝ : curr < w
hgo :
  go (aig.mkConstCached (c.getLsbD curr)).aig c (curr + 1) ((s.cast ⋯).push (aig.mkConstCached (c.getLsbD curr)).ref)
      ⋯ =
    res
hfoo :
  aig.decls.size ≤
    (go (aig.mkConstCached (c.getLsbD curr)).aig c (curr + 1) ((s.cast ⋯).push (aig.mkConstCached (c.getLsbD curr)).ref)
            ⋯).aig.decls.size
⊢ idx < curr

Tactic:
assumption

Result:
no goals

Proof state:
case isFalse
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
w : Nat
aig : AIG α
c : BitVec w
curr : Nat
hcurr : curr ≤ w
s : aig.RefVec curr
idx : Nat
hidx : idx < curr
res : RefVecEntry α w
h✝ : ¬curr < w
hgo : { aig := aig, vec := ⋯ ▸ s } = res
⊢ ∀ (hfoo : True), (⋯ ▸ s).get idx ⋯ = (s.get idx hidx).cast ⋯

Tactic:
obtain rfl : curr = w := by omega

Result:
case isFalse
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
aig : AIG α
curr : Nat
s : aig.RefVec curr
idx : Nat
hidx : idx < curr
c : BitVec curr
hcurr : curr ≤ curr
res : RefVecEntry α curr
h✝ : ¬curr < curr
hgo : { aig := aig, vec := ⋯ ▸ s } = res
⊢ ∀ (hfoo : True), (⋯ ▸ s).get idx ⋯ = (s.get idx hidx).cast ⋯

Proof state:
case isTrue
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
w : Nat
aig : AIG α
c : BitVec w
curr : Nat
hcurr : curr ≤ w
s : aig.RefVec curr
idx : Nat
hidx : idx < curr
res : RefVecEntry α w
h✝ : curr < w
hgo :
  go (aig.mkConstCached (c.getLsbD curr)).aig c (curr + 1) ((s.cast ⋯).push (aig.mkConstCached (c.getLsbD curr)).ref)
      ⋯ =
    res
hfoo :
  aig.decls.size ≤
    (go (aig.mkConstCached (c.getLsbD curr)).aig c (curr + 1) ((s.cast ⋯).push (aig.mkConstCached (c.getLsbD curr)).ref)
            ⋯).aig.decls.size
⊢ (((s.cast ⋯).push (aig.mkConstCached (c.getLsbD curr)).ref).get idx ?isTrue.hidx).cast ?isTrue.hfoo =
    (s.get idx hidx).cast hfoo

case isTrue.hidx
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
w : Nat
aig : AIG α
c : BitVec w
curr : Nat
hcurr : curr ≤ w
s : aig.RefVec curr
idx : Nat
hidx : idx < curr
res : RefVecEntry α w
h✝ : curr < w
hgo :
  go (aig.mkConstCached (c.getLsbD curr)).aig c (curr + 1) ((s.cast ⋯).push (aig.mkConstCached (c.getLsbD curr)).ref)
      ⋯ =
    res
hfoo :
  aig.decls.size ≤
    (go (aig.mkConstCached (c.getLsbD curr)).aig c (curr + 1) ((s.cast ⋯).push (aig.mkConstCached (c.getLsbD curr)).ref)
            ⋯).aig.decls.size
⊢ idx < curr + 1

case isTrue.hfoo
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
w : Nat
aig : AIG α
c : BitVec w
curr : Nat
hcurr : curr ≤ w
s : aig.RefVec curr
idx : Nat
hidx : idx < curr
res : RefVecEntry α w
h✝ : curr < w
hgo :
  go (aig.mkConstCached (c.getLsbD curr)).aig c (curr + 1) ((s.cast ⋯).push (aig.mkConstCached (c.getLsbD curr)).ref)
      ⋯ =
    res
hfoo :
  aig.decls.size ≤
    (go (aig.mkConstCached (c.getLsbD curr)).aig c (curr + 1) ((s.cast ⋯).push (aig.mkConstCached (c.getLsbD curr)).ref)
            ⋯).aig.decls.size
⊢ (aig.mkConstCached (c.getLsbD curr)).aig.decls.size ≤
    (go (aig.mkConstCached (c.getLsbD curr)).aig c (curr + 1) ((s.cast ⋯).push (aig.mkConstCached (c.getLsbD curr)).ref)
            ⋯).aig.decls.size

Tactic:
rw [AIG.RefVec.get_push_ref_lt]

Result:
case isTrue
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
w : Nat
aig : AIG α
c : BitVec w
curr : Nat
hcurr : curr ≤ w
s : aig.RefVec curr
idx : Nat
hidx : idx < curr
res : RefVecEntry α w
h✝ : curr < w
hgo :
  go (aig.mkConstCached (c.getLsbD curr)).aig c (curr + 1) ((s.cast ⋯).push (aig.mkConstCached (c.getLsbD curr)).ref)
      ⋯ =
    res
hfoo :
  aig.decls.size ≤
    (go (aig.mkConstCached (c.getLsbD curr)).aig c (curr + 1) ((s.cast ⋯).push (aig.mkConstCached (c.getLsbD curr)).ref)
            ⋯).aig.decls.size
⊢ ((s.cast ⋯).get idx ?isTrue.hidx).cast ?isTrue.hfoo = (s.get idx hidx).cast hfoo

case isTrue.hidx
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
w : Nat
aig : AIG α
c : BitVec w
curr : Nat
hcurr : curr ≤ w
s : aig.RefVec curr
idx : Nat
hidx : idx < curr
res : RefVecEntry α w
h✝ : curr < w
hgo :
  go (aig.mkConstCached (c.getLsbD curr)).aig c (curr + 1) ((s.cast ⋯).push (aig.mkConstCached (c.getLsbD curr)).ref)
      ⋯ =
    res
hfoo :
  aig.decls.size ≤
    (go (aig.mkConstCached (c.getLsbD curr)).aig c (curr + 1) ((s.cast ⋯).push (aig.mkConstCached (c.getLsbD curr)).ref)
            ⋯).aig.decls.size
⊢ idx < curr

case isTrue.hfoo
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
w : Nat
aig : AIG α
c : BitVec w
curr : Nat
hcurr : curr ≤ w
s : aig.RefVec curr
idx : Nat
hidx : idx < curr
res : RefVecEntry α w
h✝ : curr < w
hgo :
  go (aig.mkConstCached (c.getLsbD curr)).aig c (curr + 1) ((s.cast ⋯).push (aig.mkConstCached (c.getLsbD curr)).ref)
      ⋯ =
    res
hfoo :
  aig.decls.size ≤
    (go (aig.mkConstCached (c.getLsbD curr)).aig c (curr + 1) ((s.cast ⋯).push (aig.mkConstCached (c.getLsbD curr)).ref)
            ⋯).aig.decls.size
⊢ (aig.mkConstCached (c.getLsbD curr)).aig.decls.size ≤
    (go (aig.mkConstCached (c.getLsbD curr)).aig c (curr + 1) ((s.cast ⋯).push (aig.mkConstCached (c.getLsbD curr)).ref)
            ⋯).aig.decls.size