Collect paths that are
(regular-files paths &key (state 'state)) → (mv err ans new-state)
Function:
(defun regular-files-exec-fn (paths acc state) (declare (xargs :stobjs (state))) (declare (xargs :guard (string-listp paths))) "Tail recursive version for execution." (let ((__function__ 'regular-files-exec)) (declare (ignorable __function__)) (b* (((when (atom paths)) (mv nil acc state)) ((mv err regular-p state) (regular-file-p (car paths))) ((when err) (mv err acc state)) (acc (if regular-p (cons (car paths) acc) acc))) (regular-files-exec (cdr paths) acc))))
Function:
(defun regular-files-fn (paths state) (declare (xargs :stobjs (state))) (declare (xargs :guard (string-listp paths))) (let ((__function__ 'regular-files)) (declare (ignorable __function__)) (mbe :logic (b* (((when (atom paths)) (mv nil nil state)) ((mv err regular-p state) (regular-file-p (car paths))) ((when err) (mv err nil state)) ((mv err rest state) (regular-files (cdr paths))) (ans (if regular-p (cons (car paths) rest) rest))) (mv err ans state)) :exec (b* (((mv err acc state) (regular-files-exec paths nil))) (mv err (reverse acc) state)))))
Theorem:
(defthm string-listp-of-regular-files.ans (implies (string-listp paths) (b* (((mv ?err ?ans ?new-state) (regular-files-fn paths state))) (string-listp ans))) :rule-classes :rewrite)
Theorem:
(defthm state-p1-of-regular-files.new-state (implies (force (state-p1 state)) (b* (((mv ?err ?ans ?new-state) (regular-files-fn paths state))) (state-p1 new-state))) :rule-classes :rewrite)
Theorem:
(defthm regular-files-exec-removal (equal (regular-files-exec paths acc) (b* (((mv err ans state) (regular-files paths))) (mv err (revappend ans acc) state))))
Theorem:
(defthm true-listp-of-regular-files (true-listp (mv-nth 1 (regular-files paths))) :rule-classes :type-prescription)
Theorem:
(defthm w-state-of-regular-files (b* (((mv ?err ?ans ?new-state) (regular-files-fn paths state))) (equal (w new-state) (w state))))