• 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
      • Farray
      • Rp-rewriter
      • Instant-runoff-voting
      • Imp-language
      • Sidekick
      • Leftist-trees
      • Java
      • Riscv
      • Taspi
      • Bitcoin
      • 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
      • Aleo
        • Aleobft
        • Aleovm
        • Leo
          • Grammar
          • Early-version
            • Json2ast
            • Testing
            • Definition
              • Flattening
              • Abstract-syntax
              • Dynamic-semantics
                • Execution
                  • Exec-expressions/statements
                  • Init-for-loop
                  • Exec-file-main
                  • Update-variable-value-in-scope-list
                  • Step-for-loop
                  • Update-variable-value-in-scope
                  • Expr-value-to-value
                  • Exec-binary
                    • Exec-expression
                    • Init-vcscope-dinfo-call
                    • Value?+denv
                    • Exec-statement
                    • End-of-for-loop-p
                    • Expr-value
                    • Evalue+denv
                    • Write-location
                    • Read-location
                    • Exec-for-loop-iterations
                    • Update-variable-value
                    • Exec-unary
                    • Values+denv
                    • Init-vcscope-dinfo-loop
                    • Extend-denv-with-structdecl
                    • Exec-var/const
                    • Valuemap+denv
                    • Namevalue+denv
                    • Extend-denv-with-fundecl
                    • Ensure-boolean
                    • Int+denv
                    • Push-vcscope-dinfo
                    • Extend-denv-with-topdecl-list
                    • Exec-literal
                    • Build-denv-from-file
                    • Namevalue+denv-result
                    • Extend-denv-with-topdecl
                    • Evalue+denv-result
                    • Value?+denv-result
                    • Values+denv-result
                    • Valuemap+denv-result
                    • Int+denv-result
                    • Push-call-dinfo
                    • Exec-print
                    • Pop-vcscope-dinfo
                    • Exec-if
                    • Exec-function
                    • Pop-call-dinfo
                    • Exec-statement-list
                    • Exec-block
                    • Exec-struct-init-list
                    • Exec-struct-init
                    • Exec-expression-list
                  • Values
                  • Dynamic-environments
                  • Arithmetic-operations
                  • Curve-parameterization
                  • Shift-operations
                  • Errors
                  • Value-expressions
                  • Locations
                  • Input-execution
                  • Edwards-bls12-generator
                  • Equality-operations
                  • Logical-operations
                  • Program-execution
                  • Ordering-operations
                  • Bitwise-operations
                  • Literal-evaluation
                  • Type-maps-for-struct-components
                  • Output-execution
                  • Tuple-operations
                  • Struct-operations
                • Compilation
                • Static-semantics
                • Concrete-syntax
        • Bigmems
        • Builtins
        • Execloader
        • Solidity
        • Paco
        • Concurrent-programs
        • Bls12-377-curves
      • Debugging
      • Community
      • Std
      • Proof-automation
      • Macro-libraries
      • ACL2
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Execution

    Exec-binary

    Execute a binary operator, on two expression values.

    Signature
    (exec-binary op arg1 arg2 env) → evalue+denv
    Arguments
    op — Guard (binopp op).
    arg1 — Guard (expr-valuep arg1).
    arg2 — Guard (expr-valuep arg2).
    env — Guard (denvp env).
    Returns
    evalue+denv — Type (evalue+denv-resultp evalue+denv).

    We coerce the expression values to values if needed. We apply the operator. The result is a value. The environment is unchanged.

    Definitions and Theorems

    Function: exec-binary

    (defun exec-binary (op arg1 arg2 env)
     (declare (xargs :guard (and (binopp op)
                                 (expr-valuep arg1)
                                 (expr-valuep arg2)
                                 (denvp env))))
     (let ((__function__ 'exec-binary))
       (declare (ignorable __function__))
       (b* (((okf arg1)
             (expr-value-to-value arg1 env))
            ((okf arg2)
             (expr-value-to-value arg2 env))
            (curve (denv->curve env))
            ((okf val)
             (binop-case op
                         :and (op-and arg1 arg2)
                         :or (op-or arg1 arg2)
                         :nand (op-nand arg1 arg2)
                         :nor (op-nor arg1 arg2)
                         :eq (op-eq arg1 arg2)
                         :ne (op-ne arg1 arg2)
                         :ge (op-ge arg1 arg2)
                         :gt (op-gt arg1 arg2)
                         :le (op-le arg1 arg2)
                         :lt (op-lt arg1 arg2)
                         :bitxor (op-bitxor arg1 arg2)
                         :bitior (op-bitior arg1 arg2)
                         :bitand (op-bitand arg1 arg2)
                         :shl (op-shl arg1 arg2)
                         :shr (op-shr arg1 arg2)
                         :shl-wrapped (op-shl-wrapped arg1 arg2)
                         :shr-wrapped (op-shr-wrapped arg1 arg2)
                         :add (op-add arg1 arg2 curve)
                         :sub (op-sub arg1 arg2 curve)
                         :mul (op-mul arg1 arg2 curve)
                         :div (op-div arg1 arg2 curve)
                         :rem (op-rem arg1 arg2 curve)
                         :pow (op-pow arg1 arg2 curve)
                         :add-wrapped (op-add-wrapped arg1 arg2 curve)
                         :sub-wrapped (op-sub-wrapped arg1 arg2 curve)
                         :mul-wrapped (op-mul-wrapped arg1 arg2 curve)
                         :div-wrapped (op-div-wrapped arg1 arg2 curve)
                         :rem-wrapped (op-rem-wrapped arg1 arg2 curve)
                         :pow-wrapped (op-pow-wrapped arg1 arg2 curve)))
            (eval (expr-value-value val)))
         (make-evalue+denv :evalue eval
                           :denv (denv-fix env)))))

    Theorem: evalue+denv-resultp-of-exec-binary

    (defthm evalue+denv-resultp-of-exec-binary
      (b* ((evalue+denv (exec-binary op arg1 arg2 env)))
        (evalue+denv-resultp evalue+denv))
      :rule-classes :rewrite)

    Theorem: exec-binary-of-binop-fix-op

    (defthm exec-binary-of-binop-fix-op
      (equal (exec-binary (binop-fix op)
                          arg1 arg2 env)
             (exec-binary op arg1 arg2 env)))

    Theorem: exec-binary-binop-equiv-congruence-on-op

    (defthm exec-binary-binop-equiv-congruence-on-op
      (implies (binop-equiv op op-equiv)
               (equal (exec-binary op arg1 arg2 env)
                      (exec-binary op-equiv arg1 arg2 env)))
      :rule-classes :congruence)

    Theorem: exec-binary-of-expr-value-fix-arg1

    (defthm exec-binary-of-expr-value-fix-arg1
      (equal (exec-binary op (expr-value-fix arg1)
                          arg2 env)
             (exec-binary op arg1 arg2 env)))

    Theorem: exec-binary-expr-value-equiv-congruence-on-arg1

    (defthm exec-binary-expr-value-equiv-congruence-on-arg1
      (implies (expr-value-equiv arg1 arg1-equiv)
               (equal (exec-binary op arg1 arg2 env)
                      (exec-binary op arg1-equiv arg2 env)))
      :rule-classes :congruence)

    Theorem: exec-binary-of-expr-value-fix-arg2

    (defthm exec-binary-of-expr-value-fix-arg2
      (equal (exec-binary op arg1 (expr-value-fix arg2)
                          env)
             (exec-binary op arg1 arg2 env)))

    Theorem: exec-binary-expr-value-equiv-congruence-on-arg2

    (defthm exec-binary-expr-value-equiv-congruence-on-arg2
      (implies (expr-value-equiv arg2 arg2-equiv)
               (equal (exec-binary op arg1 arg2 env)
                      (exec-binary op arg1 arg2-equiv env)))
      :rule-classes :congruence)

    Theorem: exec-binary-of-denv-fix-env

    (defthm exec-binary-of-denv-fix-env
      (equal (exec-binary op arg1 arg2 (denv-fix env))
             (exec-binary op arg1 arg2 env)))

    Theorem: exec-binary-denv-equiv-congruence-on-env

    (defthm exec-binary-denv-equiv-congruence-on-env
      (implies (denv-equiv env env-equiv)
               (equal (exec-binary op arg1 arg2 env)
                      (exec-binary op arg1 arg2 env-equiv)))
      :rule-classes :congruence)