• Top
    • Documentation
    • Books
    • 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
          • Cheap-and-expensive-arguments
            • Q-and-is-nil
            • Q-compose-list
            • Qv
            • Q-compose
            • 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
      • Projects
      • Debugging
      • Community
      • Std
      • Proof-automation
      • Macro-libraries
      • ACL2
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Ubdd-constructors

    Cheap-and-expensive-arguments

    Sort arguments into those that we think are definitely cheap to evaluate versus those that may be expensive.

    This is the same idea as in q-ite. Variables and quoted constants are cheap to evaluate, so in associative/commutative operations like q-and we prefer to evaluate them first.

    Definitions and Theorems

    Function: cheap-and-expensive-arguments-aux

    (defun cheap-and-expensive-arguments-aux (x cheap expensive)
      (if (atom x)
          (mv cheap expensive)
        (if (or (quotep (car x)) (atom (car x)))
            (cheap-and-expensive-arguments-aux (cdr x)
                                               (cons (car x) cheap)
                                               expensive)
          (cheap-and-expensive-arguments-aux
               (cdr x)
               cheap (cons (car x) expensive)))))

    Function: cheap-and-expensive-arguments

    (defun cheap-and-expensive-arguments (x)
      (mv-let (cheap expensive)
              (cheap-and-expensive-arguments-aux x nil nil)
        (mv (reverse cheap)
            (reverse expensive))))