• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
    • Debugging
    • Std
      • Std/lists
      • Std/alists
      • Obags
      • Std/util
      • Std/strings
      • Std/osets
      • Std/io
      • Std/basic
      • Std/system
        • Fresh-logical-name-with-$s-suffix
        • Irrelevant-formals-info
        • Std/system/function-queries
        • Std/system/term-queries
          • Check-mv-let-call
          • Term-possible-numbers-of-results
          • Check-user-term
          • Check-nary-lambda-call
          • Check-lambda-call
          • All-vars-open
          • Dumb-occur-var-open
          • Check-user-lambda
          • Check-if-call
            • One-way-unify$
            • Check-unary-lambda-call
            • Guard-verified-fnsp
            • All-non-gv-ffn-symbs
            • All-non-gv-exec-ffn-symbs
            • Check-fn-call
            • Guard-verified-exec-fnsp
            • Check-list-call
            • Check-or-call
            • Check-and-call
            • All-program-ffn-symbs
            • Lambda-guard-verified-fnsp
            • All-free/bound-vars
            • Check-mbt$-call
            • If-tree-leaf-terms
            • Check-not-call
            • Check-mbt-call
            • Term-guard-obligation
            • All-pkg-names
            • All-vars-in-untranslated-term
            • Std/system/all-fnnames
            • Lambda-logic-fnsp
            • Lambda-guard-verified-exec-fnsp
            • All-lambdas
            • Lambda-closedp
            • Std/system/all-vars
          • Std/system/term-transformations
          • Std/system/enhanced-utilities
          • Install-not-normalized-event
          • Install-not-normalized-event-lst
          • Std/system/term-function-recognizers
          • Genvar$
          • Std/system/event-name-queries
          • Pseudo-tests-and-call-listp
          • Maybe-pseudo-event-formp
          • Add-suffix-to-fn-or-const
          • Chk-irrelevant-formals-ok
          • Table-alist+
          • Pseudo-tests-and-callp
          • Add-suffix-to-fn-or-const-lst
          • Known-packages+
          • Add-suffix-to-fn-lst
          • Unquote-term
          • Event-landmark-names
          • Add-suffix-lst
          • Std/system/theorem-queries
          • Unquote-term-list
          • Std/system/macro-queries
          • Pseudo-command-landmark-listp
          • Install-not-normalized$
          • Pseudo-event-landmark-listp
          • Known-packages
          • Std/system/partition-rest-and-keyword-args
          • Rune-enabledp
          • Rune-disabledp
          • Included-books
          • Std/system/pseudo-event-formp
          • Std/system/plist-worldp-with-formals
          • Std/system/w
          • Std/system/geprops
          • Std/system/arglistp
          • Std/system/constant-queries
        • Std/typed-lists
        • Std/bitsets
        • Std/testing
        • Std/typed-alists
        • Std/stobjs
      • Community
      • Proof-automation
      • Macro-libraries
      • ACL2
      • Interfacing-tools
      • Hardware-verification
      • Software-verification
      • Math
      • Testing-utilities
    • Std/system/term-queries

    Check-if-call

    Check if a term is a call of if.

    Signature
    (check-if-call term) → (mv yes/no test then else)
    Arguments
    term — Guard (pseudo-termp term).
    Returns
    yes/no — Type (booleanp yes/no).
    test — Type (pseudo-termp test), given the guard.
    then — Type (pseudo-termp then), given the guard.
    else — Type (pseudo-termp else), given the guard.
    If it is, return its test and branches. If it is not, all results are nil.

    Definitions and Theorems

    Function: check-if-call

    (defun check-if-call (term)
     (declare (xargs :guard (pseudo-termp term)))
     (let ((__function__ 'check-if-call))
      (declare (ignorable __function__))
      (b*
       (((when (variablep term))
         (mv nil nil nil nil))
        ((when (fquotep term))
         (mv nil nil nil nil))
        (fn (ffn-symb term))
        ((unless (eq fn 'if))
         (mv nil nil nil nil))
        ((unless (= (len (fargs term)) 3))
         (prog2$
          (raise
           "Internal error: ~
                            the IF call ~x0 has arguments ~x1."
           term (fargs term))
          (mv nil nil nil nil))))
       (mv t (fargn term 1)
           (fargn term 2)
           (fargn term 3)))))

    Theorem: booleanp-of-check-if-call.yes/no

    (defthm booleanp-of-check-if-call.yes/no
      (b* (((mv ?yes/no ?test ?then ?else)
            (check-if-call term)))
        (booleanp yes/no))
      :rule-classes :rewrite)

    Theorem: pseudo-termp-of-check-if-call.test

    (defthm pseudo-termp-of-check-if-call.test
      (implies (and (pseudo-termp term))
               (b* (((mv ?yes/no ?test ?then ?else)
                     (check-if-call term)))
                 (pseudo-termp test)))
      :rule-classes :rewrite)

    Theorem: pseudo-termp-of-check-if-call.then

    (defthm pseudo-termp-of-check-if-call.then
      (implies (and (pseudo-termp term))
               (b* (((mv ?yes/no ?test ?then ?else)
                     (check-if-call term)))
                 (pseudo-termp then)))
      :rule-classes :rewrite)

    Theorem: pseudo-termp-of-check-if-call.else

    (defthm pseudo-termp-of-check-if-call.else
      (implies (and (pseudo-termp term))
               (b* (((mv ?yes/no ?test ?then ?else)
                     (check-if-call term)))
                 (pseudo-termp else)))
      :rule-classes :rewrite)

    Theorem: acl2-count-of-check-if-call.test

    (defthm acl2-count-of-check-if-call.test
      (b* (((mv ?yes/no ?test ?then ?else)
            (check-if-call term)))
        (implies yes/no
                 (< (acl2-count test)
                    (acl2-count term))))
      :rule-classes :linear)

    Theorem: acl2-count-of-check-if-call.then

    (defthm acl2-count-of-check-if-call.then
      (b* (((mv ?yes/no ?test ?then ?else)
            (check-if-call term)))
        (implies yes/no
                 (< (acl2-count then)
                    (acl2-count term))))
      :rule-classes :linear)

    Theorem: acl2-count-of-check-if-call.else

    (defthm acl2-count-of-check-if-call.else
      (b* (((mv ?yes/no ?test ?then ?else)
            (check-if-call term)))
        (implies yes/no
                 (< (acl2-count else)
                    (acl2-count term))))
      :rule-classes :linear)