-- Mathlib/.lake/packages/lean4/src/lean/Std/Tactic/BVDecide/Bitblast/BVExpr/Circuit/Lemmas/Operations/RotateRight.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 < w - distance % w then
          input.get ((distance % w) + idx) (by omega)
        else
          input.get (idx - (w - (distance % w))) (by omega)

Proof state:
case isTrue
α : 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
⊢ (if hcurr2 : curr < w - distance % w then
          let ref := input.get (distance % w + curr) ⋯;
          let s := s.push ref;
          go input distance (curr + 1) ⋯ s
        else
          let ref := input.get (curr - (w - distance % w)) ⋯;
          let s := s.push ref;
          go input distance (curr + 1) ⋯ s).get
      idx hidx1 =
    if hidx3 : idx < w - distance % w then input.get (distance % w + idx) ⋯ else input.get (idx - (w - distance % w)) ⋯

Tactic:
dsimp only

Result:
case isTrue
α : 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
⊢ (if hcurr2 : curr < w - distance % w then go input distance (curr + 1) ⋯ (s.push (input.get (distance % w + curr) ⋯))
        else go input distance (curr + 1) ⋯ (s.push (input.get (curr - (w - distance % w)) ⋯))).get
      idx hidx1 =
    if hidx3 : idx < w - distance % w then input.get (distance % w + idx) ⋯ else input.get (idx - (w - distance % w)) ⋯

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 < w - distance % w then input.get (distance % w + idx) ⋯ else input.get (idx - (w - 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 < w - distance % w then
            let ref := input.get (distance % w + curr) ⋯;
            let s := s.push ref;
            go input distance (curr + 1) ⋯ s
          else
            let ref := input.get (curr - (w - 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 < w - distance % w then input.get (distance % w + idx) ⋯ else input.get (idx - (w - distance % w)) ⋯

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
hidx3 : ¬idx < w - distance % w
⊢ idx - (w - distance % w) < 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
curr : Nat
hcurr : curr ≤ w
s : aig.RefVec curr
idx : Nat
hidx1 : idx < w
hidx2 : curr ≤ idx
h✝ : ¬curr < w
⊢ (let_fun hcurr := ⋯;
        hcurr ▸ s).get
      idx hidx1 =
    if hidx3 : idx < w - distance % w then input.get (distance % w + idx) ⋯ else input.get (idx - (w - distance % w)) ⋯

Tactic:
omega

Result:
no goals

Proof state:
case isTrue.inl.isFalse.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 < w - distance % w
h✝ : ¬idx < w - distance % w
⊢ input.get (curr - (w - distance % w)) ⋯ = input.get (idx - (w - distance % w)) ⋯

Tactic:
simp [heq]

Result:
no goals

Proof state:
case isTrue.inl.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 < w - distance % w
⊢ (go input distance (curr + 1) ⋯ (s.push (input.get (curr - (w - distance % w)) ⋯))).get idx hidx1 =
    if hidx3 : idx < w - distance % w then input.get (distance % w + idx) ⋯ else input.get (idx - (w - distance % w)) ⋯

Tactic:
split

Result:
case isTrue.inl.isFalse.isTrue
α : 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 < w - distance % w
h✝ : idx < w - distance % w
⊢ (go input distance (curr + 1) ⋯ (s.push (input.get (curr - (w - distance % w)) ⋯))).get idx hidx1 =
    input.get (distance % w + idx) ⋯

case isTrue.inl.isFalse.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 < w - distance % w
h✝ : ¬idx < w - distance % w
⊢ (go input distance (curr + 1) ⋯ (s.push (input.get (curr - (w - distance % w)) ⋯))).get idx hidx1 =
    input.get (idx - (w - distance % w)) ⋯

Proof state:
case isTrue.inl.isTrue.isTrue.hidx
α : 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 < w - distance % w
h✝ : idx < w - distance % w
⊢ idx = curr

Tactic:
omega

Result:
no goals

Proof state:
case isTrue.inl
α : 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
⊢ (if hcurr2 : curr < w - distance % w then go input distance (curr + 1) ⋯ (s.push (input.get (distance % w + curr) ⋯))
        else go input distance (curr + 1) ⋯ (s.push (input.get (curr - (w - distance % w)) ⋯))).get
      idx hidx1 =
    if hidx3 : idx < w - distance % w then input.get (distance % w + idx) ⋯ else input.get (idx - (w - distance % w)) ⋯

Tactic:
split

Result:
case isTrue.inl.isTrue
α : 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 < w - distance % w
⊢ (go input distance (curr + 1) ⋯ (s.push (input.get (distance % w + curr) ⋯))).get idx hidx1 =
    if hidx3 : idx < w - distance % w then input.get (distance % w + idx) ⋯ else input.get (idx - (w - distance % w)) ⋯

case isTrue.inl.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 < w - distance % w
⊢ (go input distance (curr + 1) ⋯ (s.push (input.get (curr - (w - distance % w)) ⋯))).get idx hidx1 =
    if hidx3 : idx < w - distance % w then input.get (distance % w + idx) ⋯ else input.get (idx - (w - distance % w)) ⋯