-- Mathlib/.lake/packages/lean4/src/lean/Std/Sat/AIG/If.lean
theorem denote_go {w : Nat} (aig : AIG α) (curr : Nat) (hcurr : curr ≤ w) (discr : Ref aig)
    (lhs rhs : RefVec aig w) (s : RefVec aig curr) :
    ∀ (idx : Nat) (hidx1 : idx < w),
      curr ≤ idx
        →
      ⟦
        (go aig curr hcurr discr lhs rhs s).aig,
        (go aig curr hcurr discr lhs rhs s).vec.get idx hidx1,
        assign
      ⟧
        =
      if ⟦aig, discr, assign⟧ then
        ⟦aig, lhs.get idx hidx1, assign⟧
      else
        ⟦aig, rhs.get idx hidx1, assign⟧

Proof state:
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
assign : α → Bool
w : Nat
aig : AIG α
curr : Nat
hcurr : curr ≤ w
discr : aig.Ref
lhs rhs : aig.RefVec w
s : aig.RefVec curr
idx : Nat
hidx1 : idx < w
hidx2 : curr ≤ idx
res : RefVecEntry α w
hgo :
  (if hcurr : curr < w then
      let input := { discr := discr, lhs := lhs.get curr hcurr, rhs := rhs.get curr hcurr };
      let res := aig.mkIfCached input;
      let aig_1 := res.aig;
      let ref := res.ref;
      let_fun this := ⋯;
      let discr_1 := discr.cast this;
      let lhs_1 := lhs.cast this;
      let rhs_1 := rhs.cast this;
      let s := s.cast this;
      let s := s.push ref;
      go aig_1 (curr + 1) ⋯ discr_1 lhs_1 rhs_1 s
    else
      let_fun this := ⋯;
      { aig := aig, vec := this ▸ s }) =
    res
⊢ ⟦assign, { aig := res.aig, ref := res.vec.get idx hidx1 }⟧ =
    if ⟦assign, { aig := aig, ref := discr }⟧ = true then ⟦assign, { aig := aig, ref := lhs.get idx hidx1 }⟧
    else ⟦assign, { aig := aig, ref := rhs.get idx hidx1 }⟧

Tactic:
dsimp only at hgo

Result:
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
assign : α → Bool
w : Nat
aig : AIG α
curr : Nat
hcurr : curr ≤ w
discr : aig.Ref
lhs rhs : aig.RefVec w
s : aig.RefVec curr
idx : Nat
hidx1 : idx < w
hidx2 : curr ≤ idx
res : RefVecEntry α w
hgo :
  (if hcurr : curr < w then
      go (aig.mkIfCached { discr := discr, lhs := lhs.get curr hcurr, rhs := rhs.get curr hcurr }).aig (curr + 1) ⋯
        (discr.cast ⋯) (lhs.cast ⋯) (rhs.cast ⋯)
        ((s.cast ⋯).push (aig.mkIfCached { discr := discr, lhs := lhs.get curr hcurr, rhs := rhs.get curr hcurr }).ref)
    else { aig := aig, vec := ⋯ ▸ s }) =
    res
⊢ ⟦assign, { aig := res.aig, ref := res.vec.get idx hidx1 }⟧ =
    if ⟦assign, { aig := aig, ref := discr }⟧ = true then ⟦assign, { aig := aig, ref := lhs.get idx hidx1 }⟧
    else ⟦assign, { aig := aig, ref := rhs.get idx hidx1 }⟧

Proof state:
case isTrue.inl.hstart
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
assign : α → Bool
w : Nat
aig : AIG α
curr : Nat
hcurr : curr ≤ w
discr : aig.Ref
lhs rhs : aig.RefVec w
s : aig.RefVec curr
res : RefVecEntry α w
h✝ : curr < w
hgo :
  go (aig.mkIfCached { discr := discr, lhs := lhs.get curr h✝, rhs := rhs.get curr h✝ }).aig (curr + 1) ⋯ (discr.cast ⋯)
      (lhs.cast ⋯) (rhs.cast ⋯)
      ((s.cast ⋯).push (aig.mkIfCached { discr := discr, lhs := lhs.get curr h✝, rhs := rhs.get curr h✝ }).ref) =
    res
hidx1 : curr < w
hidx2 : curr ≤ curr
⊢ ((aig.mkIfCached { discr := discr, lhs := lhs.get curr h✝, rhs := rhs.get curr h✝ }).ref.cast ⋯).gate <
    (aig.mkIfCached { discr := discr, lhs := lhs.get curr h✝, rhs := rhs.get curr h✝ }).aig.decls.size

Tactic:
simp [Ref.hgate]

Result:
no goals

Proof state:
case isTrue.inr
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
assign : α → Bool
w : Nat
aig : AIG α
curr : Nat
hcurr : curr ≤ w
discr : aig.Ref
lhs rhs : aig.RefVec w
s : aig.RefVec curr
idx : Nat
hidx1 : idx < w
hidx2 : curr ≤ idx
res : RefVecEntry α w
h✝ : curr < w
hgo :
  go (aig.mkIfCached { discr := discr, lhs := lhs.get curr h✝, rhs := rhs.get curr h✝ }).aig (curr + 1) ⋯ (discr.cast ⋯)
      (lhs.cast ⋯) (rhs.cast ⋯)
      ((s.cast ⋯).push (aig.mkIfCached { discr := discr, lhs := lhs.get curr h✝, rhs := rhs.get curr h✝ }).ref) =
    res
heq : curr < idx
⊢ (if ⟦assign, { aig := aig, ref := { gate := (discr.cast ⋯).gate, hgate := ?isTrue.inr } }⟧ = true then
      ⟦assign,
        { aig := (aig.mkIfCached { discr := discr, lhs := lhs.get curr h✝, rhs := rhs.get curr h✝ }).aig,
          ref := (lhs.cast ⋯).get idx hidx1 }⟧
    else
      ⟦assign,
        { aig := (aig.mkIfCached { discr := discr, lhs := lhs.get curr h✝, rhs := rhs.get curr h✝ }).aig,
          ref := (rhs.cast ⋯).get idx hidx1 }⟧) =
    if ⟦assign, { aig := aig, ref := discr }⟧ = true then ⟦assign, { aig := aig, ref := lhs.get idx hidx1 }⟧
    else ⟦assign, { aig := aig, ref := rhs.get idx hidx1 }⟧

case isTrue.inr
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
assign : α → Bool
w : Nat
aig : AIG α
curr : Nat
hcurr : curr ≤ w
discr : aig.Ref
lhs rhs : aig.RefVec w
s : aig.RefVec curr
idx : Nat
hidx1 : idx < w
hidx2 : curr ≤ idx
res : RefVecEntry α w
h✝ : curr < w
hgo :
  go (aig.mkIfCached { discr := discr, lhs := lhs.get curr h✝, rhs := rhs.get curr h✝ }).aig (curr + 1) ⋯ (discr.cast ⋯)
      (lhs.cast ⋯) (rhs.cast ⋯)
      ((s.cast ⋯).push (aig.mkIfCached { discr := discr, lhs := lhs.get curr h✝, rhs := rhs.get curr h✝ }).ref) =
    res
heq : curr < idx
⊢ (discr.cast ⋯).gate < aig.decls.size

Tactic:
rw [LawfulOperator.denote_mem_prefix (f := mkIfCached)]

Result:
case isTrue.inr
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
assign : α → Bool
w : Nat
aig : AIG α
curr : Nat
hcurr : curr ≤ w
discr : aig.Ref
lhs rhs : aig.RefVec w
s : aig.RefVec curr
idx : Nat
hidx1 : idx < w
hidx2 : curr ≤ idx
res : RefVecEntry α w
h✝ : curr < w
hgo :
  go (aig.mkIfCached { discr := discr, lhs := lhs.get curr h✝, rhs := rhs.get curr h✝ }).aig (curr + 1) ⋯ (discr.cast ⋯)
      (lhs.cast ⋯) (rhs.cast ⋯)
      ((s.cast ⋯).push (aig.mkIfCached { discr := discr, lhs := lhs.get curr h✝, rhs := rhs.get curr h✝ }).ref) =
    res
heq : curr < idx
⊢ (if ⟦assign, { aig := aig, ref := { gate := (discr.cast ⋯).gate, hgate := ?isTrue.inr } }⟧ = true then
      ⟦assign, { aig := aig, ref := { gate := ((lhs.cast ⋯).get idx hidx1).gate, hgate := ?isTrue.inr } }⟧
    else
      ⟦assign,
        { aig := (aig.mkIfCached { discr := discr, lhs := lhs.get curr h✝, rhs := rhs.get curr h✝ }).aig,
          ref := (rhs.cast ⋯).get idx hidx1 }⟧) =
    if ⟦assign, { aig := aig, ref := discr }⟧ = true then ⟦assign, { aig := aig, ref := lhs.get idx hidx1 }⟧
    else ⟦assign, { aig := aig, ref := rhs.get idx hidx1 }⟧

case isTrue.inr
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
assign : α → Bool
w : Nat
aig : AIG α
curr : Nat
hcurr : curr ≤ w
discr : aig.Ref
lhs rhs : aig.RefVec w
s : aig.RefVec curr
idx : Nat
hidx1 : idx < w
hidx2 : curr ≤ idx
res : RefVecEntry α w
h✝ : curr < w
hgo :
  go (aig.mkIfCached { discr := discr, lhs := lhs.get curr h✝, rhs := rhs.get curr h✝ }).aig (curr + 1) ⋯ (discr.cast ⋯)
      (lhs.cast ⋯) (rhs.cast ⋯)
      ((s.cast ⋯).push (aig.mkIfCached { discr := discr, lhs := lhs.get curr h✝, rhs := rhs.get curr h✝ }).ref) =
    res
heq : curr < idx
⊢ ((lhs.cast ⋯).get idx hidx1).gate < aig.decls.size

case isTrue.inr
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
assign : α → Bool
w : Nat
aig : AIG α
curr : Nat
hcurr : curr ≤ w
discr : aig.Ref
lhs rhs : aig.RefVec w
s : aig.RefVec curr
idx : Nat
hidx1 : idx < w
hidx2 : curr ≤ idx
res : RefVecEntry α w
h✝ : curr < w
hgo :
  go (aig.mkIfCached { discr := discr, lhs := lhs.get curr h✝, rhs := rhs.get curr h✝ }).aig (curr + 1) ⋯ (discr.cast ⋯)
      (lhs.cast ⋯) (rhs.cast ⋯)
      ((s.cast ⋯).push (aig.mkIfCached { discr := discr, lhs := lhs.get curr h✝, rhs := rhs.get curr h✝ }).ref) =
    res
heq : curr < idx
⊢ (discr.cast ⋯).gate < aig.decls.size