Perform a left tree rotation.
(rotate-left tree) → tree$
When the right subtree is empty (contrary to the guard), we logically just return the tree.
Function:
(defun rotate-left$inline (tree) (declare (xargs :guard (binary-tree-p tree))) (declare (xargs :guard (not (tree-emptyp (tree-right tree))))) (if (mbt (not (tree-emptyp (tree-right tree)))) (tree-node (tree-head (tree-right tree)) (tree-node (tree-head tree) (tree-left tree) (tree-left (tree-right tree))) (tree-right (tree-right tree))) (tree-fix tree)))
Theorem:
(defthm binary-tree-p-of-rotate-left (b* ((tree$ (rotate-left$inline tree))) (binary-tree-p tree$)) :rule-classes :rewrite)