• 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
              • Exec
              • Exec-arrsub
              • Exec-expr-pure
              • Exec-expr-asg
              • Init-value-to-value
              • Exec-memberp
              • Apconvert-expr-value
              • Exec-address
              • Exec-member
              • Init-scope
              • Exec-unary
                • Exec-fun
                • Exec-block-item
                • Eval-iconst
                • Exec-binary-strict-pure
                • Exec-expr-pure-list
                • Eval-binary-strict-pure
                • Exec-block-item-list
                • Exec-indir
                • Exec-expr-call-or-pure
                • Exec-stmt-while
                • Exec-stmt
                • Exec-ident
                • Eval-cast
                • Exec-cast
                • Eval-unary
                • Exec-const
                • Exec-initer
                • Exec-expr-call-or-asg
                • Eval-const
                • Exec-expr-call
              • 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
              • 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
    • Dynamic-semantics

    Exec-unary

    Execute a unary operation on an expression value.

    Signature
    (exec-unary op arg compst) → eval
    Arguments
    op — Guard (unopp op).
    arg — Guard (expr-valuep arg).
    compst — Guard (compustatep compst).
    Returns
    eval — Type (expr-value-resultp eval).

    This ACL2 function wraps eval-unary to take and return expression values, and covers the remaining two unary operators & and *. Note that the only unary operator that needs an expression value (as opposed to just a value) is &, and that only unary operator that returns an expression value (as opposed to just a value) is *. The other four unary operators only operate on values, as factored in eval-unary.

    Before calling eval-unary, we perform array-to-pointer conversion [C17:5.3.2.1/3]. The functions handle & and * perform that conversion as needed (specifically, & does not, while * does).

    Definitions and Theorems

    Function: exec-unary

    (defun exec-unary (op arg compst)
      (declare (xargs :guard (and (unopp op)
                                  (expr-valuep arg)
                                  (compustatep compst))))
      (let ((__function__ 'exec-unary))
        (declare (ignorable __function__))
        (case (unop-kind op)
          (:address (exec-address arg))
          (:indir (exec-indir arg compst))
          (t (b* ((arg (apconvert-expr-value arg))
                  ((when (errorp arg)) arg)
                  (val (eval-unary op (expr-value->value arg)))
                  ((when (errorp val)) val))
               (make-expr-value :value val
                                :object nil))))))

    Theorem: expr-value-resultp-of-exec-unary

    (defthm expr-value-resultp-of-exec-unary
      (b* ((eval (exec-unary op arg compst)))
        (expr-value-resultp eval))
      :rule-classes :rewrite)

    Theorem: exec-unary-of-unop-fix-op

    (defthm exec-unary-of-unop-fix-op
      (equal (exec-unary (unop-fix op) arg compst)
             (exec-unary op arg compst)))

    Theorem: exec-unary-unop-equiv-congruence-on-op

    (defthm exec-unary-unop-equiv-congruence-on-op
      (implies (unop-equiv op op-equiv)
               (equal (exec-unary op arg compst)
                      (exec-unary op-equiv arg compst)))
      :rule-classes :congruence)

    Theorem: exec-unary-of-expr-value-fix-arg

    (defthm exec-unary-of-expr-value-fix-arg
      (equal (exec-unary op (expr-value-fix arg)
                         compst)
             (exec-unary op arg compst)))

    Theorem: exec-unary-expr-value-equiv-congruence-on-arg

    (defthm exec-unary-expr-value-equiv-congruence-on-arg
      (implies (expr-value-equiv arg arg-equiv)
               (equal (exec-unary op arg compst)
                      (exec-unary op arg-equiv compst)))
      :rule-classes :congruence)

    Theorem: exec-unary-of-compustate-fix-compst

    (defthm exec-unary-of-compustate-fix-compst
      (equal (exec-unary op arg (compustate-fix compst))
             (exec-unary op arg compst)))

    Theorem: exec-unary-compustate-equiv-congruence-on-compst

    (defthm exec-unary-compustate-equiv-congruence-on-compst
      (implies (compustate-equiv compst compst-equiv)
               (equal (exec-unary op arg compst)
                      (exec-unary op arg compst-equiv)))
      :rule-classes :congruence)