• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
      • Kestrel-books
        • Crypto-hdwallet
        • Apt
        • Error-checking
        • Fty-extensions
        • Isar
        • Kestrel-utilities
        • Set
          • Implementation
          • Setp
          • Right
          • Left
          • Head
          • Double-containment
          • Subset
          • Intersect
            • Insert
            • In
            • Delete
            • Union
            • Diff
            • From-list
            • To-list
            • Set-equiv
            • Sfix
            • Pick-a-point
            • Cardinality
            • Set-induct
            • Set-bi-induct
            • Emptyp
          • Soft
          • C
          • Bv
          • Imp-language
          • Event-macros
          • Java
          • Bitcoin
          • Ethereum
          • Yul
          • Zcash
          • ACL2-programming-language
          • Prime-fields
          • Json
          • Syntheto
          • File-io-light
          • Cryptography
          • Number-theory
          • Lists-light
          • Axe
          • Builtins
          • Solidity
          • Helpers
          • Htclient
          • Typed-lists-light
          • Arithmetic-light
        • X86isa
        • Axe
        • Execloader
      • Math
      • Testing-utilities
    • Set

    Intersect

    An n-ary set intersection.

    Time complexity: O(n\log(m/n)) (for binary intersection, where n < m).

    Definitions and Theorems

    Function: binary-intersect

    (defun binary-intersect (x y)
      (declare (xargs :guard (and (setp x) (setp y))))
      (let ((__function__ 'binary-intersect))
        (declare (ignorable __function__))
        (tree-intersect (sfix x) (sfix y))))

    Theorem: setp-of-binary-intersect

    (defthm setp-of-binary-intersect
      (b* ((set (binary-intersect x y)))
        (setp set))
      :rule-classes :rewrite)

    Function: intersect-macro-loop

    (defun intersect-macro-loop (list)
      (declare (xargs :guard (true-listp list)))
      (declare (xargs :guard (and (consp list) (consp (rest list)))))
      (let ((__function__ 'intersect-macro-loop))
        (declare (ignorable __function__))
        (if (endp (rest (rest list)))
            (list 'binary-intersect
                  (first list)
                  (second list))
          (list 'binary-intersect
                (first list)
                (intersect-macro-loop (rest list))))))

    Macro: intersect

    (defmacro intersect (x y &rest rst)
      (declare (xargs :guard t))
      (intersect-macro-loop (list* x y rst)))