• 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
            • Jenkins-hash
            • Binary-tree
            • Tree-split
            • Heap<
            • Tree-join
              • Tree-delete
              • Rotations
              • Tree-insert
              • Tree-intersect
              • Tree-join-at
              • Tree-union
              • Hash
              • Tree-in
              • Tree-diff
              • Tree-nodes-count
            • 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
    • Implementation

    Tree-join

    Join two trees which have previously been tree-split.

    Signature
    (tree-join left right) → tree
    Arguments
    left — Guard (binary-tree-p left).
    right — Guard (binary-tree-p right).
    Returns
    tree — Type (binary-tree-p tree).

    Technically it is not required that the two trees are a result of a previous split call. It is only expected that, given a join (tree-join left right), there exists some x such that (bst<-all-l left x) and (bst<-all-r x right), as is produced by split.

    Definitions and Theorems

    Function: tree-join

    (defun tree-join (left right)
      (declare (xargs :guard (and (binary-tree-p left)
                                  (binary-tree-p right))))
      (let ((__function__ 'tree-join))
        (declare (ignorable __function__))
        (cond ((tree-emptyp left) (tree-fix right))
              ((tree-emptyp right) (tree-fix left))
              ((heap< (tree-head left)
                      (tree-head right))
               (tree-node (tree-head right)
                          (tree-join left (tree-left right))
                          (tree-right right)))
              (t (tree-node (tree-head left)
                            (tree-left left)
                            (tree-join (tree-right left) right))))))

    Theorem: binary-tree-p-of-tree-join

    (defthm binary-tree-p-of-tree-join
      (b* ((tree (tree-join left right)))
        (binary-tree-p tree))
      :rule-classes :rewrite)