• Top
    • Documentation
    • Books
    • Boolean-reasoning
      • Ipasir
      • Aignet
      • Aig
      • Satlink
      • Truth
      • Ubdds
      • Bdd
      • Faig
      • Bed
      • 4v
        • 4v-sexprs
          • 4v-sexpr-vars
          • 4v-sexpr-eval
          • 4v-sexpr-to-faig
          • 4v-sexpr-restrict-with-rw
          • 4vs-constructors
          • 4v-sexpr-compose-with-rw
          • 4v-sexpr-restrict
          • 4v-sexpr-alist-extract
          • 4v-sexpr-compose
          • 4v-nsexpr-p
          • 4v-sexpr-purebool-p
            • 4v-sexpr-purebool-check
              • 4v-sexpr-purebool-list-check
              • 4v-sexpr-purebool-list-p
              • 4v-sexpr-purebool-list-p-to-faig-purebool-list-p
            • 4v-sexpr-<=
            • Sfaig
            • Sexpr-equivs
            • 3v-syntax-sexprp
            • Sexpr-rewriting
            • 4v-sexpr-ind
            • 4v-alist-extract
          • 4v-monotonicity
          • 4v-operations
          • Why-4v-logic
          • 4v-<=
          • 4vp
          • 4vcases
          • 4v-fix
          • 4v-lookup
      • Projects
      • Debugging
      • Std
      • Community
      • Proof-automation
      • Macro-libraries
      • ACL2
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • 4v-sexpr-purebool-p

    4v-sexpr-purebool-check

    An executable version of 4v-sexpr-purebool-p using SAT.

    Signature
    (4v-sexpr-purebool-check sexpr &key 
                             (config 'satlink::*default-config*)) 
     
      → 
    (mv fail purebool ctrex)
    Arguments
    sexpr — The 4v-sexpr to check.
    config — Guard (satlink::config-p config).
    Returns
    fail — If true, calling the SAT solver failed and the other answers are meaningless.
        Type (booleanp fail).
    purebool — Does the sexpr always evaluate to purely Boolean?.
        Type (booleanp purebool).
    ctrex — NIL when the sexpr is purely Boolean. Otherwise, an example environment (an alist suitable for 4v-sexpr-eval) for which sexpr evaluates to X or Z.

    Note: if you want to check whether several sexprs are all purely Boolean valued, 4v-sexpr-purebool-list-check will typically be far more efficient than calling 4v-sexpr-purebool-check repeatedly.

    Definitions and Theorems

    Function: 4v-sexpr-purebool-check-fn

    (defun 4v-sexpr-purebool-check-fn (sexpr config)
      (declare (xargs :guard (satlink::config-p config)))
      (let ((__function__ '4v-sexpr-purebool-check))
        (declare (ignorable __function__))
        (mbe :logic
             (b* ((faig (sfaig sexpr))
                  ((mv fail purebool faig-env)
                   (faig-purebool-check faig
                                        :config config))
                  ((when fail) (mv fail nil nil))
                  ((when purebool) (mv nil t nil))
                  (4v-env (sfaig-recover-4venv sexpr faig-env)))
               (mv nil nil 4v-env))
             :exec
             (b* ((vars (4v-sexpr-vars-1pass sexpr))
                  (onoff (num-varmap vars 0))
                  (faig (4v-sexpr-to-faig sexpr onoff))
                  ((mv fail purebool faig-env)
                   (faig-purebool-check faig
                                        :config config))
                  ((when fail) (mv fail nil nil))
                  ((when purebool) (mv nil t nil))
                  (4v-env (faig-const-alist->4v-alist
                               (faig-eval-alist onoff faig-env))))
               (mv nil nil 4v-env)))))

    Theorem: booleanp-of-4v-sexpr-purebool-check.fail

    (defthm booleanp-of-4v-sexpr-purebool-check.fail
      (b* (((mv ?fail ?purebool ?ctrex)
            (4v-sexpr-purebool-check-fn sexpr config)))
        (booleanp fail))
      :rule-classes :type-prescription)

    Theorem: booleanp-of-4v-sexpr-purebool-check.purebool

    (defthm booleanp-of-4v-sexpr-purebool-check.purebool
      (b* (((mv ?fail ?purebool ?ctrex)
            (4v-sexpr-purebool-check-fn sexpr config)))
        (booleanp purebool))
      :rule-classes :type-prescription)

    Theorem: 4v-sexpr-purebool-check-correct

    (defthm 4v-sexpr-purebool-check-correct
      (b* (((mv fail purebool ?alist)
            (4v-sexpr-purebool-check sexpr
                                     :config config)))
        (implies (not fail)
                 (equal purebool (4v-sexpr-purebool-p sexpr)))))

    Theorem: 4v-sexpr-purebool-check-counterexample-correct

    (defthm 4v-sexpr-purebool-check-counterexample-correct
      (b* (((mv fail ?purebool alist)
            (4v-sexpr-purebool-check sexpr
                                     :config config)))
        (implies (and (not fail)
                      (not (4v-sexpr-purebool-p sexpr)))
                 (and (not (equal (4v-sexpr-eval sexpr alist)
                                  (4vt)))
                      (not (equal (4v-sexpr-eval sexpr alist)
                                  (4vf)))))))