Apply DAG-aware rewriting to the network.
(rewrite! aignet config) → new-aignet
Note: This implementation is heavily based on the one in ABC, developed and maintained at Berkeley by Alan Mishchenko.
Settings for the transform can be tweaked using the
Function:
(defun rewrite! (aignet config) (declare (xargs :stobjs (aignet))) (declare (xargs :guard (rewrite-config-p config))) (let ((__function__ 'rewrite!)) (declare (ignorable __function__)) (b* (((local-stobjs aignet-tmp) (mv aignet aignet-tmp)) (aignet-tmp (rewrite-core aignet aignet-tmp config)) (aignet (aignet-prune-comb aignet-tmp aignet (rewrite-config->gatesimp config)))) (mv aignet aignet-tmp))))
Theorem:
(defthm stype-counts-of-rewrite! (b* ((?new-aignet (rewrite! aignet config))) (and (equal (stype-count :pi new-aignet) (stype-count :pi aignet)) (equal (stype-count :reg new-aignet) (stype-count :reg aignet)) (equal (stype-count :po new-aignet) (stype-count :po aignet)))))
Theorem:
(defthm rewrite!-correct (b* ((?new-aignet (rewrite! aignet config))) (comb-equiv new-aignet aignet)))
Theorem:
(defthm rewrite!-of-node-list-fix-aignet (equal (rewrite! (node-list-fix aignet) config) (rewrite! aignet config)))
Theorem:
(defthm rewrite!-node-list-equiv-congruence-on-aignet (implies (node-list-equiv aignet aignet-equiv) (equal (rewrite! aignet config) (rewrite! aignet-equiv config))) :rule-classes :congruence)
Theorem:
(defthm rewrite!-of-rewrite-config-fix-config (equal (rewrite! aignet (rewrite-config-fix config)) (rewrite! aignet config)))
Theorem:
(defthm rewrite!-rewrite-config-equiv-congruence-on-config (implies (rewrite-config-equiv config config-equiv) (equal (rewrite! aignet config) (rewrite! aignet config-equiv))) :rule-classes :congruence)