• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
      • Gl
      • Esim
      • Vl2014
      • Sv
        • Svex-stvs
        • Svex-decomposition-methodology
        • Sv-versus-esim
        • Svex-decomp
        • Svex-compose-dfs
        • Svex-compilation
        • Moddb
        • Svmods
        • Svstmt
        • Sv-tutorial
        • Expressions
          • Rewriting
          • Svex
          • Bit-blasting
          • Functions
            • 4vec-operations
              • 4vec-bit?
              • 4vec-part-install
              • 4vec-concat
              • 4vec-?
              • 4vec-rsh
              • 4vec-bit?!
              • 4vec-===*
              • 4vec-reduction-and
              • 4vec-bit-extract
              • 4vec-rev-blocks
              • 4vec-lsh
              • 4vec-resor
              • 4vec-resand
              • 4vec-parity
                • 4vec-plus
                • 4vec-<
                • 4vec-minus
                • 4vec-res
                • 4vec-override
                • 4vec-bit-index
                • 4vec-?!
                • 4vec-zero-ext
                • 4vec-part-select
                • 4vec-===
                • 4vec-remainder
                • 4vec-reduction-or
                • 4vec-idx->4v
                • 4vec-==
                • 4vec-sign-ext
                • 4vec-quotient
                • 4vec-?*
                • 4vec-bitxor
                • 4vec-wildeq
                • 4vec-times
                • 4vec-bitmux
                • 4vec-symwildeq
                • 4vec-bitand
                • 4vec-wildeq-safe
                • 4vec-bitor
                • 4vec-shift-core
                • 4vec-pow
                • 4vec-onset
                • 4vec-offset
                • 4vec-xdet
                • 4vec-uminus
                • 4vec-clog2
                • 4vec-bitnot
                • 4vec-onehot
                • 4vec-countones
                • 4veclist-p-to-stringp
                • 4vec-p-to-stringp
                • 4vec-onehot0
                • 4vec-1mask
                • 4vec-p-to-stringp-aux
                • 4v->4vec-bit
                • 4v-to-characterp
                • Bool->vec
                • Unsigned-4vec-p
              • 3vec-operations
              • *svex-op-table*
            • 4vmask
            • Why-infinite-width
            • Svex-vars
            • Evaluation
            • Values
          • Symbolic-test-vector
          • Vl-to-svex
        • Fgl
        • Vwsim
        • Vl
        • X86isa
        • Svl
        • Rtl
      • Software-verification
      • Math
      • Testing-utilities
    • 4vec-operations

    4vec-parity

    Reduction logical XOR (i.e., parity) of a 4vec.

    Signature
    (4vec-parity x) → parity
    Arguments
    x — Guard (4vec-p x).
    Returns
    parity — Type (3vec-p! parity).

    We compute the parity of x if possible, following the boolean-convention. If x has any X or Z bits, or is a negative number, we just return all Xes. Otherwise, x is a natural number and we just return the parity of its 1 bits. For instance,

    (4vec-parity #b0) == 0   (all 0s, false)
    (4vec-parity #b1) == -1  (all 1s, true)
    (4vec-parity #b11) == 0  (all 0s, false)
    (4vec-parity #b10) == -1 (all 1s, true)

    Subtle. Since 4vecs are ``infinite width,'' reduction operators are a bit unusual. For parity computations this is especially true for negative number: if x is negative, i.e., it has infinitely many leading 1 bits, it doesn't make much sense to ask about its parity. Accordingly, if you are translating from Verilog or other languages that have fixed width vectors, you will typically want to take the parity of, e.g., the 4vec-zero-ext of your vector.

    Definitions and Theorems

    Function: 4vec-parity

    (defun 4vec-parity (x)
      (declare (xargs :guard (4vec-p x)))
      (let ((__function__ '4vec-parity))
        (declare (ignorable __function__))
        (if (and (2vec-p x) (<= 0 (2vec->val x)))
            (b* ((x (2vec->val x)))
              (2vec (- (fast-parity (+ 1 (integer-length x))
                                    x))))
          (4vec-x))))

    Theorem: 3vec-p!-of-4vec-parity

    (defthm 3vec-p!-of-4vec-parity
      (b* ((parity (4vec-parity x)))
        (3vec-p! parity))
      :rule-classes :rewrite)

    Theorem: 4vec-parity-of-2vecx-fix-x

    (defthm 4vec-parity-of-2vecx-fix-x
      (equal (4vec-parity (2vecx-fix x))
             (4vec-parity x)))

    Theorem: 4vec-parity-2vecx-equiv-congruence-on-x

    (defthm 4vec-parity-2vecx-equiv-congruence-on-x
      (implies (2vecx-equiv x x-equiv)
               (equal (4vec-parity x)
                      (4vec-parity x-equiv)))
      :rule-classes :congruence)