Check if a term is a (translated) call of list.
(check-list-call term) → (mv yes/no elements)
In translated form, the term must have the form
Function:
(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:
(defthm booleanp-of-check-list-call.yes/no (b* (((mv ?yes/no ?elements) (check-list-call term))) (booleanp yes/no)) :rule-classes :rewrite)
Theorem:
(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)