(member-of-pat-flatten a pat) is an optimized way to ask if
This just avoids actually flattening the pattern, and picks a function with optimized EQ/EQL/EQUAL testing.
Function:
(defun member-eq-of-pat-flatten (a pat) (declare (xargs :guard (symbolp a))) (mbe :logic (if (member-equal a (pat-flatten1 pat)) t nil) :exec (if pat (if (atom pat) (eq a pat) (or (member-eq-of-pat-flatten a (car pat)) (member-eq-of-pat-flatten a (cdr pat)))) nil)))
Function:
(defun member-eql-of-pat-flatten (a pat) (declare (xargs :guard (eqlablep a))) (mbe :logic (if (member-equal a (pat-flatten1 pat)) t nil) :exec (if pat (if (atom pat) (eql a pat) (or (member-eql-of-pat-flatten a (car pat)) (member-eql-of-pat-flatten a (cdr pat)))) nil)))
Function:
(defun member-equal-of-pat-flatten-aux (a pat) (declare (xargs :guard t)) (mbe :logic (if (member-equal a (pat-flatten1 pat)) t nil) :exec (if pat (if (atom pat) (equal a pat) (or (member-equal-of-pat-flatten-aux a (car pat)) (member-equal-of-pat-flatten-aux a (cdr pat)))) nil)))
Function:
(defun member-of-pat-flatten (a pat) (declare (xargs :guard t)) (mbe :logic (if (member-equal a (pat-flatten1 pat)) t nil) :exec (cond ((symbolp a) (member-eq-of-pat-flatten a pat)) ((or (acl2-numberp a) (characterp a)) (member-eql-of-pat-flatten a pat)) (t (member-equal-of-pat-flatten-aux a pat)))))