File: not-intersectp-list.lisp

package info (click to toggle)
acl2 8.5dfsg-5
  • links: PTS
  • area: main
  • in suites: bookworm
  • size: 991,452 kB
  • sloc: lisp: 15,567,759; javascript: 22,820; cpp: 13,929; ansic: 12,092; perl: 7,150; java: 4,405; xml: 3,884; makefile: 3,507; sh: 3,187; ruby: 2,633; ml: 763; python: 746; yacc: 723; awk: 295; csh: 186; php: 171; lex: 154; tcl: 49; asm: 23; haskell: 17
file content (90 lines) | stat: -rw-r--r-- 3,227 bytes parent folder | download | duplicates (3)
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
(in-package "ACL2")

;  not-intersectp-list.lisp                             Mihir Mehta

(include-book "../file-system-lemmas")
(include-book "std/lists/flatten" :dir :system)

(defthm no-duplicatesp-of-member
  (implies (and (not (no-duplicatesp x))
                (no-duplicatesp (flatten lst)))
           (not (member-equal x lst))))

(defthm len-of-flatten-of-update-nth
  (equal (len (flatten (update-nth key val l)))
         (- (+ (len (flatten l)) (len val))
            (len (nth key l))))
  :hints (("goal" :induct (update-nth key val l))))

(defund not-intersectp-list (x l)
  (declare (xargs :guard (and (true-listp x) (true-list-listp l))))
  (or (atom l)
      (and (not (intersectp-equal x (car l)))
           (not-intersectp-list x (cdr l)))))

(defcong list-equiv equal (not-intersectp-list x l) 1
  :hints (("Goal" :in-theory (enable not-intersectp-list))))

(defthm not-intersectp-list-correctness-1
  (equal (intersectp-equal x (flatten l))
         (not (not-intersectp-list x l)))
  :hints (("Goal" :in-theory (enable not-intersectp-list))))

(defthmd not-intersectp-list-correctness-2
  (implies (and (not-intersectp-list x l)
                (member-equal y l))
           (not (intersectp-equal x y)))
  :hints (("Goal" :in-theory (enable not-intersectp-list))))

(defthm not-intersectp-list-of-append-1
  (equal (not-intersectp-list x (binary-append l1 l2))
         (and (not-intersectp-list x l1)
              (not-intersectp-list x l2)))
  :hints (("Goal" :in-theory (enable not-intersectp-list))))

(defthm not-intersectp-list-when-atom
  (implies (atom x) (not-intersectp-list x l))
  :hints (("Goal" :in-theory (enable not-intersectp-list))))

(defthm not-intersectp-list-when-subsetp-1
  (implies (and (not-intersectp-list y l)
                (subsetp-equal x y))
           (not-intersectp-list x l))
  :hints (("Goal" :in-theory (enable not-intersectp-list))))

(defthm not-intersectp-list-when-subsetp-2
  (implies (and (not-intersectp-list x l2)
                (subsetp-equal l1 l2))
           (not-intersectp-list x l1))
  :hints (("Goal" :in-theory (enable not-intersectp-list))))

(defthm not-intersectp-list-of-true-list-fix
  (equal (not-intersectp-list x (true-list-fix l))
         (not-intersectp-list x l))
  :hints (("Goal" :in-theory (enable not-intersectp-list))))

(defthm
  flatten-subset-no-duplicatesp-lemma-1
  (implies (and (no-duplicatesp (flatten z))
                (consp z)
                (member-equal x z)
                (member-equal y z)
                (not (equal y x)))
           (not (intersectp-equal x y)))
  :hints (("Goal" :in-theory (enable not-intersectp-list))))

(local
 (defthm flatten-subset-no-duplicatesp-lemma-3
   (implies (and (member-equal z y)
                 (not (member-equal z x))
                 (subsetp-equal x y)
                 (no-duplicatesp-equal (flatten y)))
            (not-intersectp-list z x))
   :hints (("Goal" :in-theory (enable not-intersectp-list)))))

;; This is, sort of, the main lemma.
(defthm flatten-subset-no-duplicatesp
  (implies (and (subsetp-equal x y)
                (no-duplicatesp-equal (flatten y))
                (no-duplicatesp-equal x))
           (no-duplicatesp-equal (flatten x))))