-- Mathlib/.lake/packages/lean4/src/lean/Std/Sat/AIG/If.lean
theorem go_le_size (aig : AIG α) (curr : Nat) (hcurr : curr ≤ w) (discr : Ref aig)
    (lhs rhs : RefVec aig w) (s : RefVec aig curr) :
    aig.decls.size ≤ (go aig curr hcurr discr lhs rhs s).aig.decls.size

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

Tactic:
apply LawfulOperator.le_size (f := mkIfCached)

Result:
no goals

Proof state:
case isTrue
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
w : Nat
aig : AIG α
curr : Nat
hcurr : curr ≤ w
discr : aig.Ref
lhs rhs : aig.RefVec w
s : aig.RefVec curr
h✝ : curr < w
⊢ aig.decls.size ≤
    (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)).aig.decls.size

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

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

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

Tactic:
simp

Result:
no goals

Proof state:
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
w : Nat
aig : AIG α
curr : Nat
hcurr : curr ≤ w
discr : aig.Ref
lhs rhs : aig.RefVec w
s : aig.RefVec curr
⊢ aig.decls.size ≤
    (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 }).aig.decls.size

Tactic:
dsimp only

Result:
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
w : Nat
aig : AIG α
curr : Nat
hcurr : curr ≤ w
discr : aig.Ref
lhs rhs : aig.RefVec w
s : aig.RefVec curr
⊢ aig.decls.size ≤
    (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 }).aig.decls.size

Proof state:
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
w : Nat
aig : AIG α
curr : Nat
hcurr : curr ≤ w
discr : aig.Ref
lhs rhs : aig.RefVec w
s : aig.RefVec curr
⊢ aig.decls.size ≤
    (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 }).aig.decls.size

Tactic:
split

Result:
case isTrue
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
w : Nat
aig : AIG α
curr : Nat
hcurr : curr ≤ w
discr : aig.Ref
lhs rhs : aig.RefVec w
s : aig.RefVec curr
h✝ : curr < w
⊢ aig.decls.size ≤
    (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)).aig.decls.size

case isFalse
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
w : Nat
aig : AIG α
curr : Nat
hcurr : curr ≤ w
discr : aig.Ref
lhs rhs : aig.RefVec w
s : aig.RefVec curr
h✝ : ¬curr < w
⊢ aig.decls.size ≤ { aig := aig, vec := ⋯ ▸ s }.aig.decls.size

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

Tactic:
unfold go

Result:
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
w : Nat
aig : AIG α
curr : Nat
hcurr : curr ≤ w
discr : aig.Ref
lhs rhs : aig.RefVec w
s : aig.RefVec curr
⊢ aig.decls.size ≤
    (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 }).aig.decls.size

Proof state:
α : Type
inst✝¹ : Hashable α
inst✝ : DecidableEq α
w : Nat
aig : AIG α
curr : Nat
hcurr : curr ≤ w
discr : aig.Ref
lhs rhs : aig.RefVec w
s : aig.RefVec curr
h✝ : curr < w
⊢ ?m.22562 ≤
    (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)).aig.decls.size

Tactic:
apply go_le_size

Result:
no goals