-- Mathlib/.lake/packages/lean4/src/lean/Std/Tactic/BVDecide/Bitblast/BVExpr/Circuit/Lemmas/Operations/ShiftRight.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
          →
        ⟦
          aig,
          (go input distance curr hcurr s).get idx hidx1,
          assign
        ⟧
          =
        if hidx : (distance + idx) < w then
          ⟦aig, input.get (distance + idx) (by omega), assign⟧
        else
          ⟦aig, input.get (w - 1) (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 : aig.RefVec w
hgo : go input distance curr hcurr s = res
⊢ ⟦assign, { aig := aig, ref := res.get idx hidx1 }⟧ =
    if hidx : distance + idx < w then ⟦assign, { aig := aig, ref := input.get (distance + idx) ⋯ }⟧
    else ⟦assign, { aig := aig, ref := input.get (w - 1) ⋯ }⟧

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 : aig.RefVec w
hgo :
  (if hidx : curr < w then
      if hdist : distance + curr < w then
        let s := s.push (input.get (distance + curr) ⋯);
        go input distance (curr + 1) ⋯ s
      else
        let s := s.push (input.get (w - 1) ⋯);
        go input distance (curr + 1) ⋯ s
    else
      let_fun hcurr := ⋯;
      hcurr ▸ s) =
    res
⊢ ⟦assign, { aig := aig, ref := res.get idx hidx1 }⟧ =
    if hidx : distance + idx < w then ⟦assign, { aig := aig, ref := input.get (distance + idx) ⋯ }⟧
    else ⟦assign, { aig := aig, ref := input.get (w - 1) ⋯ }⟧

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 : aig.RefVec w
h✝ : curr < w
heq : curr = idx
hlt : distance + curr < w
hgo :
  (let s := s.push (input.get (distance + curr) ⋯);
    go input distance (curr + 1) ⋯ s) =
    res
⊢ ⟦assign, { aig := aig, ref := res.get idx hidx1 }⟧ =
    if hidx : distance + idx < w then ⟦assign, { aig := aig, ref := input.get (distance + idx) ⋯ }⟧
    else ⟦assign, { aig := aig, ref := input.get (w - 1) ⋯ }⟧

Tactic:
rw [heq] at hlt

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 : aig.RefVec w
h✝ : curr < w
heq : curr = idx
hlt✝ : distance + curr < w
hlt : distance + idx < w
hgo :
  (let s := s.push (input.get (distance + curr) ⋯);
    go input distance (curr + 1) ⋯ s) =
    res
⊢ ⟦assign, { aig := aig, ref := res.get idx hidx1 }⟧ =
    if hidx : distance + idx < w then ⟦assign, { aig := aig, ref := input.get (distance + idx) ⋯ }⟧
    else ⟦assign, { aig := aig, ref := input.get (w - 1) ⋯ }⟧

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
hidx : distance + idx < w
⊢ distance + idx < w

Tactic:
omega

Result:
no goals

Proof state:
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 : aig.RefVec w
h✝ : ¬curr < w
hgo :
  (let_fun hcurr := ⋯;
    hcurr ▸ s) =
    res
⊢ ⟦assign, { aig := aig, ref := res.get idx hidx1 }⟧ =
    if hidx : distance + idx < w then ⟦assign, { aig := aig, ref := input.get (distance + idx) ⋯ }⟧
    else ⟦assign, { aig := aig, ref := input.get (w - 1) ⋯ }⟧

Tactic:
omega

Result:
no goals

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 : aig.RefVec w
hgo :
  (if hidx : curr < w then
      if hdist : distance + curr < w then
        let s := s.push (input.get (distance + curr) ⋯);
        go input distance (curr + 1) ⋯ s
      else
        let s := s.push (input.get (w - 1) ⋯);
        go input distance (curr + 1) ⋯ s
    else
      let_fun hcurr := ⋯;
      hcurr ▸ s) =
    res
⊢ ⟦assign, { aig := aig, ref := res.get idx hidx1 }⟧ =
    if hidx : distance + idx < w then ⟦assign, { aig := aig, ref := input.get (distance + idx) ⋯ }⟧
    else ⟦assign, { aig := aig, ref := input.get (w - 1) ⋯ }⟧

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 : aig.RefVec w
h✝ : curr < w
hgo :
  (if hdist : distance + curr < w then
      let s := s.push (input.get (distance + curr) ⋯);
      go input distance (curr + 1) ⋯ s
    else
      let s := s.push (input.get (w - 1) ⋯);
      go input distance (curr + 1) ⋯ s) =
    res
⊢ ⟦assign, { aig := aig, ref := res.get idx hidx1 }⟧ =
    if hidx : distance + idx < w then ⟦assign, { aig := aig, ref := input.get (distance + idx) ⋯ }⟧
    else ⟦assign, { aig := aig, ref := input.get (w - 1) ⋯ }⟧

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 : aig.RefVec w
h✝ : ¬curr < w
hgo :
  (let_fun hcurr := ⋯;
    hcurr ▸ s) =
    res
⊢ ⟦assign, { aig := aig, ref := res.get idx hidx1 }⟧ =
    if hidx : distance + idx < w then ⟦assign, { aig := aig, ref := input.get (distance + idx) ⋯ }⟧
    else ⟦assign, { aig := aig, ref := input.get (w - 1) ⋯ }⟧