• 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
      • Taspi
      • Bitcoin
      • Riscv
      • Des
      • Ethereum
      • X86isa
      • Sha-2
      • Yul
      • Zcash
      • Proof-checker-itp13
      • Regex
      • ACL2-programming-language
      • Json
      • Jfkr
      • Equational
      • Cryptography
        • R1cs
          • R1cs-verification-with-axe
          • R1cs-constraintp
          • Dot-product
          • R1csp
          • R1cs-constraint-holdsp
          • Sparse-vectorp
            • R1cs-holdsp
            • R1cs-constraints-holdp
            • R1cs-constraint-listp
            • Pseudo-varp
            • Pseudo-var-listp
          • Interfaces
          • Sha-2
          • Keccak
          • Kdf
          • Mimc
          • Padding
          • Hmac
          • Elliptic-curves
          • Attachments
          • Elliptic-curve-digital-signature-algorithm
        • 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
    • R1cs

    Sparse-vectorp

    Recognize a sparse vector in an R1CS constraint.

    ;; A sparse vector, represented as a list of pairs where each pair contains a
    ;; coefficient and a pseudo-var.  Pseudo-vars not mentioned have an implicit
    ;; coefficient of 0.
    (defund sparse-vectorp (vec)
      (declare (xargs :guard t))
      (if (atom vec)
          (equal vec nil)
        (let ((item (first vec)))
          (and (true-listp item)
               (= 2 (len item))
               ;; could say (coefficientp (first item) prime) but then we'd have to
               ;; pass in the prime:
               (integerp (first item))
               (pseudo-varp (second item))
               (sparse-vectorp (rest vec))))))