Check if an expression is zero.
There are syntactically different expressions in C
that evaluate to ``zero'' in a broad sense.
For now we only include
the octal integer constant
Function:
(defun expr-zerop (expr) (declare (xargs :guard (exprp expr))) (let ((__function__ 'expr-zerop)) (declare (ignorable __function__)) (b* (((unless (expr-case expr :const)) nil) (const (expr-const->const expr)) ((unless (const-case const :int)) nil) ((iconst iconst) (const-int->unwrap const)) ((when iconst.suffix?) nil) ((unless (dec/oct/hex-const-case iconst.core :oct)) nil) ((dec/oct/hex-const-oct doh) iconst.core) ((unless (= doh.leading-zeros 1)) nil) ((unless (= doh.value 0)) nil)) t)))
Theorem:
(defthm booleanp-of-expr-zerop (b* ((yes/no (expr-zerop expr))) (booleanp yes/no)) :rule-classes :rewrite)
Theorem:
(defthm expr-zerop-of-expr-fix-expr (equal (expr-zerop (expr-fix expr)) (expr-zerop expr)))
Theorem:
(defthm expr-zerop-expr-equiv-congruence-on-expr (implies (expr-equiv expr expr-equiv) (equal (expr-zerop expr) (expr-zerop expr-equiv))) :rule-classes :congruence)