-- Mathlib/.lake/packages/lean4/src/lean/Std/Sat/AIG/RefVecOperator/Zip.lean
theorem go_get_aux {aig : AIG α} (curr : Nat) (hcurr : curr ≤ len) (s : RefVec aig curr)
    (lhs rhs : RefVec aig len) (f : (aig : AIG α) → BinaryInput aig → Entrypoint α)
    [LawfulOperator α BinaryInput f] [chainable : LawfulZipOperator α f] :
    -- The hfoo here is a trick to make the dependent type gods happy
    ∀ (idx : Nat) (hidx : idx < curr) (hfoo),
      (go aig curr s hcurr lhs rhs f).vec.get idx (by omega)
        =
      (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
lhs rhs : aig.RefVec len
f : (aig : AIG α) → aig.BinaryInput → Entrypoint α
inst✝ : LawfulOperator α BinaryInput f
chainable : LawfulZipOperator α f
idx : Nat
hidx : idx < curr
res : RefVecEntry α len
h✝ : curr < len
hgo :
  go (f aig { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝ }).aig (curr + 1)
      ((s.cast ⋯).push (f aig { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝ }).ref) ⋯ (lhs.cast ⋯) (rhs.cast ⋯) f =
    res
hfoo :
  aig.decls.size ≤
    (go (f aig { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝ }).aig (curr + 1)
            ((s.cast ⋯).push (f aig { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝ }).ref) ⋯ (lhs.cast ⋯) (rhs.cast ⋯)
            f).aig.decls.size
⊢ (go (f aig { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝ }).aig (curr + 1)
            ((s.cast ⋯).push (f aig { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝ }).ref) ⋯ (lhs.cast ⋯) (rhs.cast ⋯)
            f).vec.get
      idx ⋯ =
    (s.get idx hidx).cast hfoo

Tactic:
rw [go_get_aux]

Result:
case isTrue
α : Type
inst✝² : Hashable α
inst✝¹ : DecidableEq α
len : Nat
aig : AIG α
curr : Nat
hcurr : curr ≤ len
s : aig.RefVec curr
lhs rhs : aig.RefVec len
f : (aig : AIG α) → aig.BinaryInput → Entrypoint α
inst✝ : LawfulOperator α BinaryInput f
chainable : LawfulZipOperator α f
idx : Nat
hidx : idx < curr
res : RefVecEntry α len
h✝ : curr < len
hgo :
  go (f aig { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝ }).aig (curr + 1)
      ((s.cast ⋯).push (f aig { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝ }).ref) ⋯ (lhs.cast ⋯) (rhs.cast ⋯) f =
    res
hfoo :
  aig.decls.size ≤
    (go (f aig { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝ }).aig (curr + 1)
            ((s.cast ⋯).push (f aig { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝ }).ref) ⋯ (lhs.cast ⋯) (rhs.cast ⋯)
            f).aig.decls.size
⊢ (((s.cast ⋯).push (f aig { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝ }).ref).get idx ?isTrue.hidx).cast
      ?isTrue.hfoo =
    (s.get idx hidx).cast hfoo

case isTrue.hidx
α : Type
inst✝² : Hashable α
inst✝¹ : DecidableEq α
len : Nat
aig : AIG α
curr : Nat
hcurr : curr ≤ len
s : aig.RefVec curr
lhs rhs : aig.RefVec len
f : (aig : AIG α) → aig.BinaryInput → Entrypoint α
inst✝ : LawfulOperator α BinaryInput f
chainable : LawfulZipOperator α f
idx : Nat
hidx : idx < curr
res : RefVecEntry α len
h✝ : curr < len
hgo :
  go (f aig { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝ }).aig (curr + 1)
      ((s.cast ⋯).push (f aig { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝ }).ref) ⋯ (lhs.cast ⋯) (rhs.cast ⋯) f =
    res
hfoo :
  aig.decls.size ≤
    (go (f aig { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝ }).aig (curr + 1)
            ((s.cast ⋯).push (f aig { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝ }).ref) ⋯ (lhs.cast ⋯) (rhs.cast ⋯)
            f).aig.decls.size
⊢ idx < curr + 1

case isTrue.hfoo
α : Type
inst✝² : Hashable α
inst✝¹ : DecidableEq α
len : Nat
aig : AIG α
curr : Nat
hcurr : curr ≤ len
s : aig.RefVec curr
lhs rhs : aig.RefVec len
f : (aig : AIG α) → aig.BinaryInput → Entrypoint α
inst✝ : LawfulOperator α BinaryInput f
chainable : LawfulZipOperator α f
idx : Nat
hidx : idx < curr
res : RefVecEntry α len
h✝ : curr < len
hgo :
  go (f aig { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝ }).aig (curr + 1)
      ((s.cast ⋯).push (f aig { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝ }).ref) ⋯ (lhs.cast ⋯) (rhs.cast ⋯) f =
    res
hfoo :
  aig.decls.size ≤
    (go (f aig { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝ }).aig (curr + 1)
            ((s.cast ⋯).push (f aig { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝ }).ref) ⋯ (lhs.cast ⋯) (rhs.cast ⋯)
            f).aig.decls.size
⊢ (f aig { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝ }).aig.decls.size ≤
    (go (f aig { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝ }).aig (curr + 1)
            ((s.cast ⋯).push (f aig { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝ }).ref) ⋯ (lhs.cast ⋯) (rhs.cast ⋯)
            f).aig.decls.size

Proof state:
α : Type
inst✝² : Hashable α
inst✝¹ : DecidableEq α
len : Nat
aig : AIG α
curr : Nat
hcurr : curr ≤ len
s : aig.RefVec curr
lhs rhs : aig.RefVec len
f : (aig : AIG α) → aig.BinaryInput → Entrypoint α
inst✝ : LawfulOperator α BinaryInput f
chainable : LawfulZipOperator α f
idx : Nat
hidx : idx < curr
⊢ ∀ (hfoo : aig.decls.size ≤ (go aig curr s hcurr lhs rhs f).aig.decls.size),
    (go aig curr s hcurr lhs rhs f).vec.get idx ⋯ = (s.get idx hidx).cast hfoo

Tactic:
generalize hgo : go aig curr s hcurr lhs rhs f = res

Result:
α : Type
inst✝² : Hashable α
inst✝¹ : DecidableEq α
len : Nat
aig : AIG α
curr : Nat
hcurr : curr ≤ len
s : aig.RefVec curr
lhs rhs : aig.RefVec len
f : (aig : AIG α) → aig.BinaryInput → Entrypoint α
inst✝ : LawfulOperator α BinaryInput f
chainable : LawfulZipOperator α f
idx : Nat
hidx : idx < curr
res : RefVecEntry α len
hgo : go aig curr s hcurr lhs rhs f = res
⊢ ∀ (hfoo : aig.decls.size ≤ res.aig.decls.size), res.vec.get idx ⋯ = (s.get idx hidx).cast hfoo

Proof state:
case isTrue.hfoo
α : Type
inst✝² : Hashable α
inst✝¹ : DecidableEq α
len : Nat
aig : AIG α
curr : Nat
hcurr : curr ≤ len
s : aig.RefVec curr
lhs rhs : aig.RefVec len
f : (aig : AIG α) → aig.BinaryInput → Entrypoint α
inst✝ : LawfulOperator α BinaryInput f
chainable : LawfulZipOperator α f
idx : Nat
hidx : idx < curr
res : RefVecEntry α len
h✝ : curr < len
hgo :
  go (f aig { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝ }).aig (curr + 1)
      ((s.cast ⋯).push (f aig { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝ }).ref) ⋯ (lhs.cast ⋯) (rhs.cast ⋯) f =
    res
hfoo :
  aig.decls.size ≤
    (go (f aig { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝ }).aig (curr + 1)
            ((s.cast ⋯).push (f aig { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝ }).ref) ⋯ (lhs.cast ⋯) (rhs.cast ⋯)
            f).aig.decls.size
⊢ (f aig { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝ }).aig.decls.size ≤
    (go (f aig { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝ }).aig (curr + 1)
            ((s.cast ⋯).push (f aig { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝ }).ref) ⋯ (lhs.cast ⋯) (rhs.cast ⋯)
            f).aig.decls.size

Tactic:
apply go_le_size

Result:
no goals