• 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-list-call

    Check if a term is a (translated) call of list.

    Signature
    (check-list-call term) → (mv yes/no elements)
    Arguments
    term — Guard (pseudo-termp term).
    Returns
    yes/no — Type (booleanp yes/no).
    elements — Type (pseudo-term-listp elements), given the guard.

    In translated form, the term must have the form (cons ... (cons ... (cons ... (... 'nil)...))), i.e. be a nest of conses that ends in a quoted nil. The nest may be empty, i.e. the term may be just a quoted nil. If the term has this form, we return the list of its element terms, i.e. all the cars of the nest, in the same order.

    Definitions and Theorems

    Function: check-list-call

    (defun check-list-call (term)
      (declare (xargs :guard (pseudo-termp term)))
      (let ((__function__ 'check-list-call))
        (declare (ignorable __function__))
        (b* (((when (variablep term)) (mv nil nil))
             ((when (fquotep term))
              (if (equal term *nil*)
                  (mv t nil)
                (mv nil nil)))
             (fn (ffn-symb term))
             ((unless (eq fn 'cons)) (mv nil nil))
             (args (fargs term))
             ((unless (= (len args) 2))
              (raise "Internal error: found CONS with ~x0 arguments."
                     (len args))
              (mv nil nil))
             (car (first args))
             (cdr (second args))
             ((mv yes/no-rest elements-rest)
              (check-list-call cdr))
             ((unless yes/no-rest) (mv nil nil)))
          (mv t (cons car elements-rest)))))

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

    (defthm booleanp-of-check-list-call.yes/no
      (b* (((mv ?yes/no ?elements)
            (check-list-call term)))
        (booleanp yes/no))
      :rule-classes :rewrite)

    Theorem: pseudo-term-listp-of-check-list-call.elements

    (defthm pseudo-term-listp-of-check-list-call.elements
      (implies (and (pseudo-termp term))
               (b* (((mv ?yes/no ?elements)
                     (check-list-call term)))
                 (pseudo-term-listp elements)))
      :rule-classes :rewrite)