(aignet-balance-outs n config aignet mark copy refcounts levels aignet2 strash) → (mv new-mark new-copy new-levels new-aignet2 new-strash)
Function:
(defun aignet-balance-outs (n config aignet mark copy refcounts levels aignet2 strash) (declare (xargs :stobjs (aignet mark copy refcounts levels aignet2 strash))) (declare (xargs :guard (and (natp n) (balance-config-p config)))) (declare (xargs :guard (and (<= n (num-outs aignet)) (<= (num-fanins aignet) (lits-length copy)) (non-exec (ec-call (aignet-copies-in-bounds copy aignet2))) (<= (num-fanins aignet) (bits-length mark)) (<= (num-fanins aignet) (u32-length refcounts)) (<= (num-fanins aignet2) (u32-length levels))))) (let ((__function__ 'aignet-balance-outs)) (declare (ignorable __function__)) (b* (((when (mbe :logic (zp (- (num-outs aignet) (nfix n))) :exec (eql n (num-outs aignet)))) (mv mark copy levels aignet2 strash)) (- (and (>= (balance-config->verbosity-level config) 1) (b* (((local-stobjs u32arr) (mv blah u32arr)) (u32arr (resize-u32 (num-fanins aignet) u32arr)) ((mv supergate &) (lit-collect-supergate (outnum->fanin n aignet) t nil (balance-config->supergate-limit config) nil u32arr aignet))) (cw "Input supergate size: ~x0~%" (len supergate)) (cw "Gate numbers: ~x0~%" (count-gates-list supergate aignet)) (mv nil u32arr)))) ((mv ?lit mark copy levels aignet2 strash) (aignet-balance-rec (lit-id (outnum->fanin n aignet)) config aignet mark copy refcounts levels aignet2 strash)) (- (and (>= (balance-config->verbosity-level config) 1) (b* (((local-stobjs u32arr) (mv blah u32arr)) (u32arr (resize-u32 (num-fanins aignet2) u32arr)) ((mv supergate &) (lit-collect-supergate lit t nil (balance-config->supergate-limit config) nil u32arr aignet2))) (cw "Output supergate size: ~x0~%" (len supergate)) (cw "Gate numbers: ~x0~%" (count-gates-list supergate aignet2)) (mv nil u32arr))))) (aignet-balance-outs (1+ (lnfix n)) config aignet mark copy refcounts levels aignet2 strash))))
Theorem:
(defthm aignet-extension-p-of-aignet-balance-outs (b* (((mv ?new-mark ?new-copy ?new-levels ?new-aignet2 ?new-strash) (aignet-balance-outs n config aignet mark copy refcounts levels aignet2 strash))) (aignet-extension-p new-aignet2 aignet2)))
Theorem:
(defthm aignet-copies-in-bounds-of-aignet-balance-outs (b* (((mv ?new-mark ?new-copy ?new-levels ?new-aignet2 ?new-strash) (aignet-balance-outs n config aignet mark copy refcounts levels aignet2 strash))) (implies (aignet-copies-in-bounds copy aignet2) (aignet-copies-in-bounds new-copy new-aignet2))))
Theorem:
(defthm levels-length-of-aignet-balance-outs (b* (((mv ?new-mark ?new-copy ?new-levels ?new-aignet2 ?new-strash) (aignet-balance-outs n config aignet mark copy refcounts levels aignet2 strash))) (implies (and (<= (num-fanins aignet2) (len levels)) (aignet-copies-in-bounds copy aignet2)) (< (fanin-count new-aignet2) (len new-levels)))) :rule-classes :linear)
Theorem:
(defthm mark-length-of-aignet-balance-outs (b* (((mv ?new-mark ?new-copy ?new-levels ?new-aignet2 ?new-strash) (aignet-balance-outs n config aignet mark copy refcounts levels aignet2 strash))) (implies (<= (num-fanins aignet) (len mark)) (equal (len new-mark) (len mark)))))
Theorem:
(defthm copy-length-of-aignet-balance-outs (b* (((mv ?new-mark ?new-copy ?new-levels ?new-aignet2 ?new-strash) (aignet-balance-outs n config aignet mark copy refcounts levels aignet2 strash))) (implies (<= (num-fanins aignet) (len copy)) (equal (len new-copy) (len copy)))))
Theorem:
(defthm marks-remain-set-of-aignet-balance-outs (b* (((mv ?new-mark ?new-copy ?new-levels ?new-aignet2 ?new-strash) (aignet-balance-outs n config aignet mark copy refcounts levels aignet2 strash))) (implies (equal (nth m mark) 1) (equal (nth m new-mark) 1))))
Theorem:
(defthm output-fanin-marked-of-aignet-balance-outs (b* (((mv ?new-mark ?new-copy ?new-levels ?new-aignet2 ?new-strash) (aignet-balance-outs n config aignet mark copy refcounts levels aignet2 strash))) (implies (and (<= (nfix n) (nfix m)) (< (nfix m) (num-outs aignet))) (equal (nth (lit-id (fanin 0 (lookup-stype m :po aignet))) new-mark) 1))))
Theorem:
(defthm aignet-output-fanins-marked-of-aignet-balance-outs (b* (((mv ?new-mark ?new-copy ?new-levels ?new-aignet2 ?new-strash) (aignet-balance-outs n config aignet mark copy refcounts levels aignet2 strash))) (implies (zp n) (aignet-output-fanins-marked new-mark aignet))))
Theorem:
(defthm aignet-balance-outs-correct (b* (((mv ?new-mark ?new-copy ?new-levels ?new-aignet2 ?new-strash) (aignet-balance-outs n config aignet mark copy refcounts levels aignet2 strash))) (implies (and (marked-lit-copies-equiv mark copy aignet aignet2 invals regvals) (aignet-copies-in-bounds copy aignet2)) (marked-lit-copies-equiv new-mark new-copy aignet new-aignet2 invals regvals))))
Theorem:
(defthm aignet-balance-outs-correct-all-evals (b* (((mv ?new-mark ?new-copy ?new-levels ?new-aignet2 ?new-strash) (aignet-balance-outs n config aignet mark copy refcounts levels aignet2 strash))) (implies (and (marked-lit-copies-equiv-all-evals mark copy aignet aignet2) (aignet-copies-in-bounds copy aignet2)) (marked-lit-copies-equiv-all-evals new-mark new-copy aignet new-aignet2))))
Theorem:
(defthm stype-counts-of-aignet-balance-outs (b* (((mv ?new-mark ?new-copy ?new-levels ?new-aignet2 ?new-strash) (aignet-balance-outs n config aignet mark copy refcounts levels aignet2 strash))) (implies (and (not (equal (stype-fix stype) (and-stype))) (not (equal (stype-fix stype) (xor-stype)))) (equal (stype-count stype new-aignet2) (stype-count stype aignet2)))))
Theorem:
(defthm aignet-balance-outs-of-nfix-n (equal (aignet-balance-outs (nfix n) config aignet mark copy refcounts levels aignet2 strash) (aignet-balance-outs n config aignet mark copy refcounts levels aignet2 strash)))
Theorem:
(defthm aignet-balance-outs-nat-equiv-congruence-on-n (implies (nat-equiv n n-equiv) (equal (aignet-balance-outs n config aignet mark copy refcounts levels aignet2 strash) (aignet-balance-outs n-equiv config aignet mark copy refcounts levels aignet2 strash))) :rule-classes :congruence)
Theorem:
(defthm aignet-balance-outs-of-balance-config-fix-config (equal (aignet-balance-outs n (balance-config-fix config) aignet mark copy refcounts levels aignet2 strash) (aignet-balance-outs n config aignet mark copy refcounts levels aignet2 strash)))
Theorem:
(defthm aignet-balance-outs-balance-config-equiv-congruence-on-config (implies (balance-config-equiv config config-equiv) (equal (aignet-balance-outs n config aignet mark copy refcounts levels aignet2 strash) (aignet-balance-outs n config-equiv aignet mark copy refcounts levels aignet2 strash))) :rule-classes :congruence)