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
|
;; Cuong Chau <cuong.chau@arm.com>
;; March 2021
(in-package "RTL")
(include-book "normalize")
(local (arith-5-for-rtl))
;; ======================================================================
;; Define the normalized dividend x and normalized divisor d satisfying
;; 1 <= x < 2 and 1 <= d < 2.
(defundd x () (sig (a)))
(defundd d () (sig (b)))
(defthm x-bounds
(and (implies (not (specialp))
(<= 1 (x)))
(< (x) 2))
:hints (("Goal" :in-theory (enable x)))
:rule-classes :linear)
(defthm d-bounds
(and (implies (not (specialp))
(<= 1 (d)))
(< (d) 2))
:hints (("Goal" :in-theory (enable d)))
:rule-classes :linear)
(defthm natp-2^prec-1*x
(implies (not (specialp))
(natp (* (expt 2 (1- (prec (f))))
(x))))
:hints (("Goal"
:use ((:instance exactp-sig
(x (bits (opa) 9 0))
(n 10))
(:instance exactp-sig
(x (bits (opa) 22 0))
(n 23))
(:instance exactp-sig
(x (bits (opa) 51 0))
(n 52)))
:in-theory (e/d (specialp
a-class
f
x
a
opaz
opaw
fmtw
snanp
qnanp
nanp
infp
zerp
decode
sig-ndecode
normp
denormp
encodingp
pseudop
unsupp
exactp2
manf)
(exactp-sig))))
:rule-classes :type-prescription)
(defthm natp-2^prec-1*d
(implies (not (specialp))
(natp (* (expt 2 (1- (prec (f))))
(d))))
:hints (("Goal"
:use ((:instance exactp-sig
(x (bits (opb) 9 0))
(n 10))
(:instance exactp-sig
(x (bits (opb) 22 0))
(n 23))
(:instance exactp-sig
(x (bits (opb) 51 0))
(n 52)))
:in-theory (e/d (specialp
b-class
f
d
b
opbz
opbw
fmtw
snanp
qnanp
nanp
infp
zerp
decode
sig-ndecode
normp
denormp
encodingp
pseudop
unsupp
exactp2
manf)
(exactp-sig))))
:rule-classes :type-prescription)
(defthmd x57-rewrite
(implies (not (specialp))
(equal (x57)
(* *2^55* (x))))
:hints (("Goal"
:use siga-rewrite
:in-theory (enable x57 x cat bvecp))))
(defthm x57-bounds
(and (implies (not (specialp))
(<= *2^55* (x57)))
(< (x57) *2^56*))
:hints (("Goal"
:use x57-rewrite
:in-theory (enable x57 cat)))
:rule-classes :linear)
(bvecthm bvecp56-x57
(bvecp (x57) 56)
:hints (("Goal" :in-theory (enable bvecp))))
(defthmd d57-rewrite
(implies (not (specialp))
(equal (d57) (* *2^55* (d))))
:hints (("Goal"
:use sigb-rewrite
:in-theory (enable d57 d cat bvecp))))
(defthm d57-bounds
(and (implies (not (specialp))
(<= *2^55* (d57)))
(< (d57) *2^56*))
:hints (("Goal"
:use d57-rewrite
:in-theory (enable d57 cat)))
:rule-classes :linear)
(bvecthm bvecp56-d57
(bvecp (d57) 56)
:hints (("Goal" :in-theory (enable bvecp))))
;; Partial quotients
(defundd quotient (i)
(if (zp i)
0
(+ (quotient (1- i))
(* (expt 2 (- 1 i)) (q i)))))
(local (in-theory (enable quotient)))
;; Partial remainders
(defundd rmd (i)
(* (expt 2 (1- i))
(- (x) (* (d) (quotient i)))))
(defthmd rmd0-rewrite
(equal (rmd 0) (/ (x) 2))
:hints (("Goal" :in-theory (enable rmd))))
(defthm rmd0-bound
(implies (not (specialp))
(< (abs (rmd 0)) (d)))
:hints (("Goal" :in-theory (enable rmd0-rewrite)))
:rule-classes :linear)
(defthmd rmd-recurrence
(implies (posp j)
(equal (rmd j)
(- (* 2 (rmd (1- j)))
(* (q j) (d)))))
:hints (("Goal" :in-theory (enable rmd))))
(defthm q-bounds
(and (<= -1 (q j))
(<= (q j) 1))
:hints (("Goal"
:expand (q j)
:in-theory (enable nextdigit)))
:rule-classes :linear)
|