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 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216
|
;; Processing Unicode Files with ACL2
;; Copyright (C) 2005-2006 by Jared Davis <jared@cs.utexas.edu>
;;
;; This program is free software; you can redistribute it and/or modify it
;; under the terms of the GNU General Public License as published by the Free
;; Software Foundation; either version 2 of the License, or (at your option)
;; any later version.
;;
;; This program is distributed in the hope that it will be useful but WITHOUT
;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
;; more details.
;;
;; You should have received a copy of the GNU General Public License along with
;; this program; if not, write to the Free Software Foundation, Inc., 59 Temple
;; Place - Suite 330, Boston, MA 02111-1307, USA.
(in-package "ACL2")
(set-verify-guards-eagerness 2)
(include-book "take")
(include-book "nat-listp")
(local (include-book "repeat"))
(in-theory (disable unsigned-byte-p))
(defund unsigned-byte-listp (n x)
(if (atom x)
(null x)
(and (unsigned-byte-p n (car x))
(unsigned-byte-listp n (cdr x)))))
(defthm unsigned-byte-listp-when-not-consp
(implies (not (consp x))
(equal (unsigned-byte-listp n x)
(not x)))
:hints(("Goal" :in-theory (enable unsigned-byte-listp))))
(defthm unsigned-byte-listp-of-cons
(equal (unsigned-byte-listp n (cons a x))
(and (unsigned-byte-p n a)
(unsigned-byte-listp n x)))
:hints(("Goal" :in-theory (enable unsigned-byte-listp))))
(defthm unsigned-byte-p-of-car-when-unsigned-byte-listp
(implies (unsigned-byte-listp bytes x)
(equal (unsigned-byte-p bytes (car x))
(consp x)))
:rule-classes (:rewrite :forward-chaining))
(defthm nat-listp-when-unsigned-byte-listp
(implies (unsigned-byte-listp bytes x)
(nat-listp x))
:hints(("Goal" :induct (len x))))
(defthm true-listp-when-unsigned-byte-listp
(implies (unsigned-byte-listp bytes x)
(true-listp x))
:hints(("Goal" :induct (len x))))
(encapsulate
()
(local (include-book "ihs/logops-lemmas" :dir :system))
(local (in-theory (disable binary-logior
binary-logand
lognot
unsigned-byte-p)))
(local (in-theory (enable signed-byte-p-logops)))
(defthm unsigned-byte-p-logand
(implies (and (or (unsigned-byte-p size i)
(unsigned-byte-p size j))
(force (integerp i))
(force (integerp j)))
(unsigned-byte-p size (logand i j))))
(defthm unsigned-byte-p-logior
(implies (and (force (integerp i))
(force (integerp j)))
(equal (unsigned-byte-p size (logior i j))
(and (unsigned-byte-p size i)
(unsigned-byte-p size j))))))
(defthm decrement-positive-unsigned-byte
(implies (and (unsigned-byte-p n x)
(< 0 x))
(unsigned-byte-p n (1- x)))
:hints(("Goal" :in-theory (enable unsigned-byte-p))))
(encapsulate
()
(local (include-book "arithmetic-3/bind-free/top" :dir :system))
(local (include-book "arithmetic-3/floor-mod/floor-mod" :dir :system))
(local (set-default-hints
'((nonlinearp-default-hint stable-under-simplificationp
hist pspv))))
(local (defthm signed-byte-promote
(implies (and (signed-byte-p size1 x)
(integerp size2)
(<= size1 size2))
(signed-byte-p size2 x))))
(defthm unsigned-byte-promote
(implies (and (unsigned-byte-p size1 x)
(integerp size2)
(<= size1 size2))
(unsigned-byte-p size2 x))
:hints(("Goal" :in-theory (enable unsigned-byte-p))))
(local (defthm lemma
(implies (unsigned-byte-p a x)
(signed-byte-p (+ 1 a) x))
:hints(("Goal" :in-theory (enable unsigned-byte-p)))))
(defthm unsigned-to-signed-promote
(implies (and (unsigned-byte-p size1 x)
(integerp size2)
(< size1 size2))
(signed-byte-p size2 x))
:hints(("Goal"
:in-theory (enable unsigned-byte-p)
:use ((:instance lemma
(a size1))
(:instance signed-byte-promote
(size1 (+ 1 size1)))))))
(defthm unsigned-byte-p-of-ash
(implies (and (force (integerp x))
(force (integerp shift))
(force (integerp size))
(<= 0 size)
(< shift size))
(equal (unsigned-byte-p size (ash x shift))
(unsigned-byte-p (- size shift) x)))
:hints(("Goal" :in-theory (enable unsigned-byte-p))))
(defthmd signed-to-unsigned-promote
(implies (and (force (integerp n))
(force (integerp x))
(<= 0 x))
(equal (signed-byte-p n x)
(unsigned-byte-p (1- n) x)))
:hints(("Goal" :in-theory (enable unsigned-byte-p))))
(defthm ash-positive
(implies (and (integerp x)
(integerp n)
(<= 0 x))
(<= 0 (ash x n)))
:rule-classes ((:rewrite) (:linear)))
(defthm unsigned-byte-p-resolver
(implies (and (integerp n) (<= 0 n)
(integerp x) (<= 0 x)
(< x (expt 2 n)))
(unsigned-byte-p n x))
:hints(("Goal" :in-theory (enable unsigned-byte-p))))
)
(in-theory (disable ash))
(in-theory (disable binary-logior))
(in-theory (disable binary-logand))
(defthm unsigned-byte-listp-of-app
(equal (unsigned-byte-listp bytes (app x y))
(and (unsigned-byte-listp bytes (list-fix x))
(unsigned-byte-listp bytes (list-fix y))))
:hints(("Goal" :induct (len x))))
(defthm unsigned-byte-listp-of-list-fix-when-unsigned-byte-listp
(implies (unsigned-byte-listp bytes x)
(unsigned-byte-listp bytes (list-fix x))))
(local (defthm unsigned-byte-listp-of-repeat
(equal (unsigned-byte-listp bytes (repeat x n))
(or (zp n)
(unsigned-byte-p bytes x)))
:hints(("Goal" :in-theory (enable repeat)))))
(local (defthm lemma-for-arithmetic
(implies (not (zp n))
(equal (not (< 1 n))
(equal 1 n)))))
(defthm unsigned-byte-listp-of-simpler-take
(implies (unsigned-byte-listp bytes x)
(equal (unsigned-byte-listp bytes (simpler-take n x))
(or (zp n)
(<= n (len x)))))
:hints(("Goal" :in-theory (enable simpler-take))))
(defthm unsigned-byte-listp-of-simpler-take-past-length
(implies (and (natp k)
(< (len x) k))
(not (unsigned-byte-listp bytes (simpler-take k x)))))
(defthm unsigned-byte-listp-of-nthcdr
(implies (unsigned-byte-listp bytes x)
(unsigned-byte-listp bytes (nthcdr n x))))
(defthm unsigned-byte-listp-when-simpler-take-and-nthcdr
(implies (and (unsigned-byte-listp bytes (simpler-take n x))
(unsigned-byte-listp bytes (nthcdr n x)))
(unsigned-byte-listp bytes x)))
|