-- Mathlib/.lake/packages/lean4/src/lean/Std/Tactic/BVDecide/Bitblast/BVExpr/Circuit/Impl/Var.lean
theorem blastVar.go_le_size {aig : AIG BVBit} (curr : Nat) (s : AIG.RefVec aig curr) (a : Nat)
    (hcurr : curr ≤ w) :
    aig.decls.size ≤ (go aig w a curr s hcurr).aig.decls.size

Proof state:
case isTrue
w : Nat
aig : AIG BVBit
curr : Nat
s : aig.RefVec curr
a : Nat
hcurr : curr ≤ w
h✝ : curr < w
⊢ aig.decls.size ≤
    (go (aig.mkAtomCached (BVBit.mk a ⟨curr, h✝⟩)).aig w a (curr + 1)
            ((s.cast ⋯).push (aig.mkAtomCached (BVBit.mk a ⟨curr, h✝⟩)).ref) ⋯).aig.decls.size

Tactic:
refine Nat.le_trans ?_ (by apply go_le_size)

Result:
case isTrue
w : Nat
aig : AIG BVBit
curr : Nat
s : aig.RefVec curr
a : Nat
hcurr : curr ≤ w
h✝ : curr < w
⊢ aig.decls.size ≤ (aig.mkAtomCached (BVBit.mk a ⟨curr, h✝⟩)).aig.decls.size

Proof state:
w : Nat
aig : AIG BVBit
curr : Nat
s : aig.RefVec curr
a : Nat
hcurr : curr ≤ w
h✝ : curr < w
⊢ ?m.7945 ≤
    (go (aig.mkAtomCached (BVBit.mk a ⟨curr, h✝⟩)).aig w a (curr + 1)
            ((s.cast ⋯).push (aig.mkAtomCached (BVBit.mk a ⟨curr, h✝⟩)).ref) ⋯).aig.decls.size

Tactic:
apply go_le_size

Result:
no goals

Proof state:
case isTrue
w : Nat
aig : AIG BVBit
curr : Nat
s : aig.RefVec curr
a : Nat
hcurr : curr ≤ w
h✝ : curr < w
⊢ aig.decls.size ≤
    (let res := aig.mkAtomCached (BVBit.mk a ⟨curr, h✝⟩);
          let aig_1 := res.aig;
          let bitRef := res.ref;
          let s := s.cast ⋯;
          let s := s.push bitRef;
          go aig_1 w a (curr + 1) s ⋯).aig.decls.size

Tactic:
dsimp only

Result:
case isTrue
w : Nat
aig : AIG BVBit
curr : Nat
s : aig.RefVec curr
a : Nat
hcurr : curr ≤ w
h✝ : curr < w
⊢ aig.decls.size ≤
    (go (aig.mkAtomCached (BVBit.mk a ⟨curr, h✝⟩)).aig w a (curr + 1)
            ((s.cast ⋯).push (aig.mkAtomCached (BVBit.mk a ⟨curr, h✝⟩)).ref) ⋯).aig.decls.size

Proof state:
w : Nat
aig : AIG BVBit
curr : Nat
s : aig.RefVec curr
a : Nat
hcurr : curr ≤ w
⊢ aig.decls.size ≤ (go aig w a curr s hcurr).aig.decls.size

Tactic:
unfold go

Result:
w : Nat
aig : AIG BVBit
curr : Nat
s : aig.RefVec curr
a : Nat
hcurr : curr ≤ w
⊢ aig.decls.size ≤
    (if hcurr : curr < w then
            let res := aig.mkAtomCached (BVBit.mk a ⟨curr, hcurr⟩);
            let aig_1 := res.aig;
            let bitRef := res.ref;
            let s := s.cast ⋯;
            let s := s.push bitRef;
            go aig_1 w a (curr + 1) s ⋯
          else
            let_fun hcurr := ⋯;
            { aig := aig, vec := hcurr ▸ s }).aig.decls.size

Proof state:
w : Nat
aig : AIG BVBit
curr : Nat
s : aig.RefVec curr
a : Nat
hcurr : curr ≤ w
⊢ aig.decls.size ≤
    (if hcurr : curr < w then
            let res := aig.mkAtomCached (BVBit.mk a ⟨curr, hcurr⟩);
            let aig_1 := res.aig;
            let bitRef := res.ref;
            let s := s.cast ⋯;
            let s := s.push bitRef;
            go aig_1 w a (curr + 1) s ⋯
          else
            let_fun hcurr := ⋯;
            { aig := aig, vec := hcurr ▸ s }).aig.decls.size

Tactic:
split

Result:
case isTrue
w : Nat
aig : AIG BVBit
curr : Nat
s : aig.RefVec curr
a : Nat
hcurr : curr ≤ w
h✝ : curr < w
⊢ aig.decls.size ≤
    (let res := aig.mkAtomCached (BVBit.mk a ⟨curr, h✝⟩);
          let aig_1 := res.aig;
          let bitRef := res.ref;
          let s := s.cast ⋯;
          let s := s.push bitRef;
          go aig_1 w a (curr + 1) s ⋯).aig.decls.size

case isFalse
w : Nat
aig : AIG BVBit
curr : Nat
s : aig.RefVec curr
a : Nat
hcurr : curr ≤ w
h✝ : ¬curr < w
⊢ aig.decls.size ≤
    (let_fun hcurr := ⋯;
          { aig := aig, vec := hcurr ▸ s }).aig.decls.size

Proof state:
case isTrue
w : Nat
aig : AIG BVBit
curr : Nat
s : aig.RefVec curr
a : Nat
hcurr : curr ≤ w
h✝ : curr < w
⊢ aig.decls.size ≤ (aig.mkAtomCached (BVBit.mk a ⟨curr, h✝⟩)).aig.decls.size

Tactic:
apply AIG.LawfulOperator.le_size (f := AIG.mkAtomCached)

Result:
no goals

Proof state:
case isFalse
w : Nat
aig : AIG BVBit
curr : Nat
s : aig.RefVec curr
a : Nat
hcurr : curr ≤ w
h✝ : ¬curr < w
⊢ aig.decls.size ≤
    (let_fun hcurr := ⋯;
          { aig := aig, vec := hcurr ▸ s }).aig.decls.size

Tactic:
simp

Result:
no goals