-- 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:
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 : { aig := aig, vec := ⋯ ▸ s } = res
this : curr = len
⊢ (⋯ ▸ s).refs[idx] = s.refs[idx]

Tactic:
subst this

Result:
case isFalse
α : Type
inst✝³ : Hashable α
inst✝² : DecidableEq α
aig : AIG α
curr : Nat
s : aig.RefVec curr
f : (aig : AIG α) → aig.Ref → Entrypoint α
inst✝¹ : LawfulOperator α Ref f
inst✝ : LawfulMapOperator α f
idx : Nat
hidx : idx < curr
hcurr : curr ≤ curr
input : aig.RefVec curr
res : RefVecEntry α curr
h✝ : ¬curr < curr
hgo : { aig := aig, vec := ⋯ ▸ s } = res
⊢ (⋯ ▸ s).refs[idx] = s.refs[idx]

Proof state:
case isTrue.hidx
α : 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
⊢ idx < curr

Tactic:
assumption

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).gate = (s.get idx hidx).gate

Tactic:
rw [AIG.RefVec.get_cast]

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.get idx ?isTrue.hidx).cast ⋯).gate = (s.get idx hidx).gate

case isTrue.hidx
α : 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
⊢ idx < curr

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 ≤ res.aig.decls.size), res.vec.get idx ⋯ = (s.get idx hidx).cast hfoo

Tactic:
rw [← 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 :
  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),
    (go (f aig (input.get curr h✝)).aig (curr + 1) ⋯ ((s.cast ⋯).push (f aig (input.get curr h✝)).ref) (input.cast ⋯)
              f).vec.get
        idx ⋯ =
      (s.get idx hidx).cast hfoo

Proof state:
case isFalse
α : Type
inst✝³ : Hashable α
inst✝² : DecidableEq α
aig : AIG α
curr : Nat
s : aig.RefVec curr
f : (aig : AIG α) → aig.Ref → Entrypoint α
inst✝¹ : LawfulOperator α Ref f
inst✝ : LawfulMapOperator α f
idx : Nat
hidx : idx < curr
hcurr : curr ≤ curr
input : aig.RefVec curr
res : RefVecEntry α curr
h✝ : ¬curr < curr
hgo : { aig := aig, vec := ⋯ ▸ s } = res
⊢ (⋯ ▸ s).refs[idx] = s.refs[idx]

Tactic:
rfl

Result:
no goals