• 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
        • Bv
        • Imp-language
        • Event-macros
        • Java
        • Bitcoin
        • Ethereum
        • Yul
        • Zcash
        • ACL2-programming-language
          • Primitive-functions
            • Eval-intern-in-package-of-symbol
            • Eval-pkg-witness
            • Eval-pkg-imports
            • Primitive-function-namep
            • Primitive-function-arity
            • Eval-if
              • Eval-bad-atom<=
              • Eval-<
              • Eval-coerce
              • Eval-complex
              • Eval-binary-+
              • Eval-binary-*
              • Eval-equal
              • Eval-cons
              • Eval-symbol-package-name
              • Eval-complex-rationalp
              • Eval-unary-/
              • Eval-symbol-name
              • Eval-denominator
              • Eval-code-char
              • Eval-unary--
              • Eval-realpart
              • Eval-rationalp
              • Eval-numerator
              • Eval-integerp
              • Eval-imagpart
              • Eval-characterp
              • Eval-char-code
              • Eval-ACL2-numberp
              • Eval-symbolp
              • Eval-stringp
              • Eval-consp
              • Eval-cdr
              • Eval-car
            • Translated-terms
            • Values
            • Evaluation
            • Program-equivalence
            • Functions
            • Packages
            • Programs
            • Interpreter
            • Evaluation-states
          • 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
    • Primitive-functions

    Eval-if

    Evaluation semantics of if.

    Signature
    (eval-if x y z) → result
    Arguments
    x — Guard (valuep x).
    y — Guard (valuep y).
    z — Guard (valuep z).
    Returns
    result — Type (valuep result).

    The function if is non-strict in the evaluation semantics. So we may not need this eval-if function. Nonetheless, we have it return the prescribed value, given the argument values.

    Definitions and Theorems

    Function: eval-if

    (defun eval-if (x y z)
      (declare (xargs :guard (and (valuep x) (valuep y) (valuep z))))
      (let ((__function__ 'eval-if))
        (declare (ignorable __function__))
        (if (value-equiv x (value-nil))
            (value-fix z)
          (value-fix y))))

    Theorem: valuep-of-eval-if

    (defthm valuep-of-eval-if
      (b* ((result (eval-if x y z)))
        (valuep result))
      :rule-classes :rewrite)

    Theorem: eval-if-of-value-fix-x

    (defthm eval-if-of-value-fix-x
      (equal (eval-if (value-fix x) y z)
             (eval-if x y z)))

    Theorem: eval-if-value-equiv-congruence-on-x

    (defthm eval-if-value-equiv-congruence-on-x
      (implies (value-equiv x x-equiv)
               (equal (eval-if x y z)
                      (eval-if x-equiv y z)))
      :rule-classes :congruence)

    Theorem: eval-if-of-value-fix-y

    (defthm eval-if-of-value-fix-y
      (equal (eval-if x (value-fix y) z)
             (eval-if x y z)))

    Theorem: eval-if-value-equiv-congruence-on-y

    (defthm eval-if-value-equiv-congruence-on-y
      (implies (value-equiv y y-equiv)
               (equal (eval-if x y z)
                      (eval-if x y-equiv z)))
      :rule-classes :congruence)

    Theorem: eval-if-of-value-fix-z

    (defthm eval-if-of-value-fix-z
      (equal (eval-if x y (value-fix z))
             (eval-if x y z)))

    Theorem: eval-if-value-equiv-congruence-on-z

    (defthm eval-if-value-equiv-congruence-on-z
      (implies (value-equiv z z-equiv)
               (equal (eval-if x y z)
                      (eval-if x y z-equiv)))
      :rule-classes :congruence)