Ordering on naturals or lists of naturals
The function
Function:
(defun l< (x y) (declare (xargs :guard (and (lexp x) (lexp y)))) (or (< (len x) (len y)) (and (= (len x) (len y)) (if (atom x) (< x y) (d< x y)))))
Function:
(defun lexp (x) (declare (xargs :guard t)) (or (natp x) (and (consp x) (nat-listp x))))
Function:
(defun d< (x y) (declare (xargs :guard (and (nat-listp x) (nat-listp y)))) (and (consp x) (consp y) (or (< (car x) (car y)) (and (= (car x) (car y)) (d< (cdr x) (cdr y))))))
Function:
(defun lex-fix (x) (declare (xargs :guard t)) (cond ((atom x) (nfix x)) (t (nfix-list x))))
Function:
(defun nfix-list (list) (declare (xargs :guard t)) (if (consp list) (cons (nfix (car list)) (nfix-list (cdr list))) nil))