Basic structural induction scheme for s-expressions.
Function:
(defun 4v-sexpr-ind (x) (declare (xargs :guard t)) (if (atom x) x (cons (car x) (4v-sexpr-ind-list (cdr x)))))
Function:
(defun 4v-sexpr-ind-list (x) (declare (xargs :guard t)) (if (atom x) nil (cons (4v-sexpr-ind (car x)) (4v-sexpr-ind-list (cdr x)))))
Function:
(defun 4v-sexpr-flag (flag x) (declare (xargs :non-executable t)) (declare (ignorable x)) (prog2$ (throw-nonexec-error '4v-sexpr-flag (list flag x)) (cond ((equal flag 'sexpr) (if (consp x) (cons (car x) (4v-sexpr-flag 'sexpr-list (cdr x))) x)) (t (if (consp x) (cons (4v-sexpr-flag 'sexpr (car x)) (4v-sexpr-flag 'sexpr-list (cdr x))) 'nil)))))
Theorem:
(defthm 4v-sexpr-flag-equivalences (and (equal (4v-sexpr-flag 'sexpr x) (4v-sexpr-ind x)) (equal (4v-sexpr-flag 'sexpr-list x) (4v-sexpr-ind-list x))))