• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
      • Apt
      • Zfc
      • Acre
      • Milawa
      • Smtlink
      • Abnf
      • Vwsim
      • Isar
      • Wp-gen
      • Dimacs-reader
      • Pfcs
      • Legacy-defrstobj
      • Proof-checker-array
      • 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
          • Bytes
          • Keywords
          • Real-operations
          • Array-operations
          • Scalar-operations
            • Test-scalar-value
              • Lognot-scalar-value
            • Structure-operations
          • Representation
          • Transformation-tools
          • Insertion-sort
          • Pack
        • Farray
        • Rp-rewriter
        • Instant-runoff-voting
        • Imp-language
        • Sidekick
        • Leftist-trees
        • Java
        • Taspi
        • Bitcoin
        • Riscv
        • Des
        • Ethereum
        • X86isa
        • Sha-2
        • Yul
        • Zcash
        • Proof-checker-itp13
        • Regex
        • ACL2-programming-language
        • Json
        • Jfkr
        • Equational
        • Cryptography
        • Poseidon
        • Where-do-i-place-my-book
        • Axe
        • Bigmems
        • Builtins
        • Execloader
        • Aleo
        • Solidity
        • Paco
        • Concurrent-programs
        • Bls12-377-curves
      • Debugging
      • Std
      • Proof-automation
      • Macro-libraries
      • ACL2
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Scalar-operations

    Test-scalar-value

    Test a scalar value logically.

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

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

    Definitions and Theorems

    Function: test-scalar-value

    (defun test-scalar-value (val)
      (declare (xargs :guard (valuep val)))
      (declare (xargs :guard (value-scalarp val)))
      (let ((__function__ 'test-scalar-value))
        (declare (ignorable __function__))
        (cond ((value-integerp val)
               (test-integer-value val))
              ((value-case val :pointer)
               (test-pointer-value val))
              (t (ec-call (acl2::bool-fix (impossible)))))))

    Theorem: booleanp-of-test-scalar-value

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

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

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

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

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