• 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
      • Json
      • Jfkr
      • Equational
      • Cryptography
      • Poseidon
        • Poseidon-main-definition
          • Param
          • Hashp
          • Absorb1
          • Sponge
          • Hash
          • All-rounds
          • Sponge-validp
          • Squeeze1
          • Sub-words-partial
          • Squeeze
          • Round
          • Partial-rounds
          • Mode
          • Full-rounds
          • Permute
          • Sub-words
          • Add-round-constants
          • Mix-layer
          • Dot-product
            • Absorb
            • Pow-by-alpha
            • Param->size
            • Sub-words-full
            • Param->capacity-then-rate-p
            • Param->partial-last-p
            • Param-additional-theorems
            • Param->rounds
            • Param->descending-p
            • Init-sponge
          • Poseidon-instantiations
        • 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
    • Poseidon-main-definition

    Dot-product

    Dot product of a matrix row and the state vector.

    Signature
    (dot-product row stat prime) → elem
    Arguments
    row — Guard (fe-listp row prime).
    stat — Guard (fe-listp stat prime).
    prime — Guard (primep prime).
    Returns
    elem — Type (fep elem prime), given (posp prime).

    This views the state as a column vector. However, as explained in param, we could equivalently view the matrix row as a matrix column and the state as a row vector.

    This could be a more general ACL2 function to perform the dot product of two vectors of field elements.

    Definitions and Theorems

    Function: dot-product

    (defun dot-product (row stat prime)
      (declare (xargs :guard (and (primep prime)
                                  (fe-listp row prime)
                                  (fe-listp stat prime))))
      (declare (xargs :guard (equal (len stat) (len row))))
      (let ((__function__ 'dot-product))
        (declare (ignorable __function__))
        (cond ((endp row) 0)
              (t (add (mul (car row) (car stat) prime)
                      (dot-product (cdr row) (cdr stat) prime)
                      prime)))))

    Theorem: fep-of-dot-product

    (defthm fep-of-dot-product
      (implies (posp prime)
               (b* ((elem (dot-product row stat prime)))
                 (fep elem prime)))
      :rule-classes :rewrite)