Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,34 @@
|
|||
(defun split (xys)
|
||||
(if (endp (rest xys))
|
||||
(mv xys nil)
|
||||
(mv-let (xs ys)
|
||||
(split (rest (rest xys)))
|
||||
(mv (cons (first xys) xs)
|
||||
(cons (second xys) ys)))))
|
||||
|
||||
(defun mrg (xs ys)
|
||||
(declare (xargs :measure (+ (len xs) (len ys))))
|
||||
(cond ((endp xs) ys)
|
||||
((endp ys) xs)
|
||||
((< (first xs) (first ys))
|
||||
(cons (first xs) (mrg (rest xs) ys)))
|
||||
(t (cons (first ys) (mrg xs (rest ys))))))
|
||||
|
||||
(defthm split-shortens
|
||||
(implies (consp (rest xs))
|
||||
(mv-let (ys zs)
|
||||
(split xs)
|
||||
(and (< (len ys) (len xs))
|
||||
(< (len zs) (len xs))))))
|
||||
|
||||
(defun msort (xs)
|
||||
(declare (xargs
|
||||
:measure (len xs)
|
||||
:hints (("Goal"
|
||||
:use ((:instance split-shortens))))))
|
||||
(if (endp (rest xs))
|
||||
xs
|
||||
(mv-let (ys zs)
|
||||
(split xs)
|
||||
(mrg (msort ys)
|
||||
(msort zs)))))
|
||||
Loading…
Add table
Add a link
Reference in a new issue