• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
      • Apt
      • Zfc
      • Acre
      • Milawa
      • Smtlink
      • Abnf
      • Vwsim
      • Isar
      • Pfcs
      • Wp-gen
      • Dimacs-reader
      • Legacy-defrstobj
      • Proof-checker-array
      • Soft
      • C
      • Farray
      • Rp-rewriter
      • Instant-runoff-voting
      • Imp-language
      • Sidekick
      • Leftist-trees
      • Java
      • Taspi
      • Riscv
      • Bitcoin
      • Des
      • Ethereum
      • X86isa
      • Sha-2
      • Yul
      • Zcash
      • Proof-checker-itp13
      • Regex
      • 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
        • Json
        • Jfkr
        • Equational
        • Cryptography
        • Poseidon
        • Where-do-i-place-my-book
        • Axe
        • Aleo
        • Bigmems
        • Builtins
        • Execloader
        • Solidity
        • Paco
        • Concurrent-programs
        • Bls12-377-curves
      • Debugging
      • Std
      • Community
      • Proof-automation
      • ACL2
      • Macro-libraries
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • 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)