Function:
(defun var (n numvars) (declare (xargs :guard (and (natp n) (natp numvars)))) (declare (xargs :guard (< n numvars))) (let ((__function__ 'var)) (declare (ignorable __function__)) (b* ((n (lnfix n)) (numvars (lnfix numvars)) (w (ash 1 n)) (rep (ash (logmask w) w))) (var-repetitions (+ 1 n) rep numvars))))
Theorem:
(defthm natp-of-var (b* ((var-enc (var n numvars))) (natp var-enc)) :rule-classes :type-prescription)
Theorem:
(defthm logbitp-of-var (b* ((?var-enc (var n numvars))) (implies (< (nfix n) (nfix numvars)) (equal (logbitp env var-enc) (and (< (nfix env) (ash 1 numvars)) (logbitp n (nfix env)))))))
Theorem:
(defthm eval-of-var (b* ((?var-enc (var n numvars))) (implies (< (nfix n) (nfix numvars)) (equal (truth-eval var-enc env numvars) (env-lookup n env)))))
Theorem:
(defthm var-size-basic (b* ((?var-enc (var n numvars))) (implies (and (< (nfix n) numvars) (natp numvars)) (unsigned-byte-p (ash 1 numvars) var-enc))))
Theorem:
(defthm var-size (b* ((?var-enc (var n numvars))) (implies (and (natp m) (<= (ash 1 numvars) m) (< (nfix n) numvars) (natp numvars)) (unsigned-byte-p m var-enc))))
Theorem:
(defthm var-negated-masked-size (b* ((?var-enc (var n numvars))) (implies (and (< (nfix n) numvars) (natp numvars)) (unsigned-byte-p (- (ash 1 numvars) (ash 1 (nfix n))) (loghead (ash 1 numvars) (lognot var-enc))))))
Theorem:
(defthm var-negated (b* ((?var-enc (var n numvars))) (implies (and (< (nfix n) numvars) (natp numvars)) (equal (loghead (ash 1 numvars) (lognot var-enc)) (logtail (ash 1 (nfix n)) var-enc)))))
Theorem:
(defthm var-of-nfix-n (equal (var (nfix n) numvars) (var n numvars)))
Theorem:
(defthm var-nat-equiv-congruence-on-n (implies (nat-equiv n n-equiv) (equal (var n numvars) (var n-equiv numvars))) :rule-classes :congruence)
Theorem:
(defthm var-of-nfix-numvars (equal (var n (nfix numvars)) (var n numvars)))
Theorem:
(defthm var-nat-equiv-congruence-on-numvars (implies (nat-equiv numvars numvars-equiv) (equal (var n numvars) (var n numvars-equiv))) :rule-classes :congruence)