-- Mathlib/.lake/packages/lean4/src/lean/Std/Tactic/BVDecide/Bitblast/BVExpr/Circuit/Lemmas/Const.lean
theorem go_denote_eq (aig : AIG α) (c : BitVec w) (assign : α → Bool)
    (curr : Nat) (hcurr : curr ≤ w) (s : AIG.RefVec aig curr) :
    ∀ (idx : Nat) (hidx1 : idx < w),
        curr ≤ idx
          →
        ⟦
          (go aig c curr s hcurr).aig,
          (go aig c curr s hcurr).vec.get idx hidx1,
          assign
        ⟧
          =
        c.getLsbD idx

Proof state:
case isTrue.inl
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
w : Nat
aig : AIG α
c : BitVec w
assign : α → Bool
curr : Nat
hcurr : curr ≤ w
s : aig.RefVec curr
idx : Nat
hidx1 : idx < w
hidx2 : curr ≤ idx
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
heq : curr = idx
⊢ ⟦assign,
      {
        aig :=
          (go (aig.mkConstCached (c.getLsbD curr)).aig c (curr + 1)
              ((s.cast ⋯).push (aig.mkConstCached (c.getLsbD curr)).ref) ⋯).aig,
        ref := (aig.mkConstCached (c.getLsbD curr)).ref.cast ⋯ }⟧ =
    c.getLsbD curr

Tactic:
rw [go_denote_mem_prefix]

Result:
case isTrue.inl
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
w : Nat
aig : AIG α
c : BitVec w
assign : α → Bool
curr : Nat
hcurr : curr ≤ w
s : aig.RefVec curr
idx : Nat
hidx1 : idx < w
hidx2 : curr ≤ idx
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
heq : curr = idx
⊢ ⟦assign,
      { aig := (aig.mkConstCached (c.getLsbD curr)).aig,
        ref := { gate := ((aig.mkConstCached (c.getLsbD curr)).ref.cast ⋯).gate, hgate := ?isTrue.inl.hstart } }⟧ =
    c.getLsbD curr

case isTrue.inl.hstart
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
w : Nat
aig : AIG α
c : BitVec w
assign : α → Bool
curr : Nat
hcurr : curr ≤ w
s : aig.RefVec curr
idx : Nat
hidx1 : idx < w
hidx2 : curr ≤ idx
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
heq : curr = idx
⊢ ((aig.mkConstCached (c.getLsbD curr)).ref.cast ⋯).gate < (aig.mkConstCached (c.getLsbD curr)).aig.decls.size

Proof state:
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
w : Nat
aig : AIG α
c : BitVec w
assign : α → Bool
curr : Nat
hcurr : curr ≤ w
s : aig.RefVec curr
idx : Nat
hidx1 : idx < w
hidx2 : curr ≤ idx
res : RefVecEntry α w
hgo : go aig c curr s hcurr = res
⊢ ⟦assign, { aig := res.aig, ref := res.vec.get idx hidx1 }⟧ = c.getLsbD idx

Tactic:
unfold go at hgo

Result:
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
w : Nat
aig : AIG α
c : BitVec w
assign : α → Bool
curr : Nat
hcurr : curr ≤ w
s : aig.RefVec curr
idx : Nat
hidx1 : idx < w
hidx2 : curr ≤ idx
res : RefVecEntry α w
hgo :
  (if hcurr : curr < w then
      let res := aig.mkConstCached (c.getLsbD curr);
      let aig_1 := res.aig;
      let bitRef := res.ref;
      let s := s.cast ⋯;
      let s := s.push bitRef;
      go aig_1 c (curr + 1) s ⋯
    else
      let_fun hcurr := ⋯;
      { aig := aig, vec := hcurr ▸ s }) =
    res
⊢ ⟦assign, { aig := res.aig, ref := res.vec.get idx hidx1 }⟧ = c.getLsbD idx

Proof state:
case isTrue.inl
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
w : Nat
aig : AIG α
c : BitVec w
assign : α → Bool
curr : Nat
hcurr : curr ≤ w
s : aig.RefVec curr
idx : Nat
hidx1 : idx < w
hidx2 : curr ≤ idx
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
heq : curr = idx
⊢ ⟦assign, { aig := res.aig, ref := res.vec.get idx hidx1 }⟧ = c.getLsbD idx

Tactic:
rw [← hgo]

Result:
case isTrue.inl
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
w : Nat
aig : AIG α
c : BitVec w
assign : α → Bool
curr : Nat
hcurr : curr ≤ w
s : aig.RefVec curr
idx : Nat
hidx1 : idx < w
hidx2 : curr ≤ idx
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
heq : curr = idx
⊢ ⟦assign,
      {
        aig :=
          (go (aig.mkConstCached (c.getLsbD curr)).aig c (curr + 1)
              ((s.cast ⋯).push (aig.mkConstCached (c.getLsbD curr)).ref) ⋯).aig,
        ref :=
          (go (aig.mkConstCached (c.getLsbD curr)).aig c (curr + 1)
                  ((s.cast ⋯).push (aig.mkConstCached (c.getLsbD curr)).ref) ⋯).vec.get
            idx hidx1 }⟧ =
    c.getLsbD idx

Proof state:
case isTrue.inl
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
w : Nat
aig : AIG α
c : BitVec w
assign : α → Bool
curr : Nat
hcurr : curr ≤ w
s : aig.RefVec curr
idx : Nat
hidx1 : idx < w
hidx2 : curr ≤ idx
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
heq : curr = idx
⊢ ⟦assign,
      {
        aig :=
          (go (aig.mkConstCached (c.getLsbD curr)).aig c (curr + 1)
              ((s.cast ⋯).push (aig.mkConstCached (c.getLsbD curr)).ref) ⋯).aig,
        ref := (((s.cast ⋯).push (aig.mkConstCached (c.getLsbD curr)).ref).get idx ?isTrue.inl.hidx).cast ⋯ }⟧ =
    c.getLsbD idx

case isTrue.inl.hidx
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
w : Nat
aig : AIG α
c : BitVec w
assign : α → Bool
curr : Nat
hcurr : curr ≤ w
s : aig.RefVec curr
idx : Nat
hidx1 : idx < w
hidx2 : curr ≤ idx
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
heq : curr = idx
⊢ idx < curr + 1

Tactic:
rw [AIG.RefVec.get_push_ref_eq']

Result:
case isTrue.inl
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
w : Nat
aig : AIG α
c : BitVec w
assign : α → Bool
curr : Nat
hcurr : curr ≤ w
s : aig.RefVec curr
idx : Nat
hidx1 : idx < w
hidx2 : curr ≤ idx
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
heq : curr = idx
⊢ ⟦assign,
      {
        aig :=
          (go (aig.mkConstCached (c.getLsbD curr)).aig c (curr + 1)
              ((s.cast ⋯).push (aig.mkConstCached (c.getLsbD curr)).ref) ⋯).aig,
        ref := (aig.mkConstCached (c.getLsbD curr)).ref.cast ⋯ }⟧ =
    c.getLsbD idx

case isTrue.inl.hidx
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
w : Nat
aig : AIG α
c : BitVec w
assign : α → Bool
curr : Nat
hcurr : curr ≤ w
s : aig.RefVec curr
idx : Nat
hidx1 : idx < w
hidx2 : curr ≤ idx
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
heq : curr = idx
⊢ idx = curr