-- Mathlib/.lake/packages/lean4/src/lean/Std/Sat/AIG/RefVecOperator/Map.lean
theorem go_get_aux {aig : AIG α} (curr : Nat) (hcurr : curr ≤ len) (s : RefVec aig curr)
    (input : RefVec aig len) (f : (aig : AIG α) → Ref aig → Entrypoint α)
    [LawfulOperator α Ref f] [LawfulMapOperator α f] :
    -- The hfoo here is a trick to make the dependent type gods happy.
    ∀ (idx : Nat) (hidx : idx < curr) (hfoo),
      (go aig curr hcurr s input f).vec.get idx (by omega)
        =
      (s.get idx hidx).cast hfoo

Proof state:
α : Type
inst✝³ : Hashable α
inst✝² : DecidableEq α
len : Nat
aig : AIG α
curr : Nat
hcurr : curr ≤ len
s : aig.RefVec curr
input : aig.RefVec len
f : (aig : AIG α) → aig.Ref → Entrypoint α
inst✝¹ : LawfulOperator α Ref f
inst✝ : LawfulMapOperator α f
idx : Nat
hidx : idx < curr
res : RefVecEntry α len
hgo :
  (if hidx : curr < len then
      let res := f aig (input.get curr hidx);
      let aig_1 := res.aig;
      let newRef := res.ref;
      let_fun this := ⋯;
      let input_1 := input.cast this;
      let s := s.cast this;
      let s := s.push newRef;
      go aig_1 (curr + 1) ⋯ s input_1 f
    else
      let_fun this := ⋯;
      { aig := aig, vec := this ▸ s }) =
    res
⊢ ∀ (hfoo : aig.decls.size ≤ res.aig.decls.size), res.vec.get idx ⋯ = (s.get idx hidx).cast hfoo

Tactic:
split at hgo

Result:
case isTrue
α : Type
inst✝³ : Hashable α
inst✝² : DecidableEq α
len : Nat
aig : AIG α
curr : Nat
hcurr : curr ≤ len
s : aig.RefVec curr
input : aig.RefVec len
f : (aig : AIG α) → aig.Ref → Entrypoint α
inst✝¹ : LawfulOperator α Ref f
inst✝ : LawfulMapOperator α f
idx : Nat
hidx : idx < curr
res : RefVecEntry α len
h✝ : curr < len
hgo :
  (let res := f aig (input.get curr h✝);
    let aig_1 := res.aig;
    let newRef := res.ref;
    let_fun this := ⋯;
    let input_1 := input.cast this;
    let s := s.cast this;
    let s := s.push newRef;
    go aig_1 (curr + 1) ⋯ s input_1 f) =
    res
⊢ ∀ (hfoo : aig.decls.size ≤ res.aig.decls.size), res.vec.get idx ⋯ = (s.get idx hidx).cast hfoo

case isFalse
α : Type
inst✝³ : Hashable α
inst✝² : DecidableEq α
len : Nat
aig : AIG α
curr : Nat
hcurr : curr ≤ len
s : aig.RefVec curr
input : aig.RefVec len
f : (aig : AIG α) → aig.Ref → Entrypoint α
inst✝¹ : LawfulOperator α Ref f
inst✝ : LawfulMapOperator α f
idx : Nat
hidx : idx < curr
res : RefVecEntry α len
h✝ : ¬curr < len
hgo :
  (let_fun this := ⋯;
    { aig := aig, vec := this ▸ s }) =
    res
⊢ ∀ (hfoo : aig.decls.size ≤ res.aig.decls.size), res.vec.get idx ⋯ = (s.get idx hidx).cast hfoo

Proof state:
case isTrue
α : Type
inst✝³ : Hashable α
inst✝² : DecidableEq α
len : Nat
aig : AIG α
curr : Nat
hcurr : curr ≤ len
s : aig.RefVec curr
input : aig.RefVec len
f : (aig : AIG α) → aig.Ref → Entrypoint α
inst✝¹ : LawfulOperator α Ref f
inst✝ : LawfulMapOperator α f
idx : Nat
hidx : idx < curr
res : RefVecEntry α len
h✝ : curr < len
hgo :
  go (f aig (input.get curr h✝)).aig (curr + 1) ⋯ ((s.cast ⋯).push (f aig (input.get curr h✝)).ref) (input.cast ⋯) f =
    res
hfoo :
  aig.decls.size ≤
    (go (f aig (input.get curr h✝)).aig (curr + 1) ⋯ ((s.cast ⋯).push (f aig (input.get curr h✝)).ref) (input.cast ⋯)
            f).aig.decls.size
⊢ ((s.get idx ?isTrue.hidx).cast ⋯).gate = (s.get idx hidx).gate

Tactic:
simp

Result:
no goals

Proof state:
case isTrue
α : Type
inst✝³ : Hashable α
inst✝² : DecidableEq α
len : Nat
aig : AIG α
curr : Nat
hcurr : curr ≤ len
s : aig.RefVec curr
input : aig.RefVec len
f : (aig : AIG α) → aig.Ref → Entrypoint α
inst✝¹ : LawfulOperator α Ref f
inst✝ : LawfulMapOperator α f
idx : Nat
hidx : idx < curr
res : RefVecEntry α len
h✝ : curr < len
hgo :
  go (f aig (input.get curr h✝)).aig (curr + 1) ⋯ ((s.cast ⋯).push (f aig (input.get curr h✝)).ref) (input.cast ⋯) f =
    res
hfoo :
  aig.decls.size ≤
    (go (f aig (input.get curr h✝)).aig (curr + 1) ⋯ ((s.cast ⋯).push (f aig (input.get curr h✝)).ref) (input.cast ⋯)
            f).aig.decls.size
⊢ ((s.cast ⋯).get idx ?isTrue.hidx).cast ?isTrue.hfoo = (s.get idx hidx).cast hfoo

Tactic:
simp only [Ref.cast, Ref.mk.injEq]

Result:
case isTrue
α : Type
inst✝³ : Hashable α
inst✝² : DecidableEq α
len : Nat
aig : AIG α
curr : Nat
hcurr : curr ≤ len
s : aig.RefVec curr
input : aig.RefVec len
f : (aig : AIG α) → aig.Ref → Entrypoint α
inst✝¹ : LawfulOperator α Ref f
inst✝ : LawfulMapOperator α f
idx : Nat
hidx : idx < curr
res : RefVecEntry α len
h✝ : curr < len
hgo :
  go (f aig (input.get curr h✝)).aig (curr + 1) ⋯ ((s.cast ⋯).push (f aig (input.get curr h✝)).ref) (input.cast ⋯) f =
    res
hfoo :
  aig.decls.size ≤
    (go (f aig (input.get curr h✝)).aig (curr + 1) ⋯ ((s.cast ⋯).push (f aig (input.get curr h✝)).ref) (input.cast ⋯)
            f).aig.decls.size
⊢ ((s.cast ⋯).get idx ?isTrue.hidx).gate = (s.get idx hidx).gate