-- Mathlib/.lake/packages/lean4/src/lean/Std/Tactic/BVDecide/Bitblast/BVExpr/Circuit/Impl/Operations/Add.lean
theorem go_decl_eq (aig : AIG α) (curr : Nat) (hcurr : curr ≤ w) (cin : AIG.Ref aig)
    (s : AIG.RefVec aig curr) (lhs rhs : AIG.RefVec aig w) :
    ∀ (idx : Nat) (h1) (h2),
        (go aig lhs rhs curr hcurr cin s).aig.decls[idx]'h2 = aig.decls[idx]'h1

Proof state:
case isTrue
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
w : Nat
aig : AIG α
curr : Nat
hcurr : curr ≤ w
cin : aig.Ref
s : aig.RefVec curr
lhs rhs : aig.RefVec w
res : AIG.RefVecEntry α w
h✝ : curr < w
hgo :
  go (mkFullAdder aig { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝, cin := cin }).aig (lhs.cast ⋯) (rhs.cast ⋯)
      (curr + 1) ⋯ (mkFullAdder aig { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝, cin := cin }).cout
      ((s.cast ⋯).push (mkFullAdder aig { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝, cin := cin }).out) =
    res
idx✝ : Nat
h1✝ : idx✝ < aig.decls.size
h2✝ :
  idx✝ <
    (go (mkFullAdder aig { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝, cin := cin }).aig (lhs.cast ⋯) (rhs.cast ⋯)
            (curr + 1) ⋯ (mkFullAdder aig { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝, cin := cin }).cout
            ((s.cast ⋯).push
              (mkFullAdder aig { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝, cin := cin }).out)).aig.decls.size
⊢ (let res := mkFullAdderOut aig { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝, cin := cin };
          let aig_1 := res.aig;
          let outRef := res.ref;
          let_fun haig1 := ⋯;
          let input := { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝, cin := cin }.cast haig1;
          let res_1 := mkFullAdderCarry aig_1 input;
          let aig_2 := res_1.aig;
          let carryRef := res_1.ref;
          let_fun haig2 := ⋯;
          let outRef := outRef.cast haig2;
          let_fun hle := ⋯;
          { aig := aig_2, out := outRef, cout := carryRef, hle := hle }).aig.decls[idx✝] =
    aig.decls[idx✝]

case isTrue.h1
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
w : Nat
aig : AIG α
curr : Nat
hcurr : curr ≤ w
cin : aig.Ref
s : aig.RefVec curr
lhs rhs : aig.RefVec w
res : AIG.RefVecEntry α w
h✝ : curr < w
hgo :
  go (mkFullAdder aig { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝, cin := cin }).aig (lhs.cast ⋯) (rhs.cast ⋯)
      (curr + 1) ⋯ (mkFullAdder aig { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝, cin := cin }).cout
      ((s.cast ⋯).push (mkFullAdder aig { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝, cin := cin }).out) =
    res
idx✝ : Nat
h1✝ : idx✝ < aig.decls.size
h2✝ :
  idx✝ <
    (go (mkFullAdder aig { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝, cin := cin }).aig (lhs.cast ⋯) (rhs.cast ⋯)
            (curr + 1) ⋯ (mkFullAdder aig { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝, cin := cin }).cout
            ((s.cast ⋯).push
              (mkFullAdder aig { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝, cin := cin }).out)).aig.decls.size
⊢ idx✝ < (mkFullAdder aig { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝, cin := cin }).aig.decls.size

Tactic:
rw [AIG.LawfulOperator.decl_eq (f := mkFullAdderCarry)]

Result:
case isTrue
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
w : Nat
aig : AIG α
curr : Nat
hcurr : curr ≤ w
cin : aig.Ref
s : aig.RefVec curr
lhs rhs : aig.RefVec w
res : AIG.RefVecEntry α w
h✝ : curr < w
hgo :
  go (mkFullAdder aig { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝, cin := cin }).aig (lhs.cast ⋯) (rhs.cast ⋯)
      (curr + 1) ⋯ (mkFullAdder aig { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝, cin := cin }).cout
      ((s.cast ⋯).push (mkFullAdder aig { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝, cin := cin }).out) =
    res
idx✝ : Nat
h1✝ : idx✝ < aig.decls.size
h2✝ :
  idx✝ <
    (go (mkFullAdder aig { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝, cin := cin }).aig (lhs.cast ⋯) (rhs.cast ⋯)
            (curr + 1) ⋯ (mkFullAdder aig { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝, cin := cin }).cout
            ((s.cast ⋯).push
              (mkFullAdder aig { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝, cin := cin }).out)).aig.decls.size
⊢ (mkFullAdderOut aig { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝, cin := cin }).aig.decls[idx✝] = aig.decls[idx✝]

case isTrue.h1
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
w : Nat
aig : AIG α
curr : Nat
hcurr : curr ≤ w
cin : aig.Ref
s : aig.RefVec curr
lhs rhs : aig.RefVec w
res : AIG.RefVecEntry α w
h✝ : curr < w
hgo :
  go (mkFullAdder aig { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝, cin := cin }).aig (lhs.cast ⋯) (rhs.cast ⋯)
      (curr + 1) ⋯ (mkFullAdder aig { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝, cin := cin }).cout
      ((s.cast ⋯).push (mkFullAdder aig { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝, cin := cin }).out) =
    res
idx✝ : Nat
h1✝ : idx✝ < aig.decls.size
h2✝ :
  idx✝ <
    (go (mkFullAdder aig { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝, cin := cin }).aig (lhs.cast ⋯) (rhs.cast ⋯)
            (curr + 1) ⋯ (mkFullAdder aig { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝, cin := cin }).cout
            ((s.cast ⋯).push
              (mkFullAdder aig { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝, cin := cin }).out)).aig.decls.size
⊢ idx✝ < (mkFullAdderOut aig { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝, cin := cin }).aig.decls.size

case isTrue.h2
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
w : Nat
aig : AIG α
curr : Nat
hcurr : curr ≤ w
cin : aig.Ref
s : aig.RefVec curr
lhs rhs : aig.RefVec w
res : AIG.RefVecEntry α w
h✝ : curr < w
hgo :
  go (mkFullAdder aig { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝, cin := cin }).aig (lhs.cast ⋯) (rhs.cast ⋯)
      (curr + 1) ⋯ (mkFullAdder aig { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝, cin := cin }).cout
      ((s.cast ⋯).push (mkFullAdder aig { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝, cin := cin }).out) =
    res
idx✝ : Nat
h1✝ : idx✝ < aig.decls.size
h2✝ :
  idx✝ <
    (go (mkFullAdder aig { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝, cin := cin }).aig (lhs.cast ⋯) (rhs.cast ⋯)
            (curr + 1) ⋯ (mkFullAdder aig { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝, cin := cin }).cout
            ((s.cast ⋯).push
              (mkFullAdder aig { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝, cin := cin }).out)).aig.decls.size
⊢ idx✝ <
    (mkFullAdderCarry (mkFullAdderOut aig { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝, cin := cin }).aig
            ({ lhs := lhs.get curr h✝, rhs := rhs.get curr h✝, cin := cin }.cast ⋯)).aig.decls.size