-- Mathlib/.lake/packages/lean4/src/lean/Std/Tactic/BVDecide/Bitblast/BVExpr/Circuit/Lemmas/Operations/Add.lean
theorem go_denote_eq (aig : AIG α) (curr : Nat) (hcurr : curr ≤ w) (cin : Ref aig)
    (s : AIG.RefVec aig curr) (lhs rhs : AIG.RefVec aig w) (assign : α → Bool)
    (lhsExpr rhsExpr : BitVec w)
    (hleft : ∀ (idx : Nat) (hidx : idx < w), ⟦aig, lhs.get idx hidx, assign⟧ = lhsExpr.getLsbD idx)
    (hright : ∀ (idx : Nat) (hidx : idx < w), ⟦aig, rhs.get idx hidx, assign⟧ = rhsExpr.getLsbD idx)
    (hcin : ⟦aig, cin, assign⟧ = BitVec.carry curr lhsExpr rhsExpr false) :
    ∀ (idx : Nat) (hidx1 : idx < w),
        curr ≤ idx
          →
        ⟦
          (go aig lhs rhs curr hcurr cin s).aig,
          (go aig lhs rhs curr hcurr cin s).vec.get idx hidx1,
          assign
        ⟧
          =
        ⟦aig, lhs.get idx hidx1, assign⟧.xor
          (⟦aig, rhs.get idx hidx1, assign⟧.xor
            (BitVec.carry idx lhsExpr rhsExpr false))

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
assign : α → Bool
lhsExpr rhsExpr : BitVec w
hleft : ∀ (idx : Nat) (hidx : idx < w), ⟦assign, { aig := aig, ref := lhs.get idx hidx }⟧ = lhsExpr.getLsbD idx
hright : ∀ (idx : Nat) (hidx : idx < w), ⟦assign, { aig := aig, ref := rhs.get idx hidx }⟧ = rhsExpr.getLsbD idx
hcin : ⟦assign, { aig := aig, ref := cin }⟧ = BitVec.carry curr lhsExpr rhsExpr false
idx : Nat
hidx1 : idx < w
hidx2 : curr ≤ idx
res : RefVecEntry α w
hlt : curr < w
hgo :
  go (mkFullAdder aig { lhs := lhs.get curr hlt, rhs := rhs.get curr hlt, cin := cin }).aig (lhs.cast ⋯) (rhs.cast ⋯)
      (curr + 1) ⋯ (mkFullAdder aig { lhs := lhs.get curr hlt, rhs := rhs.get curr hlt, cin := cin }).cout
      ((s✝.cast ⋯).push (mkFullAdder aig { lhs := lhs.get curr hlt, rhs := rhs.get curr hlt, cin := cin }).out) =
    res
heq : curr = idx
s : (mkFullAdder aig { lhs := lhs.get curr hlt, rhs := rhs.get curr hlt, cin := cin }).aig.RefVec curr
ref : (mkFullAdder aig { lhs := lhs.get curr hlt, rhs := rhs.get curr hlt, cin := cin }).aig.Ref
⊢ idx = curr

Tactic:
rw [heq]

Result:
no goals

Proof state:
case inr.hleft
α : 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
assign : α → Bool
lhsExpr rhsExpr : BitVec w
hleft : ∀ (idx : Nat) (hidx : idx < w), ⟦assign, { aig := aig, ref := lhs.get idx hidx }⟧ = lhsExpr.getLsbD idx
hright : ∀ (idx : Nat) (hidx : idx < w), ⟦assign, { aig := aig, ref := rhs.get idx hidx }⟧ = rhsExpr.getLsbD idx
hcin : ⟦assign, { aig := aig, ref := cin }⟧ = BitVec.carry curr lhsExpr rhsExpr false
idx : Nat
hidx1 : idx < w
hidx2 : curr ≤ idx
res : RefVecEntry α w
hlt✝ : curr < w
hgo :
  go (mkFullAdder aig { lhs := lhs.get curr hlt✝, rhs := rhs.get curr hlt✝, cin := cin }).aig (lhs.cast ⋯) (rhs.cast ⋯)
      (curr + 1) ⋯ (mkFullAdder aig { lhs := lhs.get curr hlt✝, rhs := rhs.get curr hlt✝, cin := cin }).cout
      ((s.cast ⋯).push (mkFullAdder aig { lhs := lhs.get curr hlt✝, rhs := rhs.get curr hlt✝, cin := cin }).out) =
    res
hlt : curr < idx
⊢ ∀ (idx : Nat) (hidx : idx < w),
    ⟦assign,
        { aig := (mkFullAdder aig { lhs := lhs.get curr hlt✝, rhs := rhs.get curr hlt✝, cin := cin }).aig,
          ref := (lhs.cast ⋯).get idx hidx }⟧ =
      lhsExpr.getLsbD idx

Tactic:
intro idx hidx

Result:
case inr.hleft
α : 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
assign : α → Bool
lhsExpr rhsExpr : BitVec w
hleft : ∀ (idx : Nat) (hidx : idx < w), ⟦assign, { aig := aig, ref := lhs.get idx hidx }⟧ = lhsExpr.getLsbD idx
hright : ∀ (idx : Nat) (hidx : idx < w), ⟦assign, { aig := aig, ref := rhs.get idx hidx }⟧ = rhsExpr.getLsbD idx
hcin : ⟦assign, { aig := aig, ref := cin }⟧ = BitVec.carry curr lhsExpr rhsExpr false
idx✝ : Nat
hidx1 : idx✝ < w
hidx2 : curr ≤ idx✝
res : RefVecEntry α w
hlt✝ : curr < w
hgo :
  go (mkFullAdder aig { lhs := lhs.get curr hlt✝, rhs := rhs.get curr hlt✝, cin := cin }).aig (lhs.cast ⋯) (rhs.cast ⋯)
      (curr + 1) ⋯ (mkFullAdder aig { lhs := lhs.get curr hlt✝, rhs := rhs.get curr hlt✝, cin := cin }).cout
      ((s.cast ⋯).push (mkFullAdder aig { lhs := lhs.get curr hlt✝, rhs := rhs.get curr hlt✝, cin := cin }).out) =
    res
hlt : curr < idx✝
idx : Nat
hidx : idx < w
⊢ ⟦assign,
      { aig := (mkFullAdder aig { lhs := lhs.get curr hlt✝, rhs := rhs.get curr hlt✝, cin := cin }).aig,
        ref := (lhs.cast ⋯).get idx hidx }⟧ =
    lhsExpr.getLsbD idx

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
assign : α → Bool
lhsExpr rhsExpr : BitVec w
hleft : ∀ (idx : Nat) (hidx : idx < w), ⟦assign, { aig := aig, ref := lhs.get idx hidx }⟧ = lhsExpr.getLsbD idx
hright : ∀ (idx : Nat) (hidx : idx < w), ⟦assign, { aig := aig, ref := rhs.get idx hidx }⟧ = rhsExpr.getLsbD idx
hcin : ⟦assign, { aig := aig, ref := cin }⟧ = BitVec.carry curr lhsExpr rhsExpr false
idx : Nat
hidx1 : idx < w
hidx2 : curr ≤ idx
⊢ ⟦assign,
      { aig := (go aig lhs rhs curr hcurr cin s).aig, ref := (go aig lhs rhs curr hcurr cin s).vec.get idx hidx1 }⟧ =
    (⟦assign, { aig := aig, ref := lhs.get idx hidx1 }⟧ ^^
      (⟦assign, { aig := aig, ref := rhs.get idx hidx1 }⟧ ^^ BitVec.carry idx lhsExpr rhsExpr false))

Tactic:
generalize hgo : go aig lhs rhs curr hcurr cin s = res

Result:
α : 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
assign : α → Bool
lhsExpr rhsExpr : BitVec w
hleft : ∀ (idx : Nat) (hidx : idx < w), ⟦assign, { aig := aig, ref := lhs.get idx hidx }⟧ = lhsExpr.getLsbD idx
hright : ∀ (idx : Nat) (hidx : idx < w), ⟦assign, { aig := aig, ref := rhs.get idx hidx }⟧ = rhsExpr.getLsbD idx
hcin : ⟦assign, { aig := aig, ref := cin }⟧ = BitVec.carry curr lhsExpr rhsExpr false
idx : Nat
hidx1 : idx < w
hidx2 : curr ≤ idx
res : RefVecEntry α w
hgo : go aig lhs rhs curr hcurr cin s = res
⊢ ⟦assign, { aig := res.aig, ref := res.vec.get idx hidx1 }⟧ =
    (⟦assign, { aig := aig, ref := lhs.get idx hidx1 }⟧ ^^
      (⟦assign, { aig := aig, ref := rhs.get idx hidx1 }⟧ ^^ BitVec.carry idx lhsExpr rhsExpr false))

Proof state:
case inr.a
α : 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
assign : α → Bool
lhsExpr rhsExpr : BitVec w
hleft : ∀ (idx : Nat) (hidx : idx < w), ⟦assign, { aig := aig, ref := lhs.get idx hidx }⟧ = lhsExpr.getLsbD idx
hright : ∀ (idx : Nat) (hidx : idx < w), ⟦assign, { aig := aig, ref := rhs.get idx hidx }⟧ = rhsExpr.getLsbD idx
hcin : ⟦assign, { aig := aig, ref := cin }⟧ = BitVec.carry curr lhsExpr rhsExpr false
idx : Nat
hidx1 : idx < w
hidx2 : curr ≤ idx
res : RefVecEntry α w
hlt✝ : curr < w
hgo :
  go (mkFullAdder aig { lhs := lhs.get curr hlt✝, rhs := rhs.get curr hlt✝, cin := cin }).aig (lhs.cast ⋯) (rhs.cast ⋯)
      (curr + 1) ⋯ (mkFullAdder aig { lhs := lhs.get curr hlt✝, rhs := rhs.get curr hlt✝, cin := cin }).cout
      ((s.cast ⋯).push (mkFullAdder aig { lhs := lhs.get curr hlt✝, rhs := rhs.get curr hlt✝, cin := cin }).out) =
    res
hlt : curr < idx
⊢ curr + 1 ≤ idx

Tactic:
omega

Result:
no goals