Core function for looking up an input, output, or register in the logical AIG network by its IO number.
(lookup-stype n stype aignet) → suffix
See representation to understand IO numbers and IO lookups.
Function:
(defun lookup-stype (n stype aignet) (declare (xargs :guard (and (natp n) (stypep stype) (node-listp aignet)))) (let ((__function__ 'lookup-stype)) (declare (ignorable __function__)) (cond ((endp aignet) (node-list-fix aignet)) ((and (equal (stype (car aignet)) (stype-fix stype)) (equal (stype-count stype (cdr aignet)) (lnfix n))) (node-list-fix aignet)) (t (lookup-stype n stype (cdr aignet))))))
Theorem:
(defthm node-listp-of-lookup-stype (b* ((suffix (lookup-stype n stype aignet))) (node-listp suffix)) :rule-classes :rewrite)
Theorem:
(defthm lookup-stype-of-nfix-n (equal (lookup-stype (nfix n) stype aignet) (lookup-stype n stype aignet)))
Theorem:
(defthm lookup-stype-nat-equiv-congruence-on-n (implies (nat-equiv n n-equiv) (equal (lookup-stype n stype aignet) (lookup-stype n-equiv stype aignet))) :rule-classes :congruence)
Theorem:
(defthm lookup-stype-of-stype-fix-stype (equal (lookup-stype n (stype-fix stype) aignet) (lookup-stype n stype aignet)))
Theorem:
(defthm lookup-stype-stype-equiv-congruence-on-stype (implies (stype-equiv stype stype-equiv) (equal (lookup-stype n stype aignet) (lookup-stype n stype-equiv aignet))) :rule-classes :congruence)
Theorem:
(defthm lookup-stype-of-node-list-fix-aignet (equal (lookup-stype n stype (node-list-fix aignet)) (lookup-stype n stype aignet)))
Theorem:
(defthm lookup-stype-node-list-equiv-congruence-on-aignet (implies (node-list-equiv aignet aignet-equiv) (equal (lookup-stype n stype aignet) (lookup-stype n stype aignet-equiv))) :rule-classes :congruence)
Theorem:
(defthm stype-count-of-cdr-lookup-stype (implies (< (nfix n) (stype-count stype aignet)) (equal (stype-count stype (cdr (lookup-stype n stype aignet))) (nfix n))))
Theorem:
(defthm car-of-lookup-stype (implies (< (nfix n) (stype-count stype aignet)) (equal (stype (car (lookup-stype n stype aignet))) (stype-fix stype))))
Theorem:
(defthm lookup-stype-in-bounds (iff (consp (lookup-stype n stype aignet)) (< (nfix n) (stype-count stype aignet))))
Theorem:
(defthm lookup-stype-aignet-extension-p (aignet-extension-p aignet (lookup-stype n stype aignet)))
Theorem:
(defthm lookup-stype-of-stype-count (implies (and (aignet-extension-p new orig) (equal (stype (car orig)) (stype-fix stype)) (not (equal (stype-fix stype) (const-stype)))) (equal (lookup-stype (stype-count stype (cdr orig)) stype new) (node-list-fix orig))))
Theorem:
(defthm lookup-stype-in-extension (implies (and (aignet-extension-binding) (consp (lookup-stype n stype orig))) (equal (lookup-stype n stype new) (lookup-stype n stype orig))))
Theorem:
(defthm lookup-stype-in-extension-inverse (implies (and (aignet-extension-bind-inverse) (consp (lookup-stype n stype orig))) (equal (lookup-stype n stype orig) (lookup-stype n stype new))))
Theorem:
(defthm stype-of-lookup-stype (implies (consp (lookup-stype n stype aignet)) (equal (stype (car (lookup-stype n stype aignet))) (stype-fix stype))))
Theorem:
(defthm stype-of-lookup-stype-split (equal (stype (car (lookup-stype n stype aignet))) (if (consp (lookup-stype n stype aignet)) (stype-fix stype) :const)))
Theorem:
(defthm aignet-extension-simplify-lookup-stype-when-counts-same (implies (and (aignet-extension-binding) (equal (stype-count stype new) (stype-count stype orig))) (equal (lookup-stype n stype new) (lookup-stype n stype orig))))
Theorem:
(defthm aignet-extension-simplify-lookup-stype-inverse (implies (and (aignet-extension-bind-inverse) (consp (lookup-stype n stype orig))) (equal (lookup-stype n stype orig) (lookup-stype n stype new))))
Theorem:
(defthm lookup-stype-out-of-bounds (implies (<= (stype-count stype aignet) (nfix n)) (equal (lookup-stype n stype aignet) nil)))
Theorem:
(defthm consp-of-lookup-stype (implies (natp n) (equal (consp (lookup-stype n stype aignet)) (< (nfix n) (stype-count stype aignet)))))
Theorem:
(defthm stype-count-of-lookup-stype-split (equal (stype-count stype (lookup-stype n stype aignet)) (if (< (nfix n) (stype-count stype aignet)) (+ 1 (nfix n)) 0)))
Theorem:
(defthm stype-count-of-lookup-stype (implies (< (nfix n) (stype-count stype aignet)) (equal (stype-count stype (lookup-stype n stype aignet)) (+ 1 (nfix n)))))