-- Mathlib/.lake/packages/lean4/src/lean/Std/Tactic/BVDecide/Bitblast/BVExpr/Circuit/Impl/Carry.lean
theorem go_le_size {aig : AIG α} {cin} {lhs rhs : AIG.RefVec aig w} :
    aig.decls.size ≤ (go aig lhs rhs curr cin).aig.decls.size

Proof state:
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
w curr : Nat
aig : AIG α
cin : aig.Ref
lhs rhs : aig.RefVec w
h✝ : curr < w
⊢ ?m.7169 ≤
    (go (mkFullAdderCarry aig { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝, cin := cin }).aig (lhs.cast ⋯)
            (rhs.cast ⋯) (curr + 1)
            (mkFullAdderCarry aig { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝, cin := cin }).ref).aig.decls.size

Tactic:
apply go_le_size

Result:
no goals

Proof state:
case isFalse
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
w curr : Nat
aig : AIG α
cin : aig.Ref
lhs rhs : aig.RefVec w
h✝ : ¬curr < w
⊢ aig.decls.size ≤ aig.decls.size

Tactic:
omega

Result:
no goals

Proof state:
case isFalse
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
w curr : Nat
aig : AIG α
cin : aig.Ref
lhs rhs : aig.RefVec w
h✝ : ¬curr < w
⊢ aig.decls.size ≤ { aig := aig, ref := cin }.aig.decls.size

Tactic:
dsimp only

Result:
case isFalse
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
w curr : Nat
aig : AIG α
cin : aig.Ref
lhs rhs : aig.RefVec w
h✝ : ¬curr < w
⊢ aig.decls.size ≤ aig.decls.size

Proof state:
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
w curr : Nat
aig : AIG α
cin : aig.Ref
lhs rhs : aig.RefVec w
⊢ aig.decls.size ≤
    (if hidx : curr < w then
            go (mkFullAdderCarry aig { lhs := lhs.get curr hidx, rhs := rhs.get curr hidx, cin := cin }).aig
              (lhs.cast ⋯) (rhs.cast ⋯) (curr + 1)
              (mkFullAdderCarry aig { lhs := lhs.get curr hidx, rhs := rhs.get curr hidx, cin := cin }).ref
          else { aig := aig, ref := cin }).aig.decls.size

Tactic:
split

Result:
case isTrue
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
w curr : Nat
aig : AIG α
cin : aig.Ref
lhs rhs : aig.RefVec w
h✝ : curr < w
⊢ aig.decls.size ≤
    (go (mkFullAdderCarry aig { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝, cin := cin }).aig (lhs.cast ⋯)
            (rhs.cast ⋯) (curr + 1)
            (mkFullAdderCarry aig { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝, cin := cin }).ref).aig.decls.size

case isFalse
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
w curr : Nat
aig : AIG α
cin : aig.Ref
lhs rhs : aig.RefVec w
h✝ : ¬curr < w
⊢ aig.decls.size ≤ { aig := aig, ref := cin }.aig.decls.size

Proof state:
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
w curr : Nat
aig : AIG α
cin : aig.Ref
lhs rhs : aig.RefVec w
⊢ aig.decls.size ≤ (go aig lhs rhs curr cin).aig.decls.size

Tactic:
unfold go

Result:
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
w curr : Nat
aig : AIG α
cin : aig.Ref
lhs rhs : aig.RefVec w
⊢ aig.decls.size ≤
    (if hidx : curr < w then
            let lin := lhs.get curr hidx;
            let rin := rhs.get curr hidx;
            let res := mkFullAdderCarry aig { lhs := lin, rhs := rin, cin := cin };
            let_fun this := ⋯;
            let aig_1 := res.aig;
            let carryRef := res.ref;
            let lhs := lhs.cast this;
            let rhs := rhs.cast this;
            go aig_1 lhs rhs (curr + 1) carryRef
          else { aig := aig, ref := cin }).aig.decls.size

Proof state:
case isTrue
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
w curr : Nat
aig : AIG α
cin : aig.Ref
lhs rhs : aig.RefVec w
h✝ : curr < w
⊢ aig.decls.size ≤ (mkFullAdderCarry aig { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝, cin := cin }).aig.decls.size

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

Result:
no goals

Proof state:
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
w curr : Nat
aig : AIG α
cin : aig.Ref
lhs rhs : aig.RefVec w
⊢ aig.decls.size ≤
    (if hidx : curr < w then
            let lin := lhs.get curr hidx;
            let rin := rhs.get curr hidx;
            let res := mkFullAdderCarry aig { lhs := lin, rhs := rin, cin := cin };
            let_fun this := ⋯;
            let aig_1 := res.aig;
            let carryRef := res.ref;
            let lhs := lhs.cast this;
            let rhs := rhs.cast this;
            go aig_1 lhs rhs (curr + 1) carryRef
          else { aig := aig, ref := cin }).aig.decls.size

Tactic:
dsimp only

Result:
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
w curr : Nat
aig : AIG α
cin : aig.Ref
lhs rhs : aig.RefVec w
⊢ aig.decls.size ≤
    (if hidx : curr < w then
            go (mkFullAdderCarry aig { lhs := lhs.get curr hidx, rhs := rhs.get curr hidx, cin := cin }).aig
              (lhs.cast ⋯) (rhs.cast ⋯) (curr + 1)
              (mkFullAdderCarry aig { lhs := lhs.get curr hidx, rhs := rhs.get curr hidx, cin := cin }).ref
          else { aig := aig, ref := cin }).aig.decls.size

Proof state:
case isTrue
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
w curr : Nat
aig : AIG α
cin : aig.Ref
lhs rhs : aig.RefVec w
h✝ : curr < w
⊢ aig.decls.size ≤
    (go (mkFullAdderCarry aig { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝, cin := cin }).aig (lhs.cast ⋯)
            (rhs.cast ⋯) (curr + 1)
            (mkFullAdderCarry aig { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝, cin := cin }).ref).aig.decls.size

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

Result:
case isTrue
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
w curr : Nat
aig : AIG α
cin : aig.Ref
lhs rhs : aig.RefVec w
h✝ : curr < w
⊢ aig.decls.size ≤ (mkFullAdderCarry aig { lhs := lhs.get curr h✝, rhs := rhs.get curr h✝, cin := cin }).aig.decls.size