aboutsummaryrefslogtreecommitdiff
path: root/flist.lisp
blob: 8e38395815ada1747ac27712f287919d49ebcbfa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
(in-package "ACL2")

(defun true-flistp (x)
  (if (endp x)
      (null x)
      (and (consp x)
           (true-flistp (car x)))))

(defun list-to-flist (x)
  (if (endp x)
      nil
      (cons (list-to-flist (cdr x))
            (car x))))

(defun flist-to-list (x)
  (if (endp x)
      nil
      (cons (cdr x)
            (flist-to-list (car x)))))

(defthm flist-to-list-to-flist
  (implies (true-flistp x)
           (equal (list-to-flist (flist-to-list x))
                  x)))

(defthm list-to-flist-to-list
  (implies (true-listp x)
           (equal (flist-to-list (list-to-flist x))
                  x)))


(defun fappend (x y)
  (if (endp x)
      y
      (cons (fappend (car x) y)
            (cdr x))))

(defthm assocativity-of-append
  (equal (fappend (fappend x y) z)
         (fappend x (fappend y z))))

(defthm fappend-append
  (implies (and (true-listp x)
                (true-listp y))
           (equal (flist-to-list (fappend (list-to-flist x)
                                          (list-to-flist y)))
                  (append x y))))