1
; Standard Association Lists Library
2
; Copyright (C) 2013-2014 Centaur Technology
5
; Centaur Technology Formal Verification Group
6
; 7600-C N. Capital of Texas Highway, Suite 300, Austin, TX 78731, USA.
7
; http://www.centtech.com/
9
; License: (An MIT/X11-style license)
11
; Permission is hereby granted, free of charge, to any person obtaining a
12
; copy of this software and associated documentation files (the "Software"),
13
; to deal in the Software without restriction, including without limitation
14
; the rights to use, copy, modify, merge, publish, distribute, sublicense,
15
; and/or sell copies of the Software, and to permit persons to whom the
16
; Software is furnished to do so, subject to the following conditions:
18
; The above copyright notice and this permission notice shall be included in
19
; all copies or substantial portions of the Software.
21
; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22
; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23
; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24
; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25
; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26
; FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27
; DEALINGS IN THE SOFTWARE.
29
; Original authors: Jared Davis <jared@centtech.com>
30
; Sol Swords <sswords@centtech.com>
33
(include-book "std/util/define" :dir :system)
34
(include-book "alist-equiv")
35
(include-book "worth-hashing")
36
(local (include-book "std/lists/sets" :dir :system))
37
(local (include-book "hons-assoc-equal"))
39
(define fal-all-boundp-fast (keys alist)
40
:parents (fal-all-boundp)
43
(and (hons-get (car keys) alist)
44
(fal-all-boundp-fast (cdr keys) alist))))
46
(define fal-all-boundp-slow (keys alist)
47
:parents (fal-all-boundp)
50
(and (hons-assoc-equal (car keys) alist)
51
(fal-all-boundp-slow (cdr keys) alist))))
53
(define fal-all-boundp (keys alist)
55
:short "@(call fal-all-boundp) determines if every key in @('keys') is bound
56
in the alist @('alist')."
57
:long "<p>The @('alist') need not be fast. If it is not fast, it may be made
58
temporarily fast, depending on its length.</p>"
60
(declare (xargs :guard t :verify-guards nil))
64
(and (hons-assoc-equal (car keys) alist)
65
(fal-all-boundp (cdr keys) alist)))
69
(if (and (worth-hashing keys)
70
(worth-hashing alist))
71
(with-fast-alist alist
72
(fal-all-boundp-fast keys alist))
73
(fal-all-boundp-slow keys alist))))
75
(defthm fal-all-boundp-fast-removal
76
(equal (fal-all-boundp-fast keys alist)
77
(fal-all-boundp keys alist))
78
:hints(("Goal" :in-theory (enable fal-all-boundp-fast))))
80
(defthm fal-all-boundp-slow-removal
81
(equal (fal-all-boundp-slow keys alist)
82
(fal-all-boundp keys alist))
83
:hints(("Goal" :in-theory (enable fal-all-boundp-slow))))
85
(verify-guards fal-all-boundp)
87
(defthm fal-all-boundp-when-atom
89
(equal (fal-all-boundp keys alist)
92
(defthm fal-all-boundp-of-cons
93
(equal (fal-all-boundp (cons a keys) alist)
94
(and (hons-get a alist)
95
(fal-all-boundp keys alist))))
100
(implies (and (fal-all-boundp y alist)
102
(hons-assoc-equal a alist))))
105
(implies (and (fal-all-boundp y alist)
107
(fal-all-boundp x alist))
108
:hints(("Goal" :induct (len x)))))
110
(defcong set-equiv equal (fal-all-boundp x alist) 1
111
:hints(("Goal" :in-theory (e/d (set-equiv)
113
:use ((:instance l1 (x x) (y x-equiv))
114
(:instance l1 (x x-equiv) (y x)))))))
116
(defcong alist-equiv equal (fal-all-boundp x alist) 2)
118
(defthm fal-all-boundp-of-list-fix
119
;; BOZO silly to prove this? Just a consequence of the set-equiv
120
(equal (fal-all-boundp (list-fix x) alist)
121
(fal-all-boundp x alist)))
123
(defthm fal-all-boundp-of-rev
124
;; BOZO silly to prove this? Just a consequence of the set-equiv
125
(equal (fal-all-boundp (rev x) alist)
126
(fal-all-boundp x alist)))
128
(defthm fal-all-boundp-of-append
129
(equal (fal-all-boundp (append x y) alist)
130
(and (fal-all-boundp x alist)
131
(fal-all-boundp y alist))))
133
(defthm fal-all-boundp-of-revappend
134
;; BOZO silly to prove this? Trivial via the set-equiv and append rules
135
(equal (fal-all-boundp (revappend x y) alist)
136
(and (fal-all-boundp x alist)
137
(fal-all-boundp y alist)))))
b'\\ No newline at end of file'