-- 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
res : RefVecEntry α w
h✝ : ¬curr < w
hgo : { aig := aig, vec := ⋯ ▸ s } = res
⊢ curr = w

Tactic:
omega

Result:
no goals

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:
intro idx hidx

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
⊢ ∀ (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

Proof state:
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:
apply go_le_size

Result:
no goals

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),
    (go (aig.mkConstCached (c.getLsbD curr)).aig c (curr + 1) ((s.cast ⋯).push (aig.mkConstCached (c.getLsbD curr)).ref)
              ⋯).vec.get
        idx ⋯ =
      (s.get idx hidx).cast hfoo

Tactic:
intro hfoo

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
⊢ (go (aig.mkConstCached (c.getLsbD curr)).aig c (curr + 1) ((s.cast ⋯).push (aig.mkConstCached (c.getLsbD curr)).ref)
            ⋯).vec.get
      idx ⋯ =
    (s.get idx hidx).cast hfoo

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 ⋯).get idx ?isTrue.hidx).gate = (s.get idx hidx).gate

Tactic:
rw [AIG.RefVec.get_cast]

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.get idx ?isTrue.hidx).cast ⋯).gate = (s.get idx hidx).gate

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

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 ⋯).get idx ?isTrue.hidx).cast ?isTrue.hfoo = (s.get idx hidx).cast hfoo

Tactic:
simp only [Ref.cast, Ref.mk.injEq]

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).gate = (s.get idx hidx).gate

Proof state:
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 ⋯

Tactic:
simp

Result:
no goals

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
⊢ idx < w

Tactic:
omega

Result:
no goals