• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
      • Apt
      • Zfc
      • Acre
      • Milawa
      • Smtlink
      • Abnf
      • Vwsim
      • Isar
      • Wp-gen
      • Dimacs-reader
      • Pfcs
        • Proof-support
        • Abstract-syntax
        • R1cs-subset
        • Semantics
          • Semantics-deeply-embedded
          • Lifting
          • Semantics-shallowly-embedded
            • Name-list-to-symbol-list
            • Name-to-symbol
            • Sesem-definition
            • Sesem-expression
              • Sesem-constraint
              • Sesem-gen-fep-terms
              • Sesem-expression-list
              • Sesem-definition-list
              • Sesem-constraint-list
              • Name-set-to-symbol-list
          • Abstract-syntax-operations
          • Indexed-names
          • Well-formedness
          • Concrete-syntax
          • R1cs-bridge
          • Parser-interface
        • Legacy-defrstobj
        • Proof-checker-array
        • Soft
        • C
        • Farray
        • Rp-rewriter
        • Instant-runoff-voting
        • Imp-language
        • Sidekick
        • Leftist-trees
        • Java
        • Taspi
        • Bitcoin
        • Riscv
        • 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
        • Bigmems
        • Builtins
        • Execloader
        • Aleo
        • Solidity
        • Paco
        • Concurrent-programs
        • Bls12-377-curves
      • Debugging
      • Std
      • Proof-automation
      • Macro-libraries
      • ACL2
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Semantics-shallowly-embedded

    Sesem-expression

    Shallowly embedded semantics of expressions.

    Signature
    (sesem-expression expr prime state) → term
    Arguments
    expr — Guard (expressionp expr).
    prime — Guard (symbolp prime).

    Besides the expression, this function also takes as argument a variable (symbol) to use as the prime. This is needed because we generate terms involving prime field operations, which all take a prime as argument; the prime is also used to reduce integer constants.

    A constant is mapped to itself, reduced modulo the prime.

    A variable is mapped to a symbol, according to name-to-symbol.

    Additions and multiplications are mapped to calls of the corresponding prime field operations applied to the terms obtained by translating the argument expressions.

    Definitions and Theorems

    Function: sesem-expression

    (defun sesem-expression (expr prime state)
     (declare (xargs :stobjs (state)))
     (declare (xargs :guard (and (expressionp expr)
                                 (symbolp prime))))
     (let ((__function__ 'sesem-expression))
      (declare (ignorable __function__))
      (expression-case
         expr
         :const (cons 'mod
                      (cons expr.value (cons prime 'nil)))
         :var (name-to-symbol expr.name state)
         :add (cons 'add
                    (cons (sesem-expression expr.arg1 prime state)
                          (cons (sesem-expression expr.arg2 prime state)
                                (cons prime 'nil))))
         :mul (cons 'mul
                    (cons (sesem-expression expr.arg1 prime state)
                          (cons (sesem-expression expr.arg2 prime state)
                                (cons prime 'nil)))))))