-- 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:
α : 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) ⋯ }⟧

Tactic:
split 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
      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) ⋯ }⟧

case 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
hgo :
  (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.inr
α : 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
h✝ : curr < idx
⊢ ⟦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:
split at hgo

Result:
case isTrue.inr.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
h✝¹ : curr < idx
h✝ : curr < distance
hgo :
  go (aig.mkConstCached false).aig (input.cast ⋯) distance (curr + 1) ⋯
      ((s.cast ⋯).push (aig.mkConstCached false).ref) =
    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) ⋯ }⟧

case isTrue.inr.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
h✝¹ : curr < idx
h✝ : ¬curr < distance
hgo : 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
h✝² : curr < w
h✝¹ : curr < idx
h✝ : curr < distance
hgo :
  go (aig.mkConstCached false).aig (input.cast ⋯) distance (curr + 1) ⋯
      ((s.cast ⋯).push (aig.mkConstCached false).ref) =
    res
hidx : ¬idx < distance
⊢ (if hidx : idx < distance then false
    else ⟦assign, { aig := (aig.mkConstCached false).aig, ref := (input.cast ⋯).get (idx - distance) ⋯ }⟧) =
    ⟦assign, { aig := aig, ref := input.get (idx - distance) ⋯ }⟧

Tactic:
simp only [hidx, ↓reduceDIte, RefVec.get_cast, Ref.cast_eq]

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
h✝² : curr < w
h✝¹ : curr < idx
h✝ : curr < distance
hgo :
  go (aig.mkConstCached false).aig (input.cast ⋯) distance (curr + 1) ⋯
      ((s.cast ⋯).push (aig.mkConstCached false).ref) =
    res
hidx : ¬idx < distance
⊢ ⟦assign,
      { aig := (aig.mkConstCached false).aig, ref := { gate := (input.get (idx - distance) ⋯).gate, hgate := ⋯ } }⟧ =
    ⟦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
h✝² : curr < w
h✝¹ : curr < idx
h✝ : ¬curr < distance
hgo : go aig input distance (curr + 1) ⋯ (s.push (input.get (curr - distance) ⋯)) = res
hidx : ¬idx < distance
⊢ ⟦assign, { aig := res.aig, ref := res.vec.get idx hidx1 }⟧ =
    ⟦assign, { aig := aig, ref := input.get (idx - distance) ⋯ }⟧

Tactic:
rw [← 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
h✝² : curr < w
h✝¹ : curr < idx
h✝ : ¬curr < distance
hgo : go aig input distance (curr + 1) ⋯ (s.push (input.get (curr - distance) ⋯)) = res
hidx : ¬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) ⋯ }⟧