• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • 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
          • Atc
          • Language
            • Abstract-syntax
            • Integer-ranges
            • Implementation-environments
            • Dynamic-semantics
            • Static-semantics
            • Grammar
            • Integer-formats
            • Types
            • Portable-ascii-identifiers
            • Values
            • Integer-operations
            • Computation-states
            • Object-designators
            • Operations
            • Errors
            • Tag-environments
            • Function-environments
            • Character-sets
            • Flexible-array-member-removal
            • Arithmetic-operations
            • Pointer-operations
              • Value-pointer-validp
              • Value-pointer->designator
              • Lognot-pointer-value
              • Test-pointer-value
                • Value-pointer-danglingp
                • Value-pointer-dangling
                • Value-pointer-nullp
                • Value-pointer-null
              • Bytes
              • Keywords
              • Real-operations
              • Array-operations
              • Scalar-operations
              • Structure-operations
            • 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
    • Pointer-operations

    Test-pointer-value

    Test a pointer value logically.

    Signature
    (test-pointer-value val) → res
    Arguments
    val — Guard (valuep val).
    Returns
    res — Type (booleanp res).

    In some contexts (e.g. conditional tests), a pointer is treated as a logical boolean: false if null, true if not null. This is captured by this ACL2 function.

    Definitions and Theorems

    Function: test-pointer-value

    (defun test-pointer-value (val)
      (declare (xargs :guard (valuep val)))
      (declare (xargs :guard (value-case val :pointer)))
      (let ((__function__ 'test-pointer-value))
        (declare (ignorable __function__))
        (not (value-pointer-nullp val))))

    Theorem: booleanp-of-test-pointer-value

    (defthm booleanp-of-test-pointer-value
      (b* ((res (test-pointer-value val)))
        (booleanp res))
      :rule-classes :rewrite)

    Theorem: test-pointer-value-of-value-fix-val

    (defthm test-pointer-value-of-value-fix-val
      (equal (test-pointer-value (value-fix val))
             (test-pointer-value val)))

    Theorem: test-pointer-value-value-equiv-congruence-on-val

    (defthm test-pointer-value-value-equiv-congruence-on-val
      (implies (value-equiv val val-equiv)
               (equal (test-pointer-value val)
                      (test-pointer-value val-equiv)))
      :rule-classes :congruence)