• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Community
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
      • Kestrel-books
        • Crypto-hdwallet
        • Apt
        • Error-checking
        • Fty-extensions
        • Isar
        • Kestrel-utilities
        • Set
        • Soft
        • C
          • Syntax-for-tools
            • Disambiguator
            • Abstract-syntax
            • Parser
            • Validator
            • Printer
            • Formalized-subset
            • Mapping-to-language-definition
            • Input-files
            • Defpred
            • Output-files
            • Abstract-syntax-operations
              • Abstract-syntax-irrelevants
              • Expr-priority
              • Expr-priority-<=
              • Combine-dirabsdeclor-into-dirabsdeclor
              • Check-decl-spec-list-all-typespec/stoclass
              • Binop-expected-priorities
              • Expr->priority
              • Transunit-at-path
              • Check-expr-binary
              • Apply-pre-inc/dec-ops
              • Apply-post-inc/dec-ops
              • Check-spec/qual-list-all-typespec
              • Check-decl-spec-list-all-typespec
              • Check-expr-mul
              • Type-spec-list-signed-long-long-int-p
              • Expr-unary/postfix/primary-p
              • Expr-to-asg-expr-list
              • Transunit-ensemble-paths
              • Type-spec-list-signed-short-int-p
              • Type-spec-list-signed-long-long-p
              • Type-spec-list-signed-long-int-p
              • Expr-postfix/primary-p
              • Dirabsdeclor-declor?-nil-p
              • Check-strunispec-no-members
              • Type-spec-list-signed-short-p
              • Type-spec-list-signed-long-p
              • Type-spec-list-signed-int128-p
              • Type-spec-list-signed-char-p
              • Expr-zerop
                • Type-spec-list-unsigned-long-long-int-p
                • Type-spec-list-signed-int-p
                • Spec/qual-list-to-type-spec-list
                • Expr-priority->=
                • Expr-priority->
                • Expr-priority-<
                • Decl-spec-list-to-type-spec-list
                • Decl-spec-list-to-stor-spec-list
                • Check-enumspec-no-list
                • Type-spec-list-unsigned-short-int-p
                • Type-spec-list-unsigned-long-long-p
                • Type-spec-list-long-double-complex-p
                • Stor-spec-list-static-threadloc-p
                • Stor-spec-list-extern-threadloc-p
                • Binop->priority
                • Type-spec-list-unsigned-short-p
                • Type-spec-list-unsigned-long-int-p
                • Type-spec-list-unsigned-int128-p
                • Type-spec-list-signed-p
                • Type-spec-list-long-long-int-p
                • Type-spec-list-double-complex-p
                • Type-spec-list-unsigned-long-p
                • Type-spec-list-unsigned-int-p
                • Type-spec-list-unsigned-char-p
                • Type-spec-list-long-double-p
                • Type-spec-list-float-complex-p
                • Type-spec-list-short-int-p
                • Type-spec-list-long-long-p
                • Type-spec-list-long-int-p
                • Stringlit-list->prefix?-list
                • Stor-spec-list-typedef-p
                • Stor-spec-list-threadloc-p
                • Stor-spec-list-static-p
                • Stor-spec-list-register-p
                • Stor-spec-list-extern-p
                • Type-spec-list-unsigned-p
                • Type-spec-list-short-p
                • Type-spec-list-long-p
                • Type-spec-list-int128-p
                • Type-spec-list-float-p
                • Type-spec-list-double-p
                • Type-spec-list-char-p
                • Stor-spec-list-auto-p
                • Check-expr-iconst
                • Type-spec-list-int-p
                • Check-expr-ident
                • Declor->ident
                • Type-spec-list-permp
                • Initdeclor->ident
              • Validation-information
              • Implementation-environments
              • Concrete-syntax
              • Ascii-identifiers
              • Unambiguity
              • Preprocessing
              • Abstraction-mapping
            • Atc
            • Language
            • Representation
            • Transformation-tools
            • Insertion-sort
            • Pack
          • Bv
          • Imp-language
          • Event-macros
          • Java
          • Bitcoin
          • Ethereum
          • Yul
          • Zcash
          • ACL2-programming-language
          • Prime-fields
          • Json
          • Syntheto
          • File-io-light
          • Cryptography
          • Number-theory
          • Lists-light
          • Axe
          • Builtins
          • Solidity
          • Helpers
          • Htclient
          • Typed-lists-light
          • Arithmetic-light
        • X86isa
        • Axe
        • Execloader
      • Math
      • Testing-utilities
    • Abstract-syntax-operations

    Expr-zerop

    Check if an expression is zero.

    Signature
    (expr-zerop expr) → yes/no
    Arguments
    expr — Guard (exprp expr).
    Returns
    yes/no — Type (booleanp yes/no).

    There are syntactically different expressions in C that evaluate to ``zero'' in a broad sense. For now we only include the octal integer constant 0 without suffixes and with just one digit. So this operation is very limited in scope, but sufficient for its current usage (elsewhere).

    Definitions and Theorems

    Function: expr-zerop

    (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: booleanp-of-expr-zerop

    (defthm booleanp-of-expr-zerop
      (b* ((yes/no (expr-zerop expr)))
        (booleanp yes/no))
      :rule-classes :rewrite)

    Theorem: expr-zerop-of-expr-fix-expr

    (defthm expr-zerop-of-expr-fix-expr
      (equal (expr-zerop (expr-fix expr))
             (expr-zerop expr)))

    Theorem: expr-zerop-expr-equiv-congruence-on-expr

    (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)