-- Mathlib/.lake/packages/lean4/src/lean/Std/Tactic/BVDecide/Bitblast/BVExpr/Circuit/Lemmas/Operations/ShiftLeft.lean
theorem go_denote_eq (aig : AIG α) (distance : Nat) (input : AIG.RefVec aig w)
    (assign : α → Bool) (curr : Nat) (hcurr : curr ≤ w) (s : AIG.RefVec aig curr) :
    ∀ (idx : Nat) (hidx1 : idx < w),
        curr ≤ idx
          →
        ⟦
          (go aig input distance curr hcurr s).aig,
          (go aig input distance curr hcurr s).vec.get idx hidx1,
          assign
        ⟧
          =
        if hidx : idx < distance then
          false
        else
          ⟦aig, input.get (idx - distance) (by omega), assign⟧

Proof state:
case isTrue
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
w : Nat
aig : AIG α
distance : Nat
input : aig.RefVec 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 :
  (if hdist : curr < distance then
      let res := aig.mkConstCached false;
      let aig_1 := res.aig;
      let zeroRef := res.ref;
      let_fun hfinal := ⋯;
      let s := s.cast hfinal;
      let input := input.cast hfinal;
      let s := s.push zeroRef;
      go aig_1 input distance (curr + 1) ⋯ s
    else
      let s := s.push (input.get (curr - distance) ⋯);
      go aig input distance (curr + 1) ⋯ s) =
    res
⊢ ⟦assign, { aig := res.aig, ref := res.vec.get idx hidx1 }⟧ =
    if hidx : idx < distance then false else ⟦assign, { aig := aig, ref := input.get (idx - distance) ⋯ }⟧

Tactic:
dsimp only at hgo

Result:
case isTrue
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
w : Nat
aig : AIG α
distance : Nat
input : aig.RefVec 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 :
  (if hdist : curr < distance then
      go (aig.mkConstCached false).aig (input.cast ⋯) distance (curr + 1) ⋯
        ((s.cast ⋯).push (aig.mkConstCached false).ref)
    else go aig input distance (curr + 1) ⋯ (s.push (input.get (curr - distance) ⋯))) =
    res
⊢ ⟦assign, { aig := res.aig, ref := res.vec.get idx hidx1 }⟧ =
    if hidx : idx < distance then false else ⟦assign, { aig := aig, ref := input.get (idx - distance) ⋯ }⟧

Proof state:
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
w : Nat
aig : AIG α
distance : Nat
input : aig.RefVec 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 input distance curr hcurr s = res
⊢ ⟦assign, { aig := res.aig, ref := res.vec.get idx hidx1 }⟧ =
    if hidx : idx < distance then false else ⟦assign, { aig := aig, ref := input.get (idx - distance) ⋯ }⟧

Tactic:
unfold go at hgo

Result:
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
w : Nat
aig : AIG α
distance : Nat
input : aig.RefVec 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 hidx : curr < w then
      if hdist : curr < distance then
        let res := aig.mkConstCached false;
        let aig_1 := res.aig;
        let zeroRef := res.ref;
        let_fun hfinal := ⋯;
        let s := s.cast hfinal;
        let input := input.cast hfinal;
        let s := s.push zeroRef;
        go aig_1 input distance (curr + 1) ⋯ s
      else
        let s := s.push (input.get (curr - distance) ⋯);
        go aig input distance (curr + 1) ⋯ s
    else
      let_fun hcurr := ⋯;
      { aig := aig, vec := hcurr ▸ s }) =
    res
⊢ ⟦assign, { aig := res.aig, ref := res.vec.get idx hidx1 }⟧ =
    if hidx : idx < distance then false else ⟦assign, { aig := aig, ref := input.get (idx - distance) ⋯ }⟧

Proof state:
case isTrue.inl.isFalse.isFalse
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
w : Nat
aig : AIG α
distance : Nat
input : aig.RefVec 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
heq : curr = idx
h✝¹ : ¬curr < distance
hgo : go aig input distance (curr + 1) ⋯ (s.push (input.get (curr - distance) ⋯)) = res
h✝ : ¬idx < distance
⊢ ⟦assign, { aig := res.aig, ref := res.vec.get idx hidx1 }⟧ =
    ⟦assign, { aig := aig, ref := input.get (idx - distance) ⋯ }⟧

Tactic:
rw [← hgo]

Result:
case isTrue.inl.isFalse.isFalse
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
w : Nat
aig : AIG α
distance : Nat
input : aig.RefVec 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
heq : curr = idx
h✝¹ : ¬curr < distance
hgo : go aig input distance (curr + 1) ⋯ (s.push (input.get (curr - distance) ⋯)) = res
h✝ : ¬idx < distance
⊢ ⟦assign,
      { aig := (go aig input distance (curr + 1) ⋯ (s.push (input.get (curr - distance) ⋯))).aig,
        ref := (go aig input distance (curr + 1) ⋯ (s.push (input.get (curr - distance) ⋯))).vec.get idx hidx1 }⟧ =
    ⟦assign, { aig := aig, ref := input.get (idx - distance) ⋯ }⟧

Proof state:
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
w : Nat
aig : AIG α
distance : Nat
input : aig.RefVec w
assign : α → Bool
curr : Nat
hcurr : curr ≤ w
s : aig.RefVec curr
⊢ ∀ (idx : Nat) (hidx1 : idx < w),
    curr ≤ idx →
      ⟦assign,
          { aig := (go aig input distance curr hcurr s).aig,
            ref := (go aig input distance curr hcurr s).vec.get idx hidx1 }⟧ =
        if hidx : idx < distance then false else ⟦assign, { aig := aig, ref := input.get (idx - distance) ⋯ }⟧

Tactic:
intro idx hidx1 hidx2

Result:
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
w : Nat
aig : AIG α
distance : Nat
input : aig.RefVec w
assign : α → Bool
curr : Nat
hcurr : curr ≤ w
s : aig.RefVec curr
idx : Nat
hidx1 : idx < w
hidx2 : curr ≤ idx
⊢ ⟦assign,
      { aig := (go aig input distance curr hcurr s).aig,
        ref := (go aig input distance curr hcurr s).vec.get idx hidx1 }⟧ =
    if hidx : idx < distance then false else ⟦assign, { aig := aig, ref := input.get (idx - distance) ⋯ }⟧