• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
      • Theories
      • Rule-classes
      • Proof-builder
      • Recursion-and-induction
      • Hons-and-memoization
      • Events
      • Parallelism
      • History
      • Programming
        • Defun
        • Declare
        • System-utilities
        • Stobj
          • Defstobj
          • Defabsstobj
          • Stobj-table
          • Preservation-thms
          • Nested-stobjs
          • Defrstobj
          • With-global-stobj
          • User-stobjs-modified-warnings
          • Stobj-example-1
          • Defrstobj
          • Stobj-example-3
          • Stobj-example-1-proofs
          • With-local-stobj
          • Stobj-example-1-defuns
          • Declare-stobjs
          • Trans-eval-and-stobjs
          • With-local-state
          • Stobj-example-2
          • Stobj-example-1-implementation
          • Add-global-stobj
          • Swap-stobjs
          • Resize-list
          • Nth-aliases-table
          • Def-stobj-frame
          • Trans-eval-and-locally-bound-stobjs
          • Std/stobjs
            • Stobj-updater-independence
            • Def-1d-arr
            • Defstobj-clone
            • Def-2d-arr
            • Defabsstobj-events
            • Bitarr
              • Bits-equiv
                • Set-bit
                • Resize-bits
                • Get-bit
                • Bits-length
              • Natarr
            • Count-keys
            • Update-nth-array
            • Remove-global-stobj
          • State
          • Mutual-recursion
          • Memoize
          • Mbe
          • Io
          • Defpkg
          • Apply$
          • Loop$
          • Programming-with-state
          • Arrays
          • Characters
          • Time$
          • Defmacro
          • Loop$-primer
          • Fast-alists
          • Defconst
          • Evaluation
          • Guard
          • Equality-variants
          • Compilation
          • Hons
          • ACL2-built-ins
          • Developers-guide
          • System-attachments
          • Advanced-features
          • Set-check-invariant-risk
          • Numbers
          • Efficiency
          • Irrelevant-formals
          • Introduction-to-programming-in-ACL2-for-those-who-know-lisp
          • Redefining-programs
          • Lists
          • Invariant-risk
          • Errors
          • Defabbrev
          • Conses
          • Alists
          • Set-register-invariant-risk
          • Strings
          • Program-wrapper
          • Get-internal-time
          • Basics
          • Packages
          • Oracle-eval
          • Defmacro-untouchable
          • <<
          • Primitive
          • Revert-world
          • Unmemoize
          • Set-duplicate-keys-action
          • Symbols
          • Def-list-constructor
          • Easy-simplify-term
          • Defiteration
          • Fake-oracle-eval
          • Defopen
          • Sleep
        • Operational-semantics
        • Real
        • Start-here
        • Debugging
        • Miscellaneous
        • Output-controls
        • Macros
        • Interfacing-tools
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Bitarr

    Bits-equiv

    Bit-for-bit list equivalence: bits-equiv recognizes lists whose nth elements are bit-equiv to one another. It is often useful for reasoning about bit arrays like bitarr.

    This is a universal equivalence, introduced using def-universal-equiv.

    Function: bits-equiv

    (defun bits-equiv (x y)
      (declare (xargs :non-executable t))
      (declare (xargs :guard t))
      (prog2$ (throw-nonexec-error 'bits-equiv
                                   (list x y))
              (let ((i (bits-equiv-witness x y)))
                (and (bit-equiv (nth i x) (nth i y))))))

    Definitions and Theorems

    Theorem: bits-equiv-necc

    (defthm bits-equiv-necc
      (implies (not (and (bit-equiv (nth i x) (nth i y))))
               (not (bits-equiv x y))))

    Theorem: bits-equiv-is-an-equivalence

    (defthm bits-equiv-is-an-equivalence
      (and (booleanp (bits-equiv x y))
           (bits-equiv x x)
           (implies (bits-equiv x y)
                    (bits-equiv y x))
           (implies (and (bits-equiv x y) (bits-equiv y z))
                    (bits-equiv x z)))
      :rule-classes (:equivalence))

    Theorem: bits-equiv-implies-bit-equiv-nth-2

    (defthm bits-equiv-implies-bit-equiv-nth-2
      (implies (bits-equiv x x-equiv)
               (bit-equiv (nth i x) (nth i x-equiv)))
      :rule-classes (:congruence))

    Theorem: bits-equiv-implies-bits-equiv-update-nth-3

    (defthm bits-equiv-implies-bits-equiv-update-nth-3
      (implies (bits-equiv x x-equiv)
               (bits-equiv (update-nth i v x)
                           (update-nth i v x-equiv)))
      :rule-classes (:congruence))

    Theorem: bit-equiv-implies-bits-equiv-update-nth-2

    (defthm bit-equiv-implies-bits-equiv-update-nth-2
      (implies (bit-equiv v v-equiv)
               (bits-equiv (update-nth i v x)
                           (update-nth i v-equiv x)))
      :rule-classes (:congruence))

    Theorem: bits-equiv-implies-bits-equiv-cdr-1

    (defthm bits-equiv-implies-bits-equiv-cdr-1
      (implies (bits-equiv a a-equiv)
               (bits-equiv (cdr a) (cdr a-equiv)))
      :rule-classes (:congruence))

    Theorem: bits-equiv-implies-bit-equiv-car-1

    (defthm bits-equiv-implies-bit-equiv-car-1
      (implies (bits-equiv x x-equiv)
               (bit-equiv (car x) (car x-equiv)))
      :rule-classes (:congruence))

    Theorem: bit-equiv-implies-bits-equiv-cons-1

    (defthm bit-equiv-implies-bits-equiv-cons-1
      (implies (bit-equiv a a-equiv)
               (bits-equiv (cons a b)
                           (cons a-equiv b)))
      :rule-classes (:congruence))

    Theorem: bits-equiv-implies-bits-equiv-cons-2

    (defthm bits-equiv-implies-bits-equiv-cons-2
      (implies (bits-equiv b b-equiv)
               (bits-equiv (cons a b)
                           (cons a b-equiv)))
      :rule-classes (:congruence))