(defun mem (a x) (if (consp x) (if (equal a (car x)) t (mem a (cdr x))) nil)) (defun sub (x y) (if (consp x) (if (mem (car x) y) (sub (cdr x) y) nil) t)) (defthm p48.1 (implies (sub y z) (sub y (cons a z)))) (defthm p48.1 (sub x (app y x))) (implies (and (consp x) (sub y (cdr x))) (sub y x))) (DEFTHM P48 (SUB X X) :INSTRUCTIONS (:INDUCT :S (:DEMOTE 2) :S :EXPAND :S (:DIVE 2) (:= X (CONS (CAR X) (CDR X))) :TOP (:REWRITE P48.1))) (defun mapnil1 (x a) (if (consp x) (mapnil1 (cdr x) (cons nil a)) a)) (defun map1 (x a) (if (consp x) (map1 (cdr x) (cons (car x) a)) a)) (defun nil-listp (x) (if (consp x) (if (equal (car x) nil) (nil-listp (cdr x)) nil) (equal x nil))) (defthm p51.1 (implies (nil-listp y) (equal (mapnil1 y (cons nil z)) (cons nil (mapnil1 y z))))) (defthm p51.2 (implies (nil-listp x) (equal (mapnil1 x nil) x)) :INSTRUCTIONS (:INDUCT :S (:DIVE 1) :S :TOP :S (:DIVE 1) :EXPAND :S :TOP (:DIVE 2 1) :EXPAND :S :TOP (:DIVE 2 1) (:REWRITE P51.1) :TOP :PRO (:DEMOTE 3) (:DIVE 1) :S :TOP :PRO (:DIVE 1 2) :S :TOP :S)) (DEFTHM P51 (IMPLIES (AND (NIL-LISTP A) (NIL-LISTP B)) (EQUAL (MAPNIL1 A B) (MAPNIL1 B A))) :INSTRUCTIONS (:INDUCT :S (:DIVE 1 1) :EXPAND :S :UP :S :TOP (:DIVE 2 1) :EXPAND :S :TOP (:DEMOTE 2) (:DIVE 1 2 1) (:REWRITE P51.1) :TOP :PRO (:= (CONS NIL (MAPNIL1 (CDR A) B)) (MAPNIL1 (CONS NIL B) (CDR A))) (:DIVE 1) :EXPAND :TOP (:DIVE 1) (:= (IF (CONSP (CONS NIL B)) (MAPNIL1 (CDR (CONS NIL B)) (CONS NIL (CDR A))) (CDR A)) (MAPNIL1 B (CONS NIL (CDR A)))) :TOP (:DIVE 2) (:= A (CONS NIL (CDR A))) :TOP :S))