-- Mathlib/.lake/packages/lean4/src/lean/Std/Tactic/BVDecide/Bitblast/BVExpr/Circuit/Lemmas/Operations/Add.lean
theorem go_get_aux (aig : AIG α) (curr : Nat) (hcurr : curr ≤ w) (cin : Ref aig)
    (s : AIG.RefVec aig curr) (lhs rhs : AIG.RefVec aig w) :
    -- `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 lhs rhs curr hcurr cin s).vec.get idx (by omega)
          =
        (s.get idx hidx).cast hfoo

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
idx : Nat
hidx : idx < curr
res : 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
hfoo :
  aig.decls.size ≤
    (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
⊢ (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)).vec.get
      idx ⋯ =
    (s.get idx hidx).cast hfoo

Tactic:
rw [go_get_aux]

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
idx : Nat
hidx : idx < curr
res : 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
hfoo :
  aig.decls.size ≤
    (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
⊢ (((s.cast ⋯).push (mkFullAdder aig { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝, cin := cin }).out).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 α
curr : Nat
hcurr : curr ≤ w
cin : aig.Ref
s : aig.RefVec curr
lhs rhs : aig.RefVec w
idx : Nat
hidx : idx < curr
res : 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
hfoo :
  aig.decls.size ≤
    (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 < curr + 1

case isTrue.hfoo
α : 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
idx : Nat
hidx : idx < curr
res : 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
hfoo :
  aig.decls.size ≤
    (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
⊢ (mkFullAdder aig { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝, cin := cin }).aig.decls.size ≤
    (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

Proof state:
α : 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
idx : Nat
hidx : idx < curr
hfoo : aig.decls.size ≤ (go aig lhs rhs curr hcurr cin s).aig.decls.size
⊢ idx < w

Tactic:
omega

Result:
no goals