-- Mathlib/.lake/packages/lean4/src/lean/Std/Tactic/BVDecide/Bitblast/BVExpr/Circuit/Lemmas/Operations/RotateLeft.lean
theorem go_get (aig : AIG α) (distance : Nat) (input : AIG.RefVec aig w)
    (curr : Nat) (hcurr : curr ≤ w) (s : AIG.RefVec aig curr) :
    ∀ (idx : Nat) (hidx1 : idx < w),
        curr ≤ idx
          →
        (go input distance curr hcurr s).get idx hidx1
          =
        if hidx3 : idx < distance % w then
          input.get (w - (distance % w) + idx) (by omega)
        else
          input.get (idx - (distance % w)) (by omega)

Proof state:
case isTrue.inr.isFalse
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
w : Nat
aig : AIG α
distance : Nat
input : aig.RefVec w
curr : Nat
hcurr : curr ≤ w
s : aig.RefVec curr
idx : Nat
hidx1 : idx < w
hidx2 : curr ≤ idx
h✝¹ : curr < w
heq : curr < idx
h✝ : ¬curr < distance % w
⊢ (go input distance (curr + 1) ⋯ (s.push (input.get (curr - distance % w) ⋯))).get idx hidx1 =
    if hidx3 : idx < distance % w then input.get (w - distance % w + idx) ⋯ else input.get (idx - distance % w) ⋯

Tactic:
rw [go_get]

Result:
case isTrue.inr.isFalse.a
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
w : Nat
aig : AIG α
distance : Nat
input : aig.RefVec w
curr : Nat
hcurr : curr ≤ w
s : aig.RefVec curr
idx : Nat
hidx1 : idx < w
hidx2 : curr ≤ idx
h✝¹ : curr < w
heq : curr < idx
h✝ : ¬curr < distance % w
⊢ curr + 1 ≤ idx

Proof state:
case isTrue.inl.isTrue.isFalse
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
w : Nat
aig : AIG α
distance : Nat
input : aig.RefVec w
curr : Nat
hcurr : curr ≤ w
s : aig.RefVec curr
idx : Nat
hidx1 : idx < w
hidx2 : curr ≤ idx
h✝² : curr < w
heq : curr = idx
h✝¹ : curr < distance % w
h✝ : ¬idx < distance % w
⊢ (go input distance (curr + 1) ⋯ (s.push (input.get (w - distance % w + curr) ⋯))).get idx hidx1 =
    input.get (idx - distance % w) ⋯

Tactic:
omega

Result:
no goals

Proof state:
case isTrue.inr.isTrue.a
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
w : Nat
aig : AIG α
distance : Nat
input : aig.RefVec w
curr : Nat
hcurr : curr ≤ w
s : aig.RefVec curr
idx : Nat
hidx1 : idx < w
hidx2 : curr ≤ idx
h✝¹ : curr < w
heq : curr < idx
h✝ : curr < distance % w
⊢ curr + 1 ≤ idx

Tactic:
omega

Result:
no goals

Proof state:
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
w : Nat
aig : AIG α
distance : Nat
input : aig.RefVec w
curr : Nat
hcurr : curr ≤ w
s : aig.RefVec curr
idx : Nat
hidx1 : idx < w
hidx2 : curr ≤ idx
⊢ (go input distance curr hcurr s).get idx hidx1 =
    if hidx3 : idx < distance % w then input.get (w - distance % w + idx) ⋯ else input.get (idx - distance % w) ⋯

Tactic:
unfold go

Result:
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
w : Nat
aig : AIG α
distance : Nat
input : aig.RefVec w
curr : Nat
hcurr : curr ≤ w
s : aig.RefVec curr
idx : Nat
hidx1 : idx < w
hidx2 : curr ≤ idx
⊢ (if hcurr1 : curr < w then
          if hcurr2 : curr < distance % w then
            let ref := input.get (w - distance % w + curr) ⋯;
            let s := s.push ref;
            go input distance (curr + 1) ⋯ s
          else
            let ref := input.get (curr - distance % w) ⋯;
            let s := s.push ref;
            go input distance (curr + 1) ⋯ s
        else
          let_fun hcurr := ⋯;
          hcurr ▸ s).get
      idx hidx1 =
    if hidx3 : idx < distance % w then input.get (w - distance % w + idx) ⋯ else input.get (idx - distance % w) ⋯