(q-or &rest args) constructs a UBDD representing the disjunction of its arguments.
In the logic,
(Q-OR) = NIL (Q-OR X) = X (Q-OR X Y) = (Q-BINARY-OR X Y) (Q-OR X Y Z) = (Q-BINARY-OR X (Q-BINARY-OR Y Z))
In the execution, we use the same sort of optimization as in q-and.
Function:
(defun q-binary-or (x y) (declare (xargs :guard t)) (cond ((atom x) (if x t (if (atom y) (if y t nil) y))) ((atom y) (if y t x)) ((hons-equal x y) x) (t (let ((l (q-binary-or (car x) (car y))) (r (q-binary-or (cdr x) (cdr y)))) (qcons l r)))))
Function:
(defun q-or-macro-logic-part (args) (cond ((atom args) nil) ((atom (cdr args)) (car args)) (t (cons 'q-binary-or (cons (car args) (cons (q-or-macro-logic-part (cdr args)) 'nil))))))
Function:
(defun q-or-macro-exec-part (args) (cond ((atom args) nil) ((atom (cdr args)) (car args)) (t (cons 'let (cons (cons (cons 'q-or-x-do-not-use-elsewhere (cons (car args) 'nil)) 'nil) (cons (cons 'if (cons '(eq t q-or-x-do-not-use-elsewhere) (cons 't (cons (cons 'prog2$ (cons '(last-chance-wash-memory) (cons (cons 'q-binary-or (cons 'q-or-x-do-not-use-elsewhere (cons (q-or-macro-exec-part (cdr args)) 'nil))) 'nil))) 'nil)))) 'nil))))))
Function:
(defun q-or-macro-fn (args) (cond ((atom args) nil) ((atom (cdr args)) (car args)) (t (mv-let (cheap expensive) (cheap-and-expensive-arguments args) (if (not expensive) (q-or-macro-logic-part cheap) (let ((reordered-args (append cheap expensive))) (cons 'mbe (cons ':logic (cons (q-or-macro-logic-part reordered-args) (cons ':exec (cons (q-or-macro-exec-part reordered-args) 'nil)))))))))))
Theorem:
(defthm ubddp-of-q-or (implies (and (force (ubddp x)) (force (ubddp y))) (equal (ubddp (q-or x y)) t)))
Theorem:
(defthm eval-bdd-of-q-or (equal (eval-bdd (q-or x y) values) (or (eval-bdd x values) (eval-bdd y values))))
Theorem:
(defthm canonicalize-q-or (implies (and (force (ubddp x)) (force (ubddp y))) (equal (q-or x y) (q-ite x t y))))
Theorem:
(defthm q-or-of-nil-slow (and (equal (q-or nil x) (if (consp x) x (if x t nil))) (equal (q-or x nil) (if (consp x) x (if x t nil)))))
Theorem:
(defthm q-or-of-nil-aggressive (implies (force (ubddp x)) (and (equal (q-or nil x) x) (equal (q-or x nil) x))))
Theorem:
(defthm q-or-of-t (and (equal (q-or t x) t) (equal (q-or x t) t)))
Theorem:
(defthm q-or-symmetric (equal (q-or x y) (q-or y x)))
Function:
(defun q-binary-or-memoize-condition (x y) (declare (ignorable x y) (xargs :guard 't)) (and (consp x) (consp y)))
Theorem:
(defthm q-or-of-self-slow (equal (q-or x x) (if (consp x) x (if x t nil))))
Theorem:
(defthm q-or-of-self-aggressive (implies (force (ubddp x)) (equal (q-or x x) x)))