• 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

    Eval-const

    Evaluate a constant.

    Signature
    (eval-const c) → val
    Arguments
    c — Guard (constp c).
    Returns
    val — Type (value-resultp val).

    We only support the evaluation of integer constants for now.

    Definitions and Theorems

    Function: eval-const

    (defun eval-const (c)
      (declare (xargs :guard (constp c)))
      (let ((__function__ 'eval-const))
        (declare (ignorable __function__))
        (const-case c
                    :int (eval-iconst c.get)
                    :float (error :exec-const-float)
                    :enum (error :exec-const-enum)
                    :char (error :exec-const-char))))

    Theorem: value-resultp-of-eval-const

    (defthm value-resultp-of-eval-const
      (b* ((val (eval-const c)))
        (value-resultp val))
      :rule-classes :rewrite)

    Theorem: eval-const-of-const-fix-c

    (defthm eval-const-of-const-fix-c
      (equal (eval-const (const-fix c))
             (eval-const c)))

    Theorem: eval-const-const-equiv-congruence-on-c

    (defthm eval-const-const-equiv-congruence-on-c
      (implies (const-equiv c c-equiv)
               (equal (eval-const c)
                      (eval-const c-equiv)))
      :rule-classes :congruence)