• Top
    • Documentation
    • Books
    • Recursion-and-induction
    • Boolean-reasoning
      • Ipasir
      • Aignet
      • Aig
      • Satlink
      • Truth
      • Ubdds
        • Equal-by-eval-bdds
        • Ubdd-constructors
          • Q-and
          • Q-ite
          • Q-or
          • Q-implies
          • Q-iff
          • Q-and-c2
          • Q-and-c1
          • Q-or-c2
          • Q-not
          • Q-ite-fn
            • Q-xor
            • Q-and-is-nil
            • Cheap-and-expensive-arguments
            • Q-compose-list
            • Q-compose
            • Qv
            • Q-and-is-nilc2
            • Q-nor
            • Q-nand
          • Eval-bdd
          • Ubddp
          • Ubdd-fix
          • Q-sat
          • Bdd-sat-dfs
          • Eval-bdd-list
          • Qcdr
          • Qcar
          • Q-sat-any
          • Canonicalize-to-q-ite
          • Ubdd-listp
          • Qcons
        • Bdd
        • Faig
        • Bed
        • 4v
      • Debugging
      • Projects
      • Std
      • Proof-automation
      • Macro-libraries
      • ACL2
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Testing-utilities
      • Math
    • Ubdd-constructors

    Q-ite-fn

    Basic way to construct a new if-then-else UBDD.

    (q-ite-fn x y z) builds a new UBDD representing (if x y z). That is, the following is a theorem:

    (equal (eval-bdd (q-ite-fn x y z) values)
           (if (eval-bdd x values)
               (eval-bdd y values)
             (eval-bdd z values)))

    Normally you will want to use q-ite instead, which is a macro that is logically the same as q-ite-fn, but expands into a lazy call of q-ite-fn and can sometimes avoid the need to evaluate y and z.

    Note: memoized for efficiency.

    Definitions and Theorems

    Function: q-ite-fn

    (defun
      q-ite-fn (x y z)
      (declare (xargs :guard t))
      (cond ((null x) z)
            ((atom x) y)
            (t (let ((y (if (hons-equal x y) t y))
                     (z (if (hons-equal x z) nil z)))
                    (cond ((hons-equal y z) y)
                          ((and (eq y t) (eq z nil)) x)
                          ((and (eq y nil) (eq z t)) (q-not x))
                          (t (qcons (q-ite-fn (car x) (qcar y) (qcar z))
                                    (q-ite-fn (cdr x)
                                              (qcdr y)
                                              (qcdr z)))))))))

    Function: q-ite-fn-memoize-condition

    (defun q-ite-fn-memoize-condition (x y z)
           (declare (ignorable x y z)
                    (xargs :guard 't))
           (and (consp x)
                (or (consp (car x)) (consp (cdr x)))))