-- Mathlib/.lake/packages/lean4/src/lean/Std/Tactic/BVDecide/Bitblast/BVExpr/Circuit/Impl/Operations/ZeroExtend.lean
theorem go_le_size (aig : AIG α) (w : Nat) (input : AIG.RefVec aig w) (newWidth curr : Nat)
    (hcurr : curr ≤ newWidth) (s : AIG.RefVec aig curr) :
    aig.decls.size ≤ (go aig w input newWidth curr hcurr s).aig.decls.size

Proof state:
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
aig : AIG α
w : Nat
input : aig.RefVec w
newWidth curr : Nat
hcurr : curr ≤ newWidth
s : aig.RefVec curr
⊢ aig.decls.size ≤
    (if hcurr1 : curr < newWidth then
            if hcurr2 : curr < w then
              let s := s.push (input.get curr hcurr2);
              go aig w input newWidth (curr + 1) ⋯ s
            else
              let res := aig.mkConstCached false;
              let aig_1 := res.aig;
              let zeroRef := res.ref;
              let_fun hcast := ⋯;
              let input := input.cast hcast;
              let s := s.cast hcast;
              let s := s.push zeroRef;
              go aig_1 w input newWidth (curr + 1) ⋯ s
          else
            let_fun hcurr := ⋯;
            { aig := aig, vec := hcurr ▸ s }).aig.decls.size

Tactic:
split

Result:
case isTrue
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
aig : AIG α
w : Nat
input : aig.RefVec w
newWidth curr : Nat
hcurr : curr ≤ newWidth
s : aig.RefVec curr
h✝ : curr < newWidth
⊢ aig.decls.size ≤
    (if hcurr2 : curr < w then
            let s := s.push (input.get curr hcurr2);
            go aig w input newWidth (curr + 1) ⋯ s
          else
            let res := aig.mkConstCached false;
            let aig_1 := res.aig;
            let zeroRef := res.ref;
            let_fun hcast := ⋯;
            let input := input.cast hcast;
            let s := s.cast hcast;
            let s := s.push zeroRef;
            go aig_1 w input newWidth (curr + 1) ⋯ s).aig.decls.size

case isFalse
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
aig : AIG α
w : Nat
input : aig.RefVec w
newWidth curr : Nat
hcurr : curr ≤ newWidth
s : aig.RefVec curr
h✝ : ¬curr < newWidth
⊢ aig.decls.size ≤
    (let_fun hcurr := ⋯;
          { aig := aig, vec := hcurr ▸ s }).aig.decls.size

Proof state:
case isTrue.isTrue
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
aig : AIG α
w : Nat
input : aig.RefVec w
newWidth curr : Nat
hcurr : curr ≤ newWidth
s : aig.RefVec curr
h✝¹ : curr < newWidth
h✝ : curr < w
⊢ aig.decls.size ≤ (go aig w input newWidth (curr + 1) ⋯ (s.push (input.get curr h✝))).aig.decls.size

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

Result:
case isTrue.isTrue
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
aig : AIG α
w : Nat
input : aig.RefVec w
newWidth curr : Nat
hcurr : curr ≤ newWidth
s : aig.RefVec curr
h✝¹ : curr < newWidth
h✝ : curr < w
⊢ aig.decls.size ≤ aig.decls.size

Proof state:
case isTrue.isTrue
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
aig : AIG α
w : Nat
input : aig.RefVec w
newWidth curr : Nat
hcurr : curr ≤ newWidth
s : aig.RefVec curr
h✝¹ : curr < newWidth
h✝ : curr < w
⊢ aig.decls.size ≤ aig.decls.size

Tactic:
omega

Result:
no goals

Proof state:
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
aig : AIG α
w : Nat
input : aig.RefVec w
newWidth curr : Nat
hcurr : curr ≤ newWidth
s : aig.RefVec curr
h✝¹ : curr < newWidth
h✝ : ¬curr < w
⊢ ?m.14114 ≤
    (go (aig.mkConstCached false).aig w (input.cast ⋯) newWidth (curr + 1) ⋯
            ((s.cast ⋯).push (aig.mkConstCached false).ref)).aig.decls.size

Tactic:
apply go_le_size

Result:
no goals

Proof state:
case isFalse
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
aig : AIG α
w : Nat
input : aig.RefVec w
newWidth curr : Nat
hcurr : curr ≤ newWidth
s : aig.RefVec curr
h✝ : ¬curr < newWidth
⊢ aig.decls.size ≤
    (let_fun hcurr := ⋯;
          { aig := aig, vec := hcurr ▸ s }).aig.decls.size

Tactic:
simp

Result:
no goals

Proof state:
case isTrue.isFalse
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
aig : AIG α
w : Nat
input : aig.RefVec w
newWidth curr : Nat
hcurr : curr ≤ newWidth
s : aig.RefVec curr
h✝¹ : curr < newWidth
h✝ : ¬curr < w
⊢ aig.decls.size ≤
    (go (aig.mkConstCached false).aig w (input.cast ⋯) newWidth (curr + 1) ⋯
            ((s.cast ⋯).push (aig.mkConstCached false).ref)).aig.decls.size

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

Result:
case isTrue.isFalse
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
aig : AIG α
w : Nat
input : aig.RefVec w
newWidth curr : Nat
hcurr : curr ≤ newWidth
s : aig.RefVec curr
h✝¹ : curr < newWidth
h✝ : ¬curr < w
⊢ aig.decls.size ≤ (aig.mkConstCached false).aig.decls.size

Proof state:
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
aig : AIG α
w : Nat
input : aig.RefVec w
newWidth curr : Nat
hcurr : curr ≤ newWidth
s : aig.RefVec curr
⊢ aig.decls.size ≤ (go aig w input newWidth curr hcurr s).aig.decls.size

Tactic:
unfold go

Result:
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
aig : AIG α
w : Nat
input : aig.RefVec w
newWidth curr : Nat
hcurr : curr ≤ newWidth
s : aig.RefVec curr
⊢ aig.decls.size ≤
    (if hcurr1 : curr < newWidth then
            if hcurr2 : curr < w then
              let s := s.push (input.get curr hcurr2);
              go aig w input newWidth (curr + 1) ⋯ s
            else
              let res := aig.mkConstCached false;
              let aig_1 := res.aig;
              let zeroRef := res.ref;
              let_fun hcast := ⋯;
              let input := input.cast hcast;
              let s := s.cast hcast;
              let s := s.push zeroRef;
              go aig_1 w input newWidth (curr + 1) ⋯ s
          else
            let_fun hcurr := ⋯;
            { aig := aig, vec := hcurr ▸ s }).aig.decls.size

Proof state:
case isTrue
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
aig : AIG α
w : Nat
input : aig.RefVec w
newWidth curr : Nat
hcurr : curr ≤ newWidth
s : aig.RefVec curr
h✝ : curr < newWidth
⊢ aig.decls.size ≤
    (if hcurr2 : curr < w then go aig w input newWidth (curr + 1) ⋯ (s.push (input.get curr hcurr2))
          else
            go (aig.mkConstCached false).aig w (input.cast ⋯) newWidth (curr + 1) ⋯
              ((s.cast ⋯).push (aig.mkConstCached false).ref)).aig.decls.size

Tactic:
split

Result:
case isTrue.isTrue
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
aig : AIG α
w : Nat
input : aig.RefVec w
newWidth curr : Nat
hcurr : curr ≤ newWidth
s : aig.RefVec curr
h✝¹ : curr < newWidth
h✝ : curr < w
⊢ aig.decls.size ≤ (go aig w input newWidth (curr + 1) ⋯ (s.push (input.get curr h✝))).aig.decls.size

case isTrue.isFalse
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
aig : AIG α
w : Nat
input : aig.RefVec w
newWidth curr : Nat
hcurr : curr ≤ newWidth
s : aig.RefVec curr
h✝¹ : curr < newWidth
h✝ : ¬curr < w
⊢ aig.decls.size ≤
    (go (aig.mkConstCached false).aig w (input.cast ⋯) newWidth (curr + 1) ⋯
            ((s.cast ⋯).push (aig.mkConstCached false).ref)).aig.decls.size

Proof state:
case isTrue.isFalse
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
aig : AIG α
w : Nat
input : aig.RefVec w
newWidth curr : Nat
hcurr : curr ≤ newWidth
s : aig.RefVec curr
h✝¹ : curr < newWidth
h✝ : ¬curr < w
⊢ aig.decls.size ≤ (aig.mkConstCached false).aig.decls.size

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

Result:
no goals