15647
|
1 |
(* AUTOMATICALLY GENERATED, DO NOT EDIT! *)
|
|
2 |
|
17566
|
3 |
theory HOL4Word32 imports HOL4Base begin
|
14516
|
4 |
|
|
5 |
;setup_theory bits
|
|
6 |
|
|
7 |
consts
|
|
8 |
DIV2 :: "nat => nat"
|
|
9 |
|
|
10 |
defs
|
|
11 |
DIV2_primdef: "DIV2 == %n. n div 2"
|
|
12 |
|
|
13 |
lemma DIV2_def: "ALL n. DIV2 n = n div 2"
|
|
14 |
by (import bits DIV2_def)
|
|
15 |
|
|
16 |
consts
|
|
17 |
TIMES_2EXP :: "nat => nat => nat"
|
|
18 |
|
|
19 |
defs
|
|
20 |
TIMES_2EXP_primdef: "TIMES_2EXP == %x n. n * 2 ^ x"
|
|
21 |
|
|
22 |
lemma TIMES_2EXP_def: "ALL x n. TIMES_2EXP x n = n * 2 ^ x"
|
|
23 |
by (import bits TIMES_2EXP_def)
|
|
24 |
|
|
25 |
consts
|
|
26 |
DIV_2EXP :: "nat => nat => nat"
|
|
27 |
|
|
28 |
defs
|
|
29 |
DIV_2EXP_primdef: "DIV_2EXP == %x n. n div 2 ^ x"
|
|
30 |
|
|
31 |
lemma DIV_2EXP_def: "ALL x n. DIV_2EXP x n = n div 2 ^ x"
|
|
32 |
by (import bits DIV_2EXP_def)
|
|
33 |
|
|
34 |
consts
|
|
35 |
MOD_2EXP :: "nat => nat => nat"
|
|
36 |
|
|
37 |
defs
|
|
38 |
MOD_2EXP_primdef: "MOD_2EXP == %x n. n mod 2 ^ x"
|
|
39 |
|
|
40 |
lemma MOD_2EXP_def: "ALL x n. MOD_2EXP x n = n mod 2 ^ x"
|
|
41 |
by (import bits MOD_2EXP_def)
|
|
42 |
|
|
43 |
consts
|
|
44 |
DIVMOD_2EXP :: "nat => nat => nat * nat"
|
|
45 |
|
|
46 |
defs
|
|
47 |
DIVMOD_2EXP_primdef: "DIVMOD_2EXP == %x n. (n div 2 ^ x, n mod 2 ^ x)"
|
|
48 |
|
|
49 |
lemma DIVMOD_2EXP_def: "ALL x n. DIVMOD_2EXP x n = (n div 2 ^ x, n mod 2 ^ x)"
|
|
50 |
by (import bits DIVMOD_2EXP_def)
|
|
51 |
|
|
52 |
consts
|
|
53 |
SBIT :: "bool => nat => nat"
|
|
54 |
|
|
55 |
defs
|
|
56 |
SBIT_primdef: "SBIT == %b n. if b then 2 ^ n else 0"
|
|
57 |
|
|
58 |
lemma SBIT_def: "ALL b n. SBIT b n = (if b then 2 ^ n else 0)"
|
|
59 |
by (import bits SBIT_def)
|
|
60 |
|
|
61 |
consts
|
|
62 |
BITS :: "nat => nat => nat => nat"
|
|
63 |
|
|
64 |
defs
|
|
65 |
BITS_primdef: "BITS == %h l n. MOD_2EXP (Suc h - l) (DIV_2EXP l n)"
|
|
66 |
|
|
67 |
lemma BITS_def: "ALL h l n. BITS h l n = MOD_2EXP (Suc h - l) (DIV_2EXP l n)"
|
|
68 |
by (import bits BITS_def)
|
|
69 |
|
|
70 |
constdefs
|
|
71 |
bit :: "nat => nat => bool"
|
|
72 |
"bit == %b n. BITS b b n = 1"
|
|
73 |
|
|
74 |
lemma BIT_def: "ALL b n. bit b n = (BITS b b n = 1)"
|
|
75 |
by (import bits BIT_def)
|
|
76 |
|
|
77 |
consts
|
|
78 |
SLICE :: "nat => nat => nat => nat"
|
|
79 |
|
|
80 |
defs
|
|
81 |
SLICE_primdef: "SLICE == %h l n. MOD_2EXP (Suc h) n - MOD_2EXP l n"
|
|
82 |
|
|
83 |
lemma SLICE_def: "ALL h l n. SLICE h l n = MOD_2EXP (Suc h) n - MOD_2EXP l n"
|
|
84 |
by (import bits SLICE_def)
|
|
85 |
|
|
86 |
consts
|
|
87 |
LSBn :: "nat => bool"
|
|
88 |
|
|
89 |
defs
|
|
90 |
LSBn_primdef: "LSBn == bit 0"
|
|
91 |
|
|
92 |
lemma LSBn_def: "LSBn = bit 0"
|
|
93 |
by (import bits LSBn_def)
|
|
94 |
|
|
95 |
consts
|
|
96 |
BITWISE :: "nat => (bool => bool => bool) => nat => nat => nat"
|
|
97 |
|
|
98 |
specification (BITWISE_primdef: BITWISE) BITWISE_def: "(ALL oper x y. BITWISE 0 oper x y = 0) &
|
|
99 |
(ALL n oper x y.
|
|
100 |
BITWISE (Suc n) oper x y =
|
|
101 |
BITWISE n oper x y + SBIT (oper (bit n x) (bit n y)) n)"
|
|
102 |
by (import bits BITWISE_def)
|
|
103 |
|
|
104 |
lemma DIV1: "ALL x::nat. x div (1::nat) = x"
|
|
105 |
by (import bits DIV1)
|
|
106 |
|
|
107 |
lemma SUC_SUB: "Suc a - a = 1"
|
|
108 |
by (import bits SUC_SUB)
|
|
109 |
|
|
110 |
lemma DIV_MULT_1: "ALL (r::nat) n::nat. r < n --> (n + r) div n = (1::nat)"
|
|
111 |
by (import bits DIV_MULT_1)
|
|
112 |
|
|
113 |
lemma ZERO_LT_TWOEXP: "ALL n::nat. (0::nat) < (2::nat) ^ n"
|
|
114 |
by (import bits ZERO_LT_TWOEXP)
|
|
115 |
|
|
116 |
lemma MOD_2EXP_LT: "ALL (n::nat) k::nat. k mod (2::nat) ^ n < (2::nat) ^ n"
|
|
117 |
by (import bits MOD_2EXP_LT)
|
|
118 |
|
|
119 |
lemma TWOEXP_DIVISION: "ALL (n::nat) k::nat.
|
|
120 |
k = k div (2::nat) ^ n * (2::nat) ^ n + k mod (2::nat) ^ n"
|
|
121 |
by (import bits TWOEXP_DIVISION)
|
|
122 |
|
|
123 |
lemma TWOEXP_MONO: "ALL (a::nat) b::nat. a < b --> (2::nat) ^ a < (2::nat) ^ b"
|
|
124 |
by (import bits TWOEXP_MONO)
|
|
125 |
|
|
126 |
lemma TWOEXP_MONO2: "ALL (a::nat) b::nat. a <= b --> (2::nat) ^ a <= (2::nat) ^ b"
|
|
127 |
by (import bits TWOEXP_MONO2)
|
|
128 |
|
|
129 |
lemma EXP_SUB_LESS_EQ: "ALL (a::nat) b::nat. (2::nat) ^ (a - b) <= (2::nat) ^ a"
|
|
130 |
by (import bits EXP_SUB_LESS_EQ)
|
|
131 |
|
|
132 |
lemma BITS_THM: "ALL x xa xb. BITS x xa xb = xb div 2 ^ xa mod 2 ^ (Suc x - xa)"
|
|
133 |
by (import bits BITS_THM)
|
|
134 |
|
|
135 |
lemma BITSLT_THM: "ALL h l n. BITS h l n < 2 ^ (Suc h - l)"
|
|
136 |
by (import bits BITSLT_THM)
|
|
137 |
|
|
138 |
lemma DIV_MULT_LEM: "ALL (m::nat) n::nat. (0::nat) < n --> m div n * n <= m"
|
|
139 |
by (import bits DIV_MULT_LEM)
|
|
140 |
|
|
141 |
lemma MOD_2EXP_LEM: "ALL (n::nat) x::nat.
|
|
142 |
n mod (2::nat) ^ x = n - n div (2::nat) ^ x * (2::nat) ^ x"
|
|
143 |
by (import bits MOD_2EXP_LEM)
|
|
144 |
|
|
145 |
lemma BITS2_THM: "ALL h l n. BITS h l n = n mod 2 ^ Suc h div 2 ^ l"
|
|
146 |
by (import bits BITS2_THM)
|
|
147 |
|
|
148 |
lemma BITS_COMP_THM: "ALL h1 l1 h2 l2 n.
|
|
149 |
h2 + l1 <= h1 --> BITS h2 l2 (BITS h1 l1 n) = BITS (h2 + l1) (l2 + l1) n"
|
|
150 |
by (import bits BITS_COMP_THM)
|
|
151 |
|
|
152 |
lemma BITS_DIV_THM: "ALL h l x n. BITS h l x div 2 ^ n = BITS h (l + n) x"
|
|
153 |
by (import bits BITS_DIV_THM)
|
|
154 |
|
|
155 |
lemma BITS_LT_HIGH: "ALL h l n. n < 2 ^ Suc h --> BITS h l n = n div 2 ^ l"
|
|
156 |
by (import bits BITS_LT_HIGH)
|
|
157 |
|
|
158 |
lemma BITS_ZERO: "ALL h l n. h < l --> BITS h l n = 0"
|
|
159 |
by (import bits BITS_ZERO)
|
|
160 |
|
|
161 |
lemma BITS_ZERO2: "ALL h l. BITS h l 0 = 0"
|
|
162 |
by (import bits BITS_ZERO2)
|
|
163 |
|
|
164 |
lemma BITS_ZERO3: "ALL h x. BITS h 0 x = x mod 2 ^ Suc h"
|
|
165 |
by (import bits BITS_ZERO3)
|
|
166 |
|
|
167 |
lemma BITS_COMP_THM2: "ALL h1 l1 h2 l2 n.
|
|
168 |
BITS h2 l2 (BITS h1 l1 n) = BITS (min h1 (h2 + l1)) (l2 + l1) n"
|
|
169 |
by (import bits BITS_COMP_THM2)
|
|
170 |
|
|
171 |
lemma NOT_MOD2_LEM: "ALL n::nat. (n mod (2::nat) ~= (0::nat)) = (n mod (2::nat) = (1::nat))"
|
|
172 |
by (import bits NOT_MOD2_LEM)
|
|
173 |
|
|
174 |
lemma NOT_MOD2_LEM2: "ALL (n::nat) a::'a.
|
|
175 |
(n mod (2::nat) ~= (1::nat)) = (n mod (2::nat) = (0::nat))"
|
|
176 |
by (import bits NOT_MOD2_LEM2)
|
|
177 |
|
|
178 |
lemma EVEN_MOD2_LEM: "ALL n. EVEN n = (n mod 2 = 0)"
|
|
179 |
by (import bits EVEN_MOD2_LEM)
|
|
180 |
|
|
181 |
lemma ODD_MOD2_LEM: "ALL n. ODD n = (n mod 2 = 1)"
|
|
182 |
by (import bits ODD_MOD2_LEM)
|
|
183 |
|
|
184 |
lemma LSB_ODD: "LSBn = ODD"
|
|
185 |
by (import bits LSB_ODD)
|
|
186 |
|
|
187 |
lemma DIV_MULT_THM: "ALL (x::nat) n::nat.
|
|
188 |
n div (2::nat) ^ x * (2::nat) ^ x = n - n mod (2::nat) ^ x"
|
|
189 |
by (import bits DIV_MULT_THM)
|
|
190 |
|
|
191 |
lemma DIV_MULT_THM2: "ALL x::nat. (2::nat) * (x div (2::nat)) = x - x mod (2::nat)"
|
|
192 |
by (import bits DIV_MULT_THM2)
|
|
193 |
|
|
194 |
lemma LESS_EQ_EXP_MULT: "ALL (a::nat) b::nat. a <= b --> (EX x::nat. (2::nat) ^ b = x * (2::nat) ^ a)"
|
|
195 |
by (import bits LESS_EQ_EXP_MULT)
|
|
196 |
|
|
197 |
lemma SLICE_LEM1: "ALL (a::nat) (x::nat) y::nat.
|
|
198 |
a div (2::nat) ^ (x + y) * (2::nat) ^ (x + y) =
|
|
199 |
a div (2::nat) ^ x * (2::nat) ^ x -
|
|
200 |
a div (2::nat) ^ x mod (2::nat) ^ y * (2::nat) ^ x"
|
|
201 |
by (import bits SLICE_LEM1)
|
|
202 |
|
|
203 |
lemma SLICE_LEM2: "ALL (a::'a) (x::nat) y::nat.
|
|
204 |
(n::nat) mod (2::nat) ^ (x + y) =
|
|
205 |
n mod (2::nat) ^ x + n div (2::nat) ^ x mod (2::nat) ^ y * (2::nat) ^ x"
|
|
206 |
by (import bits SLICE_LEM2)
|
|
207 |
|
|
208 |
lemma SLICE_LEM3: "ALL (n::nat) (h::nat) l::nat.
|
|
209 |
l < h --> n mod (2::nat) ^ Suc l <= n mod (2::nat) ^ h"
|
|
210 |
by (import bits SLICE_LEM3)
|
|
211 |
|
|
212 |
lemma SLICE_THM: "ALL n h l. SLICE h l n = BITS h l n * 2 ^ l"
|
|
213 |
by (import bits SLICE_THM)
|
|
214 |
|
|
215 |
lemma SLICELT_THM: "ALL h l n. SLICE h l n < 2 ^ Suc h"
|
|
216 |
by (import bits SLICELT_THM)
|
|
217 |
|
|
218 |
lemma BITS_SLICE_THM: "ALL h l n. BITS h l (SLICE h l n) = BITS h l n"
|
|
219 |
by (import bits BITS_SLICE_THM)
|
|
220 |
|
|
221 |
lemma BITS_SLICE_THM2: "ALL h l n. h <= h2 --> BITS h2 l (SLICE h l n) = BITS h l n"
|
|
222 |
by (import bits BITS_SLICE_THM2)
|
|
223 |
|
|
224 |
lemma MOD_2EXP_MONO: "ALL (n::nat) (h::nat) l::nat.
|
|
225 |
l <= h --> n mod (2::nat) ^ l <= n mod (2::nat) ^ Suc h"
|
|
226 |
by (import bits MOD_2EXP_MONO)
|
|
227 |
|
|
228 |
lemma SLICE_COMP_THM: "ALL h m l n.
|
|
229 |
Suc m <= h & l <= m --> SLICE h (Suc m) n + SLICE m l n = SLICE h l n"
|
|
230 |
by (import bits SLICE_COMP_THM)
|
|
231 |
|
|
232 |
lemma SLICE_ZERO: "ALL h l n. h < l --> SLICE h l n = 0"
|
|
233 |
by (import bits SLICE_ZERO)
|
|
234 |
|
|
235 |
lemma BIT_COMP_THM3: "ALL h m l n.
|
|
236 |
Suc m <= h & l <= m -->
|
|
237 |
BITS h (Suc m) n * 2 ^ (Suc m - l) + BITS m l n = BITS h l n"
|
|
238 |
by (import bits BIT_COMP_THM3)
|
|
239 |
|
|
240 |
lemma NOT_BIT: "ALL n a. (~ bit n a) = (BITS n n a = 0)"
|
|
241 |
by (import bits NOT_BIT)
|
|
242 |
|
|
243 |
lemma NOT_BITS: "ALL n a. (BITS n n a ~= 0) = (BITS n n a = 1)"
|
|
244 |
by (import bits NOT_BITS)
|
|
245 |
|
|
246 |
lemma NOT_BITS2: "ALL n a. (BITS n n a ~= 1) = (BITS n n a = 0)"
|
|
247 |
by (import bits NOT_BITS2)
|
|
248 |
|
|
249 |
lemma BIT_SLICE: "ALL n a b. (bit n a = bit n b) = (SLICE n n a = SLICE n n b)"
|
|
250 |
by (import bits BIT_SLICE)
|
|
251 |
|
|
252 |
lemma BIT_SLICE_LEM: "ALL y x n. SBIT (bit x n) (x + y) = SLICE x x n * 2 ^ y"
|
|
253 |
by (import bits BIT_SLICE_LEM)
|
|
254 |
|
|
255 |
lemma BIT_SLICE_THM: "ALL x xa. SBIT (bit x xa) x = SLICE x x xa"
|
|
256 |
by (import bits BIT_SLICE_THM)
|
|
257 |
|
|
258 |
lemma SBIT_DIV: "ALL b m n. n < m --> SBIT b (m - n) = SBIT b m div 2 ^ n"
|
|
259 |
by (import bits SBIT_DIV)
|
|
260 |
|
|
261 |
lemma BITS_SUC: "ALL h l n.
|
|
262 |
l <= Suc h -->
|
|
263 |
SBIT (bit (Suc h) n) (Suc h - l) + BITS h l n = BITS (Suc h) l n"
|
|
264 |
by (import bits BITS_SUC)
|
|
265 |
|
|
266 |
lemma BITS_SUC_THM: "ALL h l n.
|
|
267 |
BITS (Suc h) l n =
|
|
268 |
(if Suc h < l then 0 else SBIT (bit (Suc h) n) (Suc h - l) + BITS h l n)"
|
|
269 |
by (import bits BITS_SUC_THM)
|
|
270 |
|
|
271 |
lemma BIT_BITS_THM: "ALL h l a b.
|
|
272 |
(ALL x. l <= x & x <= h --> bit x a = bit x b) =
|
|
273 |
(BITS h l a = BITS h l b)"
|
|
274 |
by (import bits BIT_BITS_THM)
|
|
275 |
|
|
276 |
lemma BITWISE_LT_2EXP: "ALL n oper a b. BITWISE n oper a b < 2 ^ n"
|
|
277 |
by (import bits BITWISE_LT_2EXP)
|
|
278 |
|
|
279 |
lemma LESS_EXP_MULT2: "ALL (a::nat) b::nat.
|
|
280 |
a < b -->
|
|
281 |
(EX x::nat. (2::nat) ^ b = (2::nat) ^ (x + (1::nat)) * (2::nat) ^ a)"
|
|
282 |
by (import bits LESS_EXP_MULT2)
|
|
283 |
|
|
284 |
lemma BITWISE_THM: "ALL x n oper a b.
|
|
285 |
x < n --> bit x (BITWISE n oper a b) = oper (bit x a) (bit x b)"
|
|
286 |
by (import bits BITWISE_THM)
|
|
287 |
|
|
288 |
lemma BITWISE_COR: "ALL x n oper a b.
|
|
289 |
x < n -->
|
|
290 |
oper (bit x a) (bit x b) --> BITWISE n oper a b div 2 ^ x mod 2 = 1"
|
|
291 |
by (import bits BITWISE_COR)
|
|
292 |
|
|
293 |
lemma BITWISE_NOT_COR: "ALL x n oper a b.
|
|
294 |
x < n -->
|
|
295 |
~ oper (bit x a) (bit x b) --> BITWISE n oper a b div 2 ^ x mod 2 = 0"
|
|
296 |
by (import bits BITWISE_NOT_COR)
|
|
297 |
|
15647
|
298 |
lemma MOD_PLUS_RIGHT: "ALL n>0::nat. ALL (j::nat) k::nat. (j + k mod n) mod n = (j + k) mod n"
|
14516
|
299 |
by (import bits MOD_PLUS_RIGHT)
|
|
300 |
|
15647
|
301 |
lemma MOD_PLUS_1: "ALL n>0::nat.
|
|
302 |
ALL x::nat. ((x + (1::nat)) mod n = (0::nat)) = (x mod n + (1::nat) = n)"
|
14516
|
303 |
by (import bits MOD_PLUS_1)
|
|
304 |
|
15647
|
305 |
lemma MOD_ADD_1: "ALL n>0::nat.
|
|
306 |
ALL x::nat.
|
|
307 |
(x + (1::nat)) mod n ~= (0::nat) -->
|
|
308 |
(x + (1::nat)) mod n = x mod n + (1::nat)"
|
14516
|
309 |
by (import bits MOD_ADD_1)
|
|
310 |
|
|
311 |
;end_setup
|
|
312 |
|
|
313 |
;setup_theory word32
|
|
314 |
|
|
315 |
consts
|
|
316 |
HB :: "nat"
|
|
317 |
|
|
318 |
defs
|
|
319 |
HB_primdef: "HB ==
|
|
320 |
NUMERAL
|
|
321 |
(NUMERAL_BIT1
|
|
322 |
(NUMERAL_BIT1 (NUMERAL_BIT1 (NUMERAL_BIT1 (NUMERAL_BIT1 ALT_ZERO)))))"
|
|
323 |
|
|
324 |
lemma HB_def: "HB =
|
|
325 |
NUMERAL
|
|
326 |
(NUMERAL_BIT1
|
|
327 |
(NUMERAL_BIT1 (NUMERAL_BIT1 (NUMERAL_BIT1 (NUMERAL_BIT1 ALT_ZERO)))))"
|
|
328 |
by (import word32 HB_def)
|
|
329 |
|
|
330 |
consts
|
|
331 |
WL :: "nat"
|
|
332 |
|
|
333 |
defs
|
|
334 |
WL_primdef: "WL == Suc HB"
|
|
335 |
|
|
336 |
lemma WL_def: "WL = Suc HB"
|
|
337 |
by (import word32 WL_def)
|
|
338 |
|
|
339 |
consts
|
|
340 |
MODw :: "nat => nat"
|
|
341 |
|
|
342 |
defs
|
|
343 |
MODw_primdef: "MODw == %n. n mod 2 ^ WL"
|
|
344 |
|
|
345 |
lemma MODw_def: "ALL n. MODw n = n mod 2 ^ WL"
|
|
346 |
by (import word32 MODw_def)
|
|
347 |
|
|
348 |
consts
|
|
349 |
INw :: "nat => bool"
|
|
350 |
|
|
351 |
defs
|
|
352 |
INw_primdef: "INw == %n. n < 2 ^ WL"
|
|
353 |
|
|
354 |
lemma INw_def: "ALL n. INw n = (n < 2 ^ WL)"
|
|
355 |
by (import word32 INw_def)
|
|
356 |
|
|
357 |
consts
|
|
358 |
EQUIV :: "nat => nat => bool"
|
|
359 |
|
|
360 |
defs
|
|
361 |
EQUIV_primdef: "EQUIV == %x y. MODw x = MODw y"
|
|
362 |
|
|
363 |
lemma EQUIV_def: "ALL x y. EQUIV x y = (MODw x = MODw y)"
|
|
364 |
by (import word32 EQUIV_def)
|
|
365 |
|
|
366 |
lemma EQUIV_QT: "ALL x y. EQUIV x y = (EQUIV x = EQUIV y)"
|
|
367 |
by (import word32 EQUIV_QT)
|
|
368 |
|
|
369 |
lemma FUNPOW_THM: "ALL f n x. (f ^ n) (f x) = f ((f ^ n) x)"
|
|
370 |
by (import word32 FUNPOW_THM)
|
|
371 |
|
|
372 |
lemma FUNPOW_THM2: "ALL f n x. (f ^ Suc n) x = f ((f ^ n) x)"
|
|
373 |
by (import word32 FUNPOW_THM2)
|
|
374 |
|
|
375 |
lemma FUNPOW_COMP: "ALL f m n a. (f ^ m) ((f ^ n) a) = (f ^ (m + n)) a"
|
|
376 |
by (import word32 FUNPOW_COMP)
|
|
377 |
|
|
378 |
lemma INw_MODw: "ALL n. INw (MODw n)"
|
|
379 |
by (import word32 INw_MODw)
|
|
380 |
|
|
381 |
lemma TOw_IDEM: "ALL a. INw a --> MODw a = a"
|
|
382 |
by (import word32 TOw_IDEM)
|
|
383 |
|
|
384 |
lemma MODw_IDEM2: "ALL a. MODw (MODw a) = MODw a"
|
|
385 |
by (import word32 MODw_IDEM2)
|
|
386 |
|
|
387 |
lemma TOw_QT: "ALL a. EQUIV (MODw a) a"
|
|
388 |
by (import word32 TOw_QT)
|
|
389 |
|
|
390 |
lemma MODw_THM: "MODw = BITS HB 0"
|
|
391 |
by (import word32 MODw_THM)
|
|
392 |
|
|
393 |
lemma MOD_ADD: "ALL a b. MODw (a + b) = MODw (MODw a + MODw b)"
|
|
394 |
by (import word32 MOD_ADD)
|
|
395 |
|
|
396 |
lemma MODw_MULT: "ALL a b. MODw (a * b) = MODw (MODw a * MODw b)"
|
|
397 |
by (import word32 MODw_MULT)
|
|
398 |
|
|
399 |
consts
|
|
400 |
AONE :: "nat"
|
|
401 |
|
|
402 |
defs
|
|
403 |
AONE_primdef: "AONE == 1"
|
|
404 |
|
|
405 |
lemma AONE_def: "AONE = 1"
|
|
406 |
by (import word32 AONE_def)
|
|
407 |
|
|
408 |
lemma ADD_QT: "(ALL n. EQUIV (0 + n) n) & (ALL m n. EQUIV (Suc m + n) (Suc (m + n)))"
|
|
409 |
by (import word32 ADD_QT)
|
|
410 |
|
|
411 |
lemma ADD_0_QT: "ALL a. EQUIV (a + 0) a"
|
|
412 |
by (import word32 ADD_0_QT)
|
|
413 |
|
|
414 |
lemma ADD_COMM_QT: "ALL a b. EQUIV (a + b) (b + a)"
|
|
415 |
by (import word32 ADD_COMM_QT)
|
|
416 |
|
|
417 |
lemma ADD_ASSOC_QT: "ALL a b c. EQUIV (a + (b + c)) (a + b + c)"
|
|
418 |
by (import word32 ADD_ASSOC_QT)
|
|
419 |
|
|
420 |
lemma MULT_QT: "(ALL n. EQUIV (0 * n) 0) & (ALL m n. EQUIV (Suc m * n) (m * n + n))"
|
|
421 |
by (import word32 MULT_QT)
|
|
422 |
|
|
423 |
lemma ADD1_QT: "ALL m. EQUIV (Suc m) (m + AONE)"
|
|
424 |
by (import word32 ADD1_QT)
|
|
425 |
|
|
426 |
lemma ADD_CLAUSES_QT: "(ALL m. EQUIV (0 + m) m) &
|
|
427 |
(ALL m. EQUIV (m + 0) m) &
|
|
428 |
(ALL m n. EQUIV (Suc m + n) (Suc (m + n))) &
|
|
429 |
(ALL m n. EQUIV (m + Suc n) (Suc (m + n)))"
|
|
430 |
by (import word32 ADD_CLAUSES_QT)
|
|
431 |
|
|
432 |
lemma SUC_EQUIV_COMP: "ALL a b. EQUIV (Suc a) b --> EQUIV a (b + (2 ^ WL - 1))"
|
|
433 |
by (import word32 SUC_EQUIV_COMP)
|
|
434 |
|
|
435 |
lemma INV_SUC_EQ_QT: "ALL m n. EQUIV (Suc m) (Suc n) = EQUIV m n"
|
|
436 |
by (import word32 INV_SUC_EQ_QT)
|
|
437 |
|
|
438 |
lemma ADD_INV_0_QT: "ALL m n. EQUIV (m + n) m --> EQUIV n 0"
|
|
439 |
by (import word32 ADD_INV_0_QT)
|
|
440 |
|
|
441 |
lemma ADD_INV_0_EQ_QT: "ALL m n. EQUIV (m + n) m = EQUIV n 0"
|
|
442 |
by (import word32 ADD_INV_0_EQ_QT)
|
|
443 |
|
|
444 |
lemma EQ_ADD_LCANCEL_QT: "ALL m n p. EQUIV (m + n) (m + p) = EQUIV n p"
|
|
445 |
by (import word32 EQ_ADD_LCANCEL_QT)
|
|
446 |
|
|
447 |
lemma EQ_ADD_RCANCEL_QT: "ALL x xa xb. EQUIV (x + xb) (xa + xb) = EQUIV x xa"
|
|
448 |
by (import word32 EQ_ADD_RCANCEL_QT)
|
|
449 |
|
|
450 |
lemma LEFT_ADD_DISTRIB_QT: "ALL m n p. EQUIV (p * (m + n)) (p * m + p * n)"
|
|
451 |
by (import word32 LEFT_ADD_DISTRIB_QT)
|
|
452 |
|
|
453 |
lemma MULT_ASSOC_QT: "ALL m n p. EQUIV (m * (n * p)) (m * n * p)"
|
|
454 |
by (import word32 MULT_ASSOC_QT)
|
|
455 |
|
|
456 |
lemma MULT_COMM_QT: "ALL m n. EQUIV (m * n) (n * m)"
|
|
457 |
by (import word32 MULT_COMM_QT)
|
|
458 |
|
|
459 |
lemma MULT_CLAUSES_QT: "ALL m n.
|
|
460 |
EQUIV (0 * m) 0 &
|
|
461 |
EQUIV (m * 0) 0 &
|
|
462 |
EQUIV (AONE * m) m &
|
|
463 |
EQUIV (m * AONE) m &
|
|
464 |
EQUIV (Suc m * n) (m * n + n) & EQUIV (m * Suc n) (m + m * n)"
|
|
465 |
by (import word32 MULT_CLAUSES_QT)
|
|
466 |
|
|
467 |
consts
|
|
468 |
MSBn :: "nat => bool"
|
|
469 |
|
|
470 |
defs
|
|
471 |
MSBn_primdef: "MSBn == bit HB"
|
|
472 |
|
|
473 |
lemma MSBn_def: "MSBn = bit HB"
|
|
474 |
by (import word32 MSBn_def)
|
|
475 |
|
|
476 |
consts
|
|
477 |
ONE_COMP :: "nat => nat"
|
|
478 |
|
|
479 |
defs
|
|
480 |
ONE_COMP_primdef: "ONE_COMP == %x. 2 ^ WL - 1 - MODw x"
|
|
481 |
|
|
482 |
lemma ONE_COMP_def: "ALL x. ONE_COMP x = 2 ^ WL - 1 - MODw x"
|
|
483 |
by (import word32 ONE_COMP_def)
|
|
484 |
|
|
485 |
consts
|
|
486 |
TWO_COMP :: "nat => nat"
|
|
487 |
|
|
488 |
defs
|
|
489 |
TWO_COMP_primdef: "TWO_COMP == %x. 2 ^ WL - MODw x"
|
|
490 |
|
|
491 |
lemma TWO_COMP_def: "ALL x. TWO_COMP x = 2 ^ WL - MODw x"
|
|
492 |
by (import word32 TWO_COMP_def)
|
|
493 |
|
|
494 |
lemma ADD_TWO_COMP_QT: "ALL a. EQUIV (MODw a + TWO_COMP a) 0"
|
|
495 |
by (import word32 ADD_TWO_COMP_QT)
|
|
496 |
|
|
497 |
lemma TWO_COMP_ONE_COMP_QT: "ALL a. EQUIV (TWO_COMP a) (ONE_COMP a + AONE)"
|
|
498 |
by (import word32 TWO_COMP_ONE_COMP_QT)
|
|
499 |
|
14847
|
500 |
lemma BIT_EQUIV_THM: "(All::(nat => bool) => bool)
|
|
501 |
(%x::nat.
|
|
502 |
(All::(nat => bool) => bool)
|
|
503 |
(%xa::nat.
|
|
504 |
(op =::bool => bool => bool)
|
|
505 |
((All::(nat => bool) => bool)
|
|
506 |
(%xb::nat.
|
|
507 |
(op -->::bool => bool => bool)
|
|
508 |
((op <::nat => nat => bool) xb (WL::nat))
|
|
509 |
((op =::bool => bool => bool)
|
|
510 |
((bit::nat => nat => bool) xb x)
|
|
511 |
((bit::nat => nat => bool) xb xa))))
|
|
512 |
((EQUIV::nat => nat => bool) x xa)))"
|
14516
|
513 |
by (import word32 BIT_EQUIV_THM)
|
|
514 |
|
|
515 |
lemma BITS_SUC2: "ALL n a. BITS (Suc n) 0 a = SLICE (Suc n) (Suc n) a + BITS n 0 a"
|
|
516 |
by (import word32 BITS_SUC2)
|
|
517 |
|
|
518 |
lemma BITWISE_ONE_COMP_THM: "ALL a b. BITWISE WL (%x y. ~ x) a b = ONE_COMP a"
|
|
519 |
by (import word32 BITWISE_ONE_COMP_THM)
|
|
520 |
|
|
521 |
lemma ONE_COMP_THM: "ALL x xa. xa < WL --> bit xa (ONE_COMP x) = (~ bit xa x)"
|
|
522 |
by (import word32 ONE_COMP_THM)
|
|
523 |
|
|
524 |
consts
|
|
525 |
OR :: "nat => nat => nat"
|
|
526 |
|
|
527 |
defs
|
|
528 |
OR_primdef: "OR == BITWISE WL op |"
|
|
529 |
|
|
530 |
lemma OR_def: "OR = BITWISE WL op |"
|
|
531 |
by (import word32 OR_def)
|
|
532 |
|
|
533 |
consts
|
|
534 |
AND :: "nat => nat => nat"
|
|
535 |
|
|
536 |
defs
|
|
537 |
AND_primdef: "AND == BITWISE WL op &"
|
|
538 |
|
|
539 |
lemma AND_def: "AND = BITWISE WL op &"
|
|
540 |
by (import word32 AND_def)
|
|
541 |
|
|
542 |
consts
|
|
543 |
EOR :: "nat => nat => nat"
|
|
544 |
|
|
545 |
defs
|
|
546 |
EOR_primdef: "EOR == BITWISE WL (%x y. x ~= y)"
|
|
547 |
|
|
548 |
lemma EOR_def: "EOR = BITWISE WL (%x y. x ~= y)"
|
|
549 |
by (import word32 EOR_def)
|
|
550 |
|
|
551 |
consts
|
|
552 |
COMP0 :: "nat"
|
|
553 |
|
|
554 |
defs
|
|
555 |
COMP0_primdef: "COMP0 == ONE_COMP 0"
|
|
556 |
|
|
557 |
lemma COMP0_def: "COMP0 = ONE_COMP 0"
|
|
558 |
by (import word32 COMP0_def)
|
|
559 |
|
14847
|
560 |
lemma BITWISE_THM2: "(All::(nat => bool) => bool)
|
|
561 |
(%y::nat.
|
|
562 |
(All::((bool => bool => bool) => bool) => bool)
|
|
563 |
(%oper::bool => bool => bool.
|
|
564 |
(All::(nat => bool) => bool)
|
|
565 |
(%a::nat.
|
|
566 |
(All::(nat => bool) => bool)
|
|
567 |
(%b::nat.
|
|
568 |
(op =::bool => bool => bool)
|
|
569 |
((All::(nat => bool) => bool)
|
|
570 |
(%x::nat.
|
|
571 |
(op -->::bool => bool => bool)
|
|
572 |
((op <::nat => nat => bool) x (WL::nat))
|
|
573 |
((op =::bool => bool => bool)
|
|
574 |
(oper ((bit::nat => nat => bool) x a)
|
|
575 |
((bit::nat => nat => bool) x b))
|
|
576 |
((bit::nat => nat => bool) x y))))
|
|
577 |
((EQUIV::nat => nat => bool)
|
|
578 |
((BITWISE::nat
|
|
579 |
=> (bool => bool => bool)
|
|
580 |
=> nat => nat => nat)
|
|
581 |
(WL::nat) oper a b)
|
|
582 |
y)))))"
|
14516
|
583 |
by (import word32 BITWISE_THM2)
|
|
584 |
|
|
585 |
lemma OR_ASSOC_QT: "ALL a b c. EQUIV (OR a (OR b c)) (OR (OR a b) c)"
|
|
586 |
by (import word32 OR_ASSOC_QT)
|
|
587 |
|
|
588 |
lemma OR_COMM_QT: "ALL a b. EQUIV (OR a b) (OR b a)"
|
|
589 |
by (import word32 OR_COMM_QT)
|
|
590 |
|
|
591 |
lemma OR_ABSORB_QT: "ALL a b. EQUIV (AND a (OR a b)) a"
|
|
592 |
by (import word32 OR_ABSORB_QT)
|
|
593 |
|
|
594 |
lemma OR_IDEM_QT: "ALL a. EQUIV (OR a a) a"
|
|
595 |
by (import word32 OR_IDEM_QT)
|
|
596 |
|
|
597 |
lemma AND_ASSOC_QT: "ALL a b c. EQUIV (AND a (AND b c)) (AND (AND a b) c)"
|
|
598 |
by (import word32 AND_ASSOC_QT)
|
|
599 |
|
|
600 |
lemma AND_COMM_QT: "ALL a b. EQUIV (AND a b) (AND b a)"
|
|
601 |
by (import word32 AND_COMM_QT)
|
|
602 |
|
|
603 |
lemma AND_ABSORB_QT: "ALL a b. EQUIV (OR a (AND a b)) a"
|
|
604 |
by (import word32 AND_ABSORB_QT)
|
|
605 |
|
|
606 |
lemma AND_IDEM_QT: "ALL a. EQUIV (AND a a) a"
|
|
607 |
by (import word32 AND_IDEM_QT)
|
|
608 |
|
|
609 |
lemma OR_COMP_QT: "ALL a. EQUIV (OR a (ONE_COMP a)) COMP0"
|
|
610 |
by (import word32 OR_COMP_QT)
|
|
611 |
|
|
612 |
lemma AND_COMP_QT: "ALL a. EQUIV (AND a (ONE_COMP a)) 0"
|
|
613 |
by (import word32 AND_COMP_QT)
|
|
614 |
|
|
615 |
lemma ONE_COMP_QT: "ALL a. EQUIV (ONE_COMP (ONE_COMP a)) a"
|
|
616 |
by (import word32 ONE_COMP_QT)
|
|
617 |
|
|
618 |
lemma RIGHT_AND_OVER_OR_QT: "ALL a b c. EQUIV (AND (OR a b) c) (OR (AND a c) (AND b c))"
|
|
619 |
by (import word32 RIGHT_AND_OVER_OR_QT)
|
|
620 |
|
|
621 |
lemma RIGHT_OR_OVER_AND_QT: "ALL a b c. EQUIV (OR (AND a b) c) (AND (OR a c) (OR b c))"
|
|
622 |
by (import word32 RIGHT_OR_OVER_AND_QT)
|
|
623 |
|
|
624 |
lemma DE_MORGAN_THM_QT: "ALL a b.
|
|
625 |
EQUIV (ONE_COMP (AND a b)) (OR (ONE_COMP a) (ONE_COMP b)) &
|
|
626 |
EQUIV (ONE_COMP (OR a b)) (AND (ONE_COMP a) (ONE_COMP b))"
|
|
627 |
by (import word32 DE_MORGAN_THM_QT)
|
|
628 |
|
|
629 |
lemma BIT_EQUIV: "ALL n a b. n < WL --> EQUIV a b --> bit n a = bit n b"
|
|
630 |
by (import word32 BIT_EQUIV)
|
|
631 |
|
|
632 |
lemma LSB_WELLDEF: "ALL a b. EQUIV a b --> LSBn a = LSBn b"
|
|
633 |
by (import word32 LSB_WELLDEF)
|
|
634 |
|
|
635 |
lemma MSB_WELLDEF: "ALL a b. EQUIV a b --> MSBn a = MSBn b"
|
|
636 |
by (import word32 MSB_WELLDEF)
|
|
637 |
|
|
638 |
lemma BITWISE_ISTEP: "ALL n oper a b.
|
|
639 |
0 < n -->
|
|
640 |
BITWISE n oper (a div 2) (b div 2) =
|
|
641 |
BITWISE n oper a b div 2 + SBIT (oper (bit n a) (bit n b)) (n - 1)"
|
|
642 |
by (import word32 BITWISE_ISTEP)
|
|
643 |
|
|
644 |
lemma BITWISE_EVAL: "ALL n oper a b.
|
|
645 |
BITWISE (Suc n) oper a b =
|
|
646 |
2 * BITWISE n oper (a div 2) (b div 2) + SBIT (oper (LSBn a) (LSBn b)) 0"
|
|
647 |
by (import word32 BITWISE_EVAL)
|
|
648 |
|
|
649 |
lemma BITWISE_WELLDEF: "ALL n oper a b c d.
|
|
650 |
EQUIV a b & EQUIV c d --> EQUIV (BITWISE n oper a c) (BITWISE n oper b d)"
|
|
651 |
by (import word32 BITWISE_WELLDEF)
|
|
652 |
|
|
653 |
lemma BITWISEw_WELLDEF: "ALL oper a b c d.
|
|
654 |
EQUIV a b & EQUIV c d -->
|
|
655 |
EQUIV (BITWISE WL oper a c) (BITWISE WL oper b d)"
|
|
656 |
by (import word32 BITWISEw_WELLDEF)
|
|
657 |
|
|
658 |
lemma SUC_WELLDEF: "ALL a b. EQUIV a b --> EQUIV (Suc a) (Suc b)"
|
|
659 |
by (import word32 SUC_WELLDEF)
|
|
660 |
|
|
661 |
lemma ADD_WELLDEF: "ALL a b c d. EQUIV a b & EQUIV c d --> EQUIV (a + c) (b + d)"
|
|
662 |
by (import word32 ADD_WELLDEF)
|
|
663 |
|
|
664 |
lemma MUL_WELLDEF: "ALL a b c d. EQUIV a b & EQUIV c d --> EQUIV (a * c) (b * d)"
|
|
665 |
by (import word32 MUL_WELLDEF)
|
|
666 |
|
|
667 |
lemma ONE_COMP_WELLDEF: "ALL a b. EQUIV a b --> EQUIV (ONE_COMP a) (ONE_COMP b)"
|
|
668 |
by (import word32 ONE_COMP_WELLDEF)
|
|
669 |
|
|
670 |
lemma TWO_COMP_WELLDEF: "ALL a b. EQUIV a b --> EQUIV (TWO_COMP a) (TWO_COMP b)"
|
|
671 |
by (import word32 TWO_COMP_WELLDEF)
|
|
672 |
|
|
673 |
lemma TOw_WELLDEF: "ALL a b. EQUIV a b --> EQUIV (MODw a) (MODw b)"
|
|
674 |
by (import word32 TOw_WELLDEF)
|
|
675 |
|
|
676 |
consts
|
|
677 |
LSR_ONE :: "nat => nat"
|
|
678 |
|
|
679 |
defs
|
|
680 |
LSR_ONE_primdef: "LSR_ONE == %a. MODw a div 2"
|
|
681 |
|
|
682 |
lemma LSR_ONE_def: "ALL a. LSR_ONE a = MODw a div 2"
|
|
683 |
by (import word32 LSR_ONE_def)
|
|
684 |
|
|
685 |
consts
|
|
686 |
ASR_ONE :: "nat => nat"
|
|
687 |
|
|
688 |
defs
|
|
689 |
ASR_ONE_primdef: "ASR_ONE == %a. LSR_ONE a + SBIT (MSBn a) HB"
|
|
690 |
|
|
691 |
lemma ASR_ONE_def: "ALL a. ASR_ONE a = LSR_ONE a + SBIT (MSBn a) HB"
|
|
692 |
by (import word32 ASR_ONE_def)
|
|
693 |
|
|
694 |
consts
|
|
695 |
ROR_ONE :: "nat => nat"
|
|
696 |
|
|
697 |
defs
|
|
698 |
ROR_ONE_primdef: "ROR_ONE == %a. LSR_ONE a + SBIT (LSBn a) HB"
|
|
699 |
|
|
700 |
lemma ROR_ONE_def: "ALL a. ROR_ONE a = LSR_ONE a + SBIT (LSBn a) HB"
|
|
701 |
by (import word32 ROR_ONE_def)
|
|
702 |
|
|
703 |
consts
|
|
704 |
RRXn :: "bool => nat => nat"
|
|
705 |
|
|
706 |
defs
|
|
707 |
RRXn_primdef: "RRXn == %c a. LSR_ONE a + SBIT c HB"
|
|
708 |
|
|
709 |
lemma RRXn_def: "ALL c a. RRXn c a = LSR_ONE a + SBIT c HB"
|
|
710 |
by (import word32 RRXn_def)
|
|
711 |
|
|
712 |
lemma LSR_ONE_WELLDEF: "ALL a b. EQUIV a b --> EQUIV (LSR_ONE a) (LSR_ONE b)"
|
|
713 |
by (import word32 LSR_ONE_WELLDEF)
|
|
714 |
|
|
715 |
lemma ASR_ONE_WELLDEF: "ALL a b. EQUIV a b --> EQUIV (ASR_ONE a) (ASR_ONE b)"
|
|
716 |
by (import word32 ASR_ONE_WELLDEF)
|
|
717 |
|
|
718 |
lemma ROR_ONE_WELLDEF: "ALL a b. EQUIV a b --> EQUIV (ROR_ONE a) (ROR_ONE b)"
|
|
719 |
by (import word32 ROR_ONE_WELLDEF)
|
|
720 |
|
|
721 |
lemma RRX_WELLDEF: "ALL a b c. EQUIV a b --> EQUIV (RRXn c a) (RRXn c b)"
|
|
722 |
by (import word32 RRX_WELLDEF)
|
|
723 |
|
|
724 |
lemma LSR_ONE: "LSR_ONE = BITS HB 1"
|
|
725 |
by (import word32 LSR_ONE)
|
|
726 |
|
|
727 |
typedef (open) word32 = "{x. EX xa. x = EQUIV xa}"
|
|
728 |
by (rule typedef_helper,import word32 word32_TY_DEF)
|
|
729 |
|
|
730 |
lemmas word32_TY_DEF = typedef_hol2hol4 [OF type_definition_word32]
|
|
731 |
|
|
732 |
consts
|
|
733 |
mk_word32 :: "(nat => bool) => word32"
|
|
734 |
dest_word32 :: "word32 => nat => bool"
|
|
735 |
|
|
736 |
specification (dest_word32 mk_word32) word32_tybij: "(ALL a. mk_word32 (dest_word32 a) = a) &
|
|
737 |
(ALL r. (EX x. r = EQUIV x) = (dest_word32 (mk_word32 r) = r))"
|
|
738 |
by (import word32 word32_tybij)
|
|
739 |
|
|
740 |
consts
|
|
741 |
w_0 :: "word32"
|
|
742 |
|
|
743 |
defs
|
|
744 |
w_0_primdef: "w_0 == mk_word32 (EQUIV 0)"
|
|
745 |
|
|
746 |
lemma w_0_def: "w_0 = mk_word32 (EQUIV 0)"
|
|
747 |
by (import word32 w_0_def)
|
|
748 |
|
|
749 |
consts
|
|
750 |
w_1 :: "word32"
|
|
751 |
|
|
752 |
defs
|
|
753 |
w_1_primdef: "w_1 == mk_word32 (EQUIV AONE)"
|
|
754 |
|
|
755 |
lemma w_1_def: "w_1 = mk_word32 (EQUIV AONE)"
|
|
756 |
by (import word32 w_1_def)
|
|
757 |
|
|
758 |
consts
|
|
759 |
w_T :: "word32"
|
|
760 |
|
|
761 |
defs
|
|
762 |
w_T_primdef: "w_T == mk_word32 (EQUIV COMP0)"
|
|
763 |
|
|
764 |
lemma w_T_def: "w_T = mk_word32 (EQUIV COMP0)"
|
|
765 |
by (import word32 w_T_def)
|
|
766 |
|
|
767 |
constdefs
|
|
768 |
word_suc :: "word32 => word32"
|
|
769 |
"word_suc == %T1. mk_word32 (EQUIV (Suc (Eps (dest_word32 T1))))"
|
|
770 |
|
|
771 |
lemma word_suc: "ALL T1. word_suc T1 = mk_word32 (EQUIV (Suc (Eps (dest_word32 T1))))"
|
|
772 |
by (import word32 word_suc)
|
|
773 |
|
|
774 |
constdefs
|
|
775 |
word_add :: "word32 => word32 => word32"
|
|
776 |
"word_add ==
|
|
777 |
%T1 T2. mk_word32 (EQUIV (Eps (dest_word32 T1) + Eps (dest_word32 T2)))"
|
|
778 |
|
|
779 |
lemma word_add: "ALL T1 T2.
|
|
780 |
word_add T1 T2 =
|
|
781 |
mk_word32 (EQUIV (Eps (dest_word32 T1) + Eps (dest_word32 T2)))"
|
|
782 |
by (import word32 word_add)
|
|
783 |
|
|
784 |
constdefs
|
|
785 |
word_mul :: "word32 => word32 => word32"
|
|
786 |
"word_mul ==
|
|
787 |
%T1 T2. mk_word32 (EQUIV (Eps (dest_word32 T1) * Eps (dest_word32 T2)))"
|
|
788 |
|
|
789 |
lemma word_mul: "ALL T1 T2.
|
|
790 |
word_mul T1 T2 =
|
|
791 |
mk_word32 (EQUIV (Eps (dest_word32 T1) * Eps (dest_word32 T2)))"
|
|
792 |
by (import word32 word_mul)
|
|
793 |
|
|
794 |
constdefs
|
|
795 |
word_1comp :: "word32 => word32"
|
|
796 |
"word_1comp == %T1. mk_word32 (EQUIV (ONE_COMP (Eps (dest_word32 T1))))"
|
|
797 |
|
|
798 |
lemma word_1comp: "ALL T1. word_1comp T1 = mk_word32 (EQUIV (ONE_COMP (Eps (dest_word32 T1))))"
|
|
799 |
by (import word32 word_1comp)
|
|
800 |
|
|
801 |
constdefs
|
|
802 |
word_2comp :: "word32 => word32"
|
|
803 |
"word_2comp == %T1. mk_word32 (EQUIV (TWO_COMP (Eps (dest_word32 T1))))"
|
|
804 |
|
|
805 |
lemma word_2comp: "ALL T1. word_2comp T1 = mk_word32 (EQUIV (TWO_COMP (Eps (dest_word32 T1))))"
|
|
806 |
by (import word32 word_2comp)
|
|
807 |
|
|
808 |
constdefs
|
|
809 |
word_lsr1 :: "word32 => word32"
|
|
810 |
"word_lsr1 == %T1. mk_word32 (EQUIV (LSR_ONE (Eps (dest_word32 T1))))"
|
|
811 |
|
|
812 |
lemma word_lsr1: "ALL T1. word_lsr1 T1 = mk_word32 (EQUIV (LSR_ONE (Eps (dest_word32 T1))))"
|
|
813 |
by (import word32 word_lsr1)
|
|
814 |
|
|
815 |
constdefs
|
|
816 |
word_asr1 :: "word32 => word32"
|
|
817 |
"word_asr1 == %T1. mk_word32 (EQUIV (ASR_ONE (Eps (dest_word32 T1))))"
|
|
818 |
|
|
819 |
lemma word_asr1: "ALL T1. word_asr1 T1 = mk_word32 (EQUIV (ASR_ONE (Eps (dest_word32 T1))))"
|
|
820 |
by (import word32 word_asr1)
|
|
821 |
|
|
822 |
constdefs
|
|
823 |
word_ror1 :: "word32 => word32"
|
|
824 |
"word_ror1 == %T1. mk_word32 (EQUIV (ROR_ONE (Eps (dest_word32 T1))))"
|
|
825 |
|
|
826 |
lemma word_ror1: "ALL T1. word_ror1 T1 = mk_word32 (EQUIV (ROR_ONE (Eps (dest_word32 T1))))"
|
|
827 |
by (import word32 word_ror1)
|
|
828 |
|
|
829 |
consts
|
|
830 |
RRX :: "bool => word32 => word32"
|
|
831 |
|
|
832 |
defs
|
|
833 |
RRX_primdef: "RRX == %T1 T2. mk_word32 (EQUIV (RRXn T1 (Eps (dest_word32 T2))))"
|
|
834 |
|
|
835 |
lemma RRX_def: "ALL T1 T2. RRX T1 T2 = mk_word32 (EQUIV (RRXn T1 (Eps (dest_word32 T2))))"
|
|
836 |
by (import word32 RRX_def)
|
|
837 |
|
|
838 |
consts
|
|
839 |
LSB :: "word32 => bool"
|
|
840 |
|
|
841 |
defs
|
|
842 |
LSB_primdef: "LSB == %T1. LSBn (Eps (dest_word32 T1))"
|
|
843 |
|
|
844 |
lemma LSB_def: "ALL T1. LSB T1 = LSBn (Eps (dest_word32 T1))"
|
|
845 |
by (import word32 LSB_def)
|
|
846 |
|
|
847 |
consts
|
|
848 |
MSB :: "word32 => bool"
|
|
849 |
|
|
850 |
defs
|
|
851 |
MSB_primdef: "MSB == %T1. MSBn (Eps (dest_word32 T1))"
|
|
852 |
|
|
853 |
lemma MSB_def: "ALL T1. MSB T1 = MSBn (Eps (dest_word32 T1))"
|
|
854 |
by (import word32 MSB_def)
|
|
855 |
|
|
856 |
constdefs
|
|
857 |
bitwise_or :: "word32 => word32 => word32"
|
|
858 |
"bitwise_or ==
|
|
859 |
%T1 T2. mk_word32 (EQUIV (OR (Eps (dest_word32 T1)) (Eps (dest_word32 T2))))"
|
|
860 |
|
|
861 |
lemma bitwise_or: "ALL T1 T2.
|
|
862 |
bitwise_or T1 T2 =
|
|
863 |
mk_word32 (EQUIV (OR (Eps (dest_word32 T1)) (Eps (dest_word32 T2))))"
|
|
864 |
by (import word32 bitwise_or)
|
|
865 |
|
|
866 |
constdefs
|
|
867 |
bitwise_eor :: "word32 => word32 => word32"
|
|
868 |
"bitwise_eor ==
|
|
869 |
%T1 T2.
|
|
870 |
mk_word32 (EQUIV (EOR (Eps (dest_word32 T1)) (Eps (dest_word32 T2))))"
|
|
871 |
|
|
872 |
lemma bitwise_eor: "ALL T1 T2.
|
|
873 |
bitwise_eor T1 T2 =
|
|
874 |
mk_word32 (EQUIV (EOR (Eps (dest_word32 T1)) (Eps (dest_word32 T2))))"
|
|
875 |
by (import word32 bitwise_eor)
|
|
876 |
|
|
877 |
constdefs
|
|
878 |
bitwise_and :: "word32 => word32 => word32"
|
|
879 |
"bitwise_and ==
|
|
880 |
%T1 T2.
|
|
881 |
mk_word32 (EQUIV (AND (Eps (dest_word32 T1)) (Eps (dest_word32 T2))))"
|
|
882 |
|
|
883 |
lemma bitwise_and: "ALL T1 T2.
|
|
884 |
bitwise_and T1 T2 =
|
|
885 |
mk_word32 (EQUIV (AND (Eps (dest_word32 T1)) (Eps (dest_word32 T2))))"
|
|
886 |
by (import word32 bitwise_and)
|
|
887 |
|
|
888 |
consts
|
|
889 |
TOw :: "word32 => word32"
|
|
890 |
|
|
891 |
defs
|
|
892 |
TOw_primdef: "TOw == %T1. mk_word32 (EQUIV (MODw (Eps (dest_word32 T1))))"
|
|
893 |
|
|
894 |
lemma TOw_def: "ALL T1. TOw T1 = mk_word32 (EQUIV (MODw (Eps (dest_word32 T1))))"
|
|
895 |
by (import word32 TOw_def)
|
|
896 |
|
|
897 |
consts
|
|
898 |
n2w :: "nat => word32"
|
|
899 |
|
|
900 |
defs
|
|
901 |
n2w_primdef: "n2w == %n. mk_word32 (EQUIV n)"
|
|
902 |
|
|
903 |
lemma n2w_def: "ALL n. n2w n = mk_word32 (EQUIV n)"
|
|
904 |
by (import word32 n2w_def)
|
|
905 |
|
|
906 |
consts
|
|
907 |
w2n :: "word32 => nat"
|
|
908 |
|
|
909 |
defs
|
|
910 |
w2n_primdef: "w2n == %w. MODw (Eps (dest_word32 w))"
|
|
911 |
|
|
912 |
lemma w2n_def: "ALL w. w2n w = MODw (Eps (dest_word32 w))"
|
|
913 |
by (import word32 w2n_def)
|
|
914 |
|
|
915 |
lemma ADDw: "(ALL x. word_add w_0 x = x) &
|
|
916 |
(ALL x xa. word_add (word_suc x) xa = word_suc (word_add x xa))"
|
|
917 |
by (import word32 ADDw)
|
|
918 |
|
|
919 |
lemma ADD_0w: "ALL x. word_add x w_0 = x"
|
|
920 |
by (import word32 ADD_0w)
|
|
921 |
|
|
922 |
lemma ADD1w: "ALL x. word_suc x = word_add x w_1"
|
|
923 |
by (import word32 ADD1w)
|
|
924 |
|
|
925 |
lemma ADD_ASSOCw: "ALL x xa xb. word_add x (word_add xa xb) = word_add (word_add x xa) xb"
|
|
926 |
by (import word32 ADD_ASSOCw)
|
|
927 |
|
|
928 |
lemma ADD_CLAUSESw: "(ALL x. word_add w_0 x = x) &
|
|
929 |
(ALL x. word_add x w_0 = x) &
|
|
930 |
(ALL x xa. word_add (word_suc x) xa = word_suc (word_add x xa)) &
|
|
931 |
(ALL x xa. word_add x (word_suc xa) = word_suc (word_add x xa))"
|
|
932 |
by (import word32 ADD_CLAUSESw)
|
|
933 |
|
|
934 |
lemma ADD_COMMw: "ALL x xa. word_add x xa = word_add xa x"
|
|
935 |
by (import word32 ADD_COMMw)
|
|
936 |
|
|
937 |
lemma ADD_INV_0_EQw: "ALL x xa. (word_add x xa = x) = (xa = w_0)"
|
|
938 |
by (import word32 ADD_INV_0_EQw)
|
|
939 |
|
|
940 |
lemma EQ_ADD_LCANCELw: "ALL x xa xb. (word_add x xa = word_add x xb) = (xa = xb)"
|
|
941 |
by (import word32 EQ_ADD_LCANCELw)
|
|
942 |
|
|
943 |
lemma EQ_ADD_RCANCELw: "ALL x xa xb. (word_add x xb = word_add xa xb) = (x = xa)"
|
|
944 |
by (import word32 EQ_ADD_RCANCELw)
|
|
945 |
|
|
946 |
lemma LEFT_ADD_DISTRIBw: "ALL x xa xb.
|
|
947 |
word_mul xb (word_add x xa) = word_add (word_mul xb x) (word_mul xb xa)"
|
|
948 |
by (import word32 LEFT_ADD_DISTRIBw)
|
|
949 |
|
|
950 |
lemma MULT_ASSOCw: "ALL x xa xb. word_mul x (word_mul xa xb) = word_mul (word_mul x xa) xb"
|
|
951 |
by (import word32 MULT_ASSOCw)
|
|
952 |
|
|
953 |
lemma MULT_COMMw: "ALL x xa. word_mul x xa = word_mul xa x"
|
|
954 |
by (import word32 MULT_COMMw)
|
|
955 |
|
|
956 |
lemma MULT_CLAUSESw: "ALL x xa.
|
|
957 |
word_mul w_0 x = w_0 &
|
|
958 |
word_mul x w_0 = w_0 &
|
|
959 |
word_mul w_1 x = x &
|
|
960 |
word_mul x w_1 = x &
|
|
961 |
word_mul (word_suc x) xa = word_add (word_mul x xa) xa &
|
|
962 |
word_mul x (word_suc xa) = word_add x (word_mul x xa)"
|
|
963 |
by (import word32 MULT_CLAUSESw)
|
|
964 |
|
|
965 |
lemma TWO_COMP_ONE_COMP: "ALL x. word_2comp x = word_add (word_1comp x) w_1"
|
|
966 |
by (import word32 TWO_COMP_ONE_COMP)
|
|
967 |
|
|
968 |
lemma OR_ASSOCw: "ALL x xa xb.
|
|
969 |
bitwise_or x (bitwise_or xa xb) = bitwise_or (bitwise_or x xa) xb"
|
|
970 |
by (import word32 OR_ASSOCw)
|
|
971 |
|
|
972 |
lemma OR_COMMw: "ALL x xa. bitwise_or x xa = bitwise_or xa x"
|
|
973 |
by (import word32 OR_COMMw)
|
|
974 |
|
|
975 |
lemma OR_IDEMw: "ALL x. bitwise_or x x = x"
|
|
976 |
by (import word32 OR_IDEMw)
|
|
977 |
|
|
978 |
lemma OR_ABSORBw: "ALL x xa. bitwise_and x (bitwise_or x xa) = x"
|
|
979 |
by (import word32 OR_ABSORBw)
|
|
980 |
|
|
981 |
lemma AND_ASSOCw: "ALL x xa xb.
|
|
982 |
bitwise_and x (bitwise_and xa xb) = bitwise_and (bitwise_and x xa) xb"
|
|
983 |
by (import word32 AND_ASSOCw)
|
|
984 |
|
|
985 |
lemma AND_COMMw: "ALL x xa. bitwise_and x xa = bitwise_and xa x"
|
|
986 |
by (import word32 AND_COMMw)
|
|
987 |
|
|
988 |
lemma AND_IDEMw: "ALL x. bitwise_and x x = x"
|
|
989 |
by (import word32 AND_IDEMw)
|
|
990 |
|
|
991 |
lemma AND_ABSORBw: "ALL x xa. bitwise_or x (bitwise_and x xa) = x"
|
|
992 |
by (import word32 AND_ABSORBw)
|
|
993 |
|
|
994 |
lemma ONE_COMPw: "ALL x. word_1comp (word_1comp x) = x"
|
|
995 |
by (import word32 ONE_COMPw)
|
|
996 |
|
|
997 |
lemma RIGHT_AND_OVER_ORw: "ALL x xa xb.
|
|
998 |
bitwise_and (bitwise_or x xa) xb =
|
|
999 |
bitwise_or (bitwise_and x xb) (bitwise_and xa xb)"
|
|
1000 |
by (import word32 RIGHT_AND_OVER_ORw)
|
|
1001 |
|
|
1002 |
lemma RIGHT_OR_OVER_ANDw: "ALL x xa xb.
|
|
1003 |
bitwise_or (bitwise_and x xa) xb =
|
|
1004 |
bitwise_and (bitwise_or x xb) (bitwise_or xa xb)"
|
|
1005 |
by (import word32 RIGHT_OR_OVER_ANDw)
|
|
1006 |
|
|
1007 |
lemma DE_MORGAN_THMw: "ALL x xa.
|
|
1008 |
word_1comp (bitwise_and x xa) =
|
|
1009 |
bitwise_or (word_1comp x) (word_1comp xa) &
|
|
1010 |
word_1comp (bitwise_or x xa) = bitwise_and (word_1comp x) (word_1comp xa)"
|
|
1011 |
by (import word32 DE_MORGAN_THMw)
|
|
1012 |
|
|
1013 |
lemma w_0: "w_0 = n2w 0"
|
|
1014 |
by (import word32 w_0)
|
|
1015 |
|
|
1016 |
lemma w_1: "w_1 = n2w 1"
|
|
1017 |
by (import word32 w_1)
|
|
1018 |
|
|
1019 |
lemma w_T: "w_T =
|
|
1020 |
n2w (NUMERAL
|
|
1021 |
(NUMERAL_BIT1
|
|
1022 |
(NUMERAL_BIT1
|
|
1023 |
(NUMERAL_BIT1
|
|
1024 |
(NUMERAL_BIT1
|
|
1025 |
(NUMERAL_BIT1
|
|
1026 |
(NUMERAL_BIT1
|
|
1027 |
(NUMERAL_BIT1
|
|
1028 |
(NUMERAL_BIT1
|
|
1029 |
(NUMERAL_BIT1
|
|
1030 |
(NUMERAL_BIT1
|
|
1031 |
(NUMERAL_BIT1
|
|
1032 |
(NUMERAL_BIT1
|
|
1033 |
(NUMERAL_BIT1
|
|
1034 |
(NUMERAL_BIT1
|
|
1035 |
(NUMERAL_BIT1
|
|
1036 |
(NUMERAL_BIT1
|
|
1037 |
(NUMERAL_BIT1
|
|
1038 |
(NUMERAL_BIT1
|
|
1039 |
(NUMERAL_BIT1
|
|
1040 |
(NUMERAL_BIT1
|
|
1041 |
(NUMERAL_BIT1
|
|
1042 |
(NUMERAL_BIT1
|
|
1043 |
(NUMERAL_BIT1
|
|
1044 |
(NUMERAL_BIT1
|
|
1045 |
(NUMERAL_BIT1
|
|
1046 |
(NUMERAL_BIT1
|
|
1047 |
(NUMERAL_BIT1
|
|
1048 |
(NUMERAL_BIT1
|
|
1049 |
(NUMERAL_BIT1
|
|
1050 |
(NUMERAL_BIT1
|
|
1051 |
(NUMERAL_BIT1
|
|
1052 |
(NUMERAL_BIT1
|
|
1053 |
ALT_ZERO)))))))))))))))))))))))))))))))))"
|
|
1054 |
by (import word32 w_T)
|
|
1055 |
|
|
1056 |
lemma ADD_TWO_COMP: "ALL x. word_add x (word_2comp x) = w_0"
|
|
1057 |
by (import word32 ADD_TWO_COMP)
|
|
1058 |
|
|
1059 |
lemma ADD_TWO_COMP2: "ALL x. word_add (word_2comp x) x = w_0"
|
|
1060 |
by (import word32 ADD_TWO_COMP2)
|
|
1061 |
|
|
1062 |
constdefs
|
|
1063 |
word_sub :: "word32 => word32 => word32"
|
|
1064 |
"word_sub == %a b. word_add a (word_2comp b)"
|
|
1065 |
|
|
1066 |
lemma word_sub: "ALL a b. word_sub a b = word_add a (word_2comp b)"
|
|
1067 |
by (import word32 word_sub)
|
|
1068 |
|
|
1069 |
constdefs
|
|
1070 |
word_lsl :: "word32 => nat => word32"
|
|
1071 |
"word_lsl == %a n. word_mul a (n2w (2 ^ n))"
|
|
1072 |
|
|
1073 |
lemma word_lsl: "ALL a n. word_lsl a n = word_mul a (n2w (2 ^ n))"
|
|
1074 |
by (import word32 word_lsl)
|
|
1075 |
|
|
1076 |
constdefs
|
|
1077 |
word_lsr :: "word32 => nat => word32"
|
|
1078 |
"word_lsr == %a n. (word_lsr1 ^ n) a"
|
|
1079 |
|
|
1080 |
lemma word_lsr: "ALL a n. word_lsr a n = (word_lsr1 ^ n) a"
|
|
1081 |
by (import word32 word_lsr)
|
|
1082 |
|
|
1083 |
constdefs
|
|
1084 |
word_asr :: "word32 => nat => word32"
|
|
1085 |
"word_asr == %a n. (word_asr1 ^ n) a"
|
|
1086 |
|
|
1087 |
lemma word_asr: "ALL a n. word_asr a n = (word_asr1 ^ n) a"
|
|
1088 |
by (import word32 word_asr)
|
|
1089 |
|
|
1090 |
constdefs
|
|
1091 |
word_ror :: "word32 => nat => word32"
|
|
1092 |
"word_ror == %a n. (word_ror1 ^ n) a"
|
|
1093 |
|
|
1094 |
lemma word_ror: "ALL a n. word_ror a n = (word_ror1 ^ n) a"
|
|
1095 |
by (import word32 word_ror)
|
|
1096 |
|
|
1097 |
consts
|
|
1098 |
BITw :: "nat => word32 => bool"
|
|
1099 |
|
|
1100 |
defs
|
|
1101 |
BITw_primdef: "BITw == %b n. bit b (w2n n)"
|
|
1102 |
|
|
1103 |
lemma BITw_def: "ALL b n. BITw b n = bit b (w2n n)"
|
|
1104 |
by (import word32 BITw_def)
|
|
1105 |
|
|
1106 |
consts
|
|
1107 |
BITSw :: "nat => nat => word32 => nat"
|
|
1108 |
|
|
1109 |
defs
|
|
1110 |
BITSw_primdef: "BITSw == %h l n. BITS h l (w2n n)"
|
|
1111 |
|
|
1112 |
lemma BITSw_def: "ALL h l n. BITSw h l n = BITS h l (w2n n)"
|
|
1113 |
by (import word32 BITSw_def)
|
|
1114 |
|
|
1115 |
consts
|
|
1116 |
SLICEw :: "nat => nat => word32 => nat"
|
|
1117 |
|
|
1118 |
defs
|
|
1119 |
SLICEw_primdef: "SLICEw == %h l n. SLICE h l (w2n n)"
|
|
1120 |
|
|
1121 |
lemma SLICEw_def: "ALL h l n. SLICEw h l n = SLICE h l (w2n n)"
|
|
1122 |
by (import word32 SLICEw_def)
|
|
1123 |
|
|
1124 |
lemma TWO_COMP_ADD: "ALL a b. word_2comp (word_add a b) = word_add (word_2comp a) (word_2comp b)"
|
|
1125 |
by (import word32 TWO_COMP_ADD)
|
|
1126 |
|
|
1127 |
lemma TWO_COMP_ELIM: "ALL a. word_2comp (word_2comp a) = a"
|
|
1128 |
by (import word32 TWO_COMP_ELIM)
|
|
1129 |
|
|
1130 |
lemma ADD_SUB_ASSOC: "ALL a b c. word_sub (word_add a b) c = word_add a (word_sub b c)"
|
|
1131 |
by (import word32 ADD_SUB_ASSOC)
|
|
1132 |
|
|
1133 |
lemma ADD_SUB_SYM: "ALL a b c. word_sub (word_add a b) c = word_add (word_sub a c) b"
|
|
1134 |
by (import word32 ADD_SUB_SYM)
|
|
1135 |
|
|
1136 |
lemma SUB_EQUALw: "ALL a. word_sub a a = w_0"
|
|
1137 |
by (import word32 SUB_EQUALw)
|
|
1138 |
|
|
1139 |
lemma ADD_SUBw: "ALL a b. word_sub (word_add a b) b = a"
|
|
1140 |
by (import word32 ADD_SUBw)
|
|
1141 |
|
|
1142 |
lemma SUB_SUBw: "ALL a b c. word_sub a (word_sub b c) = word_sub (word_add a c) b"
|
|
1143 |
by (import word32 SUB_SUBw)
|
|
1144 |
|
|
1145 |
lemma ONE_COMP_TWO_COMP: "ALL a. word_1comp a = word_sub (word_2comp a) w_1"
|
|
1146 |
by (import word32 ONE_COMP_TWO_COMP)
|
|
1147 |
|
|
1148 |
lemma SUBw: "ALL m n. word_sub (word_suc m) n = word_suc (word_sub m n)"
|
|
1149 |
by (import word32 SUBw)
|
|
1150 |
|
|
1151 |
lemma ADD_EQ_SUBw: "ALL m n p. (word_add m n = p) = (m = word_sub p n)"
|
|
1152 |
by (import word32 ADD_EQ_SUBw)
|
|
1153 |
|
|
1154 |
lemma CANCEL_SUBw: "ALL m n p. (word_sub n p = word_sub m p) = (n = m)"
|
|
1155 |
by (import word32 CANCEL_SUBw)
|
|
1156 |
|
|
1157 |
lemma SUB_PLUSw: "ALL a b c. word_sub a (word_add b c) = word_sub (word_sub a b) c"
|
|
1158 |
by (import word32 SUB_PLUSw)
|
|
1159 |
|
|
1160 |
lemma word_nchotomy: "ALL w. EX n. w = n2w n"
|
|
1161 |
by (import word32 word_nchotomy)
|
|
1162 |
|
|
1163 |
lemma dest_word_mk_word_eq3: "ALL a. dest_word32 (mk_word32 (EQUIV a)) = EQUIV a"
|
|
1164 |
by (import word32 dest_word_mk_word_eq3)
|
|
1165 |
|
|
1166 |
lemma MODw_ELIM: "ALL n. n2w (MODw n) = n2w n"
|
|
1167 |
by (import word32 MODw_ELIM)
|
|
1168 |
|
|
1169 |
lemma w2n_EVAL: "ALL n. w2n (n2w n) = MODw n"
|
|
1170 |
by (import word32 w2n_EVAL)
|
|
1171 |
|
|
1172 |
lemma w2n_ELIM: "ALL a. n2w (w2n a) = a"
|
|
1173 |
by (import word32 w2n_ELIM)
|
|
1174 |
|
|
1175 |
lemma n2w_11: "ALL a b. (n2w a = n2w b) = (MODw a = MODw b)"
|
|
1176 |
by (import word32 n2w_11)
|
|
1177 |
|
|
1178 |
lemma ADD_EVAL: "word_add (n2w a) (n2w b) = n2w (a + b)"
|
|
1179 |
by (import word32 ADD_EVAL)
|
|
1180 |
|
|
1181 |
lemma MUL_EVAL: "word_mul (n2w a) (n2w b) = n2w (a * b)"
|
|
1182 |
by (import word32 MUL_EVAL)
|
|
1183 |
|
|
1184 |
lemma ONE_COMP_EVAL: "word_1comp (n2w a) = n2w (ONE_COMP a)"
|
|
1185 |
by (import word32 ONE_COMP_EVAL)
|
|
1186 |
|
|
1187 |
lemma TWO_COMP_EVAL: "word_2comp (n2w a) = n2w (TWO_COMP a)"
|
|
1188 |
by (import word32 TWO_COMP_EVAL)
|
|
1189 |
|
|
1190 |
lemma LSR_ONE_EVAL: "word_lsr1 (n2w a) = n2w (LSR_ONE a)"
|
|
1191 |
by (import word32 LSR_ONE_EVAL)
|
|
1192 |
|
|
1193 |
lemma ASR_ONE_EVAL: "word_asr1 (n2w a) = n2w (ASR_ONE a)"
|
|
1194 |
by (import word32 ASR_ONE_EVAL)
|
|
1195 |
|
|
1196 |
lemma ROR_ONE_EVAL: "word_ror1 (n2w a) = n2w (ROR_ONE a)"
|
|
1197 |
by (import word32 ROR_ONE_EVAL)
|
|
1198 |
|
|
1199 |
lemma RRX_EVAL: "RRX c (n2w a) = n2w (RRXn c a)"
|
|
1200 |
by (import word32 RRX_EVAL)
|
|
1201 |
|
|
1202 |
lemma LSB_EVAL: "LSB (n2w a) = LSBn a"
|
|
1203 |
by (import word32 LSB_EVAL)
|
|
1204 |
|
|
1205 |
lemma MSB_EVAL: "MSB (n2w a) = MSBn a"
|
|
1206 |
by (import word32 MSB_EVAL)
|
|
1207 |
|
|
1208 |
lemma OR_EVAL: "bitwise_or (n2w a) (n2w b) = n2w (OR a b)"
|
|
1209 |
by (import word32 OR_EVAL)
|
|
1210 |
|
|
1211 |
lemma EOR_EVAL: "bitwise_eor (n2w a) (n2w b) = n2w (EOR a b)"
|
|
1212 |
by (import word32 EOR_EVAL)
|
|
1213 |
|
|
1214 |
lemma AND_EVAL: "bitwise_and (n2w a) (n2w b) = n2w (AND a b)"
|
|
1215 |
by (import word32 AND_EVAL)
|
|
1216 |
|
|
1217 |
lemma BITS_EVAL: "ALL h l a. BITSw h l (n2w a) = BITS h l (MODw a)"
|
|
1218 |
by (import word32 BITS_EVAL)
|
|
1219 |
|
|
1220 |
lemma BIT_EVAL: "ALL b a. BITw b (n2w a) = bit b (MODw a)"
|
|
1221 |
by (import word32 BIT_EVAL)
|
|
1222 |
|
|
1223 |
lemma SLICE_EVAL: "ALL h l a. SLICEw h l (n2w a) = SLICE h l (MODw a)"
|
|
1224 |
by (import word32 SLICE_EVAL)
|
|
1225 |
|
|
1226 |
lemma LSL_ADD: "ALL a m n. word_lsl (word_lsl a m) n = word_lsl a (m + n)"
|
|
1227 |
by (import word32 LSL_ADD)
|
|
1228 |
|
|
1229 |
lemma LSR_ADD: "ALL x xa xb. word_lsr (word_lsr x xa) xb = word_lsr x (xa + xb)"
|
|
1230 |
by (import word32 LSR_ADD)
|
|
1231 |
|
|
1232 |
lemma ASR_ADD: "ALL x xa xb. word_asr (word_asr x xa) xb = word_asr x (xa + xb)"
|
|
1233 |
by (import word32 ASR_ADD)
|
|
1234 |
|
|
1235 |
lemma ROR_ADD: "ALL x xa xb. word_ror (word_ror x xa) xb = word_ror x (xa + xb)"
|
|
1236 |
by (import word32 ROR_ADD)
|
|
1237 |
|
|
1238 |
lemma LSL_LIMIT: "ALL w n. HB < n --> word_lsl w n = w_0"
|
|
1239 |
by (import word32 LSL_LIMIT)
|
|
1240 |
|
|
1241 |
lemma MOD_MOD_DIV: "ALL a b. INw (MODw a div 2 ^ b)"
|
|
1242 |
by (import word32 MOD_MOD_DIV)
|
|
1243 |
|
|
1244 |
lemma MOD_MOD_DIV_2EXP: "ALL a n. MODw (MODw a div 2 ^ n) div 2 = MODw a div 2 ^ Suc n"
|
|
1245 |
by (import word32 MOD_MOD_DIV_2EXP)
|
|
1246 |
|
|
1247 |
lemma LSR_EVAL: "ALL n. word_lsr (n2w a) n = n2w (MODw a div 2 ^ n)"
|
|
1248 |
by (import word32 LSR_EVAL)
|
|
1249 |
|
|
1250 |
lemma LSR_THM: "ALL x n. word_lsr (n2w n) x = n2w (BITS HB (min WL x) n)"
|
|
1251 |
by (import word32 LSR_THM)
|
|
1252 |
|
|
1253 |
lemma LSR_LIMIT: "ALL x w. HB < x --> word_lsr w x = w_0"
|
|
1254 |
by (import word32 LSR_LIMIT)
|
|
1255 |
|
|
1256 |
lemma LEFT_SHIFT_LESS: "ALL (n::nat) (m::nat) a::nat.
|
|
1257 |
a < (2::nat) ^ m -->
|
|
1258 |
(2::nat) ^ n + a * (2::nat) ^ n <= (2::nat) ^ (m + n)"
|
|
1259 |
by (import word32 LEFT_SHIFT_LESS)
|
|
1260 |
|
|
1261 |
lemma ROR_THM: "ALL x n.
|
|
1262 |
word_ror (n2w n) x =
|
|
1263 |
(let x' = x mod WL
|
|
1264 |
in n2w (BITS HB x' n + BITS (x' - 1) 0 n * 2 ^ (WL - x')))"
|
|
1265 |
by (import word32 ROR_THM)
|
|
1266 |
|
|
1267 |
lemma ROR_CYCLE: "ALL x w. word_ror w (x * WL) = w"
|
|
1268 |
by (import word32 ROR_CYCLE)
|
|
1269 |
|
|
1270 |
lemma ASR_THM: "ALL x n.
|
|
1271 |
word_asr (n2w n) x =
|
|
1272 |
(let x' = min HB x; s = BITS HB x' n
|
|
1273 |
in n2w (if MSBn n then 2 ^ WL - 2 ^ (WL - x') + s else s))"
|
|
1274 |
by (import word32 ASR_THM)
|
|
1275 |
|
|
1276 |
lemma ASR_LIMIT: "ALL x w. HB <= x --> word_asr w x = (if MSB w then w_T else w_0)"
|
|
1277 |
by (import word32 ASR_LIMIT)
|
|
1278 |
|
|
1279 |
lemma ZERO_SHIFT: "(ALL n. word_lsl w_0 n = w_0) &
|
|
1280 |
(ALL n. word_asr w_0 n = w_0) &
|
|
1281 |
(ALL n. word_lsr w_0 n = w_0) & (ALL n. word_ror w_0 n = w_0)"
|
|
1282 |
by (import word32 ZERO_SHIFT)
|
|
1283 |
|
|
1284 |
lemma ZERO_SHIFT2: "(ALL a. word_lsl a 0 = a) &
|
|
1285 |
(ALL a. word_asr a 0 = a) &
|
|
1286 |
(ALL a. word_lsr a 0 = a) & (ALL a. word_ror a 0 = a)"
|
|
1287 |
by (import word32 ZERO_SHIFT2)
|
|
1288 |
|
|
1289 |
lemma ASR_w_T: "ALL n. word_asr w_T n = w_T"
|
|
1290 |
by (import word32 ASR_w_T)
|
|
1291 |
|
|
1292 |
lemma ROR_w_T: "ALL n. word_ror w_T n = w_T"
|
|
1293 |
by (import word32 ROR_w_T)
|
|
1294 |
|
|
1295 |
lemma MODw_EVAL: "ALL x.
|
|
1296 |
MODw x =
|
|
1297 |
x mod
|
|
1298 |
NUMERAL
|
|
1299 |
(NUMERAL_BIT2
|
|
1300 |
(NUMERAL_BIT1
|
|
1301 |
(NUMERAL_BIT1
|
|
1302 |
(NUMERAL_BIT1
|
|
1303 |
(NUMERAL_BIT1
|
|
1304 |
(NUMERAL_BIT1
|
|
1305 |
(NUMERAL_BIT1
|
|
1306 |
(NUMERAL_BIT1
|
|
1307 |
(NUMERAL_BIT1
|
|
1308 |
(NUMERAL_BIT1
|
|
1309 |
(NUMERAL_BIT1
|
|
1310 |
(NUMERAL_BIT1
|
|
1311 |
(NUMERAL_BIT1
|
|
1312 |
(NUMERAL_BIT1
|
|
1313 |
(NUMERAL_BIT1
|
|
1314 |
(NUMERAL_BIT1
|
|
1315 |
(NUMERAL_BIT1
|
|
1316 |
(NUMERAL_BIT1
|
|
1317 |
(NUMERAL_BIT1
|
|
1318 |
(NUMERAL_BIT1
|
|
1319 |
(NUMERAL_BIT1
|
|
1320 |
(NUMERAL_BIT1
|
|
1321 |
(NUMERAL_BIT1
|
|
1322 |
(NUMERAL_BIT1
|
|
1323 |
(NUMERAL_BIT1
|
|
1324 |
(NUMERAL_BIT1
|
|
1325 |
(NUMERAL_BIT1
|
|
1326 |
(NUMERAL_BIT1
|
|
1327 |
(NUMERAL_BIT1
|
|
1328 |
(NUMERAL_BIT1
|
|
1329 |
(NUMERAL_BIT1
|
|
1330 |
(NUMERAL_BIT1
|
|
1331 |
ALT_ZERO))))))))))))))))))))))))))))))))"
|
|
1332 |
by (import word32 MODw_EVAL)
|
|
1333 |
|
|
1334 |
lemma ADD_EVAL2: "ALL b a. word_add (n2w a) (n2w b) = n2w (MODw (a + b))"
|
|
1335 |
by (import word32 ADD_EVAL2)
|
|
1336 |
|
|
1337 |
lemma MUL_EVAL2: "ALL b a. word_mul (n2w a) (n2w b) = n2w (MODw (a * b))"
|
|
1338 |
by (import word32 MUL_EVAL2)
|
|
1339 |
|
|
1340 |
lemma ONE_COMP_EVAL2: "ALL a.
|
|
1341 |
word_1comp (n2w a) =
|
|
1342 |
n2w (2 ^
|
|
1343 |
NUMERAL
|
|
1344 |
(NUMERAL_BIT2
|
|
1345 |
(NUMERAL_BIT1
|
|
1346 |
(NUMERAL_BIT1 (NUMERAL_BIT1 (NUMERAL_BIT1 ALT_ZERO))))) -
|
|
1347 |
1 -
|
|
1348 |
MODw a)"
|
|
1349 |
by (import word32 ONE_COMP_EVAL2)
|
|
1350 |
|
|
1351 |
lemma TWO_COMP_EVAL2: "ALL a.
|
|
1352 |
word_2comp (n2w a) =
|
|
1353 |
n2w (MODw
|
|
1354 |
(2 ^
|
|
1355 |
NUMERAL
|
|
1356 |
(NUMERAL_BIT2
|
|
1357 |
(NUMERAL_BIT1
|
|
1358 |
(NUMERAL_BIT1 (NUMERAL_BIT1 (NUMERAL_BIT1 ALT_ZERO))))) -
|
|
1359 |
MODw a))"
|
|
1360 |
by (import word32 TWO_COMP_EVAL2)
|
|
1361 |
|
|
1362 |
lemma LSR_ONE_EVAL2: "ALL a. word_lsr1 (n2w a) = n2w (MODw a div 2)"
|
|
1363 |
by (import word32 LSR_ONE_EVAL2)
|
|
1364 |
|
|
1365 |
lemma ASR_ONE_EVAL2: "ALL a.
|
|
1366 |
word_asr1 (n2w a) =
|
|
1367 |
n2w (MODw a div 2 +
|
|
1368 |
SBIT (MSBn a)
|
|
1369 |
(NUMERAL
|
|
1370 |
(NUMERAL_BIT1
|
|
1371 |
(NUMERAL_BIT1
|
|
1372 |
(NUMERAL_BIT1 (NUMERAL_BIT1 (NUMERAL_BIT1 ALT_ZERO)))))))"
|
|
1373 |
by (import word32 ASR_ONE_EVAL2)
|
|
1374 |
|
|
1375 |
lemma ROR_ONE_EVAL2: "ALL a.
|
|
1376 |
word_ror1 (n2w a) =
|
|
1377 |
n2w (MODw a div 2 +
|
|
1378 |
SBIT (LSBn a)
|
|
1379 |
(NUMERAL
|
|
1380 |
(NUMERAL_BIT1
|
|
1381 |
(NUMERAL_BIT1
|
|
1382 |
(NUMERAL_BIT1 (NUMERAL_BIT1 (NUMERAL_BIT1 ALT_ZERO)))))))"
|
|
1383 |
by (import word32 ROR_ONE_EVAL2)
|
|
1384 |
|
|
1385 |
lemma RRX_EVAL2: "ALL c a.
|
|
1386 |
RRX c (n2w a) =
|
|
1387 |
n2w (MODw a div 2 +
|
|
1388 |
SBIT c
|
|
1389 |
(NUMERAL
|
|
1390 |
(NUMERAL_BIT1
|
|
1391 |
(NUMERAL_BIT1
|
|
1392 |
(NUMERAL_BIT1 (NUMERAL_BIT1 (NUMERAL_BIT1 ALT_ZERO)))))))"
|
|
1393 |
by (import word32 RRX_EVAL2)
|
|
1394 |
|
|
1395 |
lemma LSB_EVAL2: "ALL a. LSB (n2w a) = ODD a"
|
|
1396 |
by (import word32 LSB_EVAL2)
|
|
1397 |
|
|
1398 |
lemma MSB_EVAL2: "ALL a.
|
|
1399 |
MSB (n2w a) =
|
|
1400 |
bit (NUMERAL
|
|
1401 |
(NUMERAL_BIT1
|
|
1402 |
(NUMERAL_BIT1
|
|
1403 |
(NUMERAL_BIT1 (NUMERAL_BIT1 (NUMERAL_BIT1 ALT_ZERO))))))
|
|
1404 |
a"
|
|
1405 |
by (import word32 MSB_EVAL2)
|
|
1406 |
|
|
1407 |
lemma OR_EVAL2: "ALL b a.
|
|
1408 |
bitwise_or (n2w a) (n2w b) =
|
|
1409 |
n2w (BITWISE
|
|
1410 |
(NUMERAL
|
|
1411 |
(NUMERAL_BIT2
|
|
1412 |
(NUMERAL_BIT1
|
|
1413 |
(NUMERAL_BIT1 (NUMERAL_BIT1 (NUMERAL_BIT1 ALT_ZERO))))))
|
|
1414 |
op | a b)"
|
|
1415 |
by (import word32 OR_EVAL2)
|
|
1416 |
|
|
1417 |
lemma AND_EVAL2: "ALL b a.
|
|
1418 |
bitwise_and (n2w a) (n2w b) =
|
|
1419 |
n2w (BITWISE
|
|
1420 |
(NUMERAL
|
|
1421 |
(NUMERAL_BIT2
|
|
1422 |
(NUMERAL_BIT1
|
|
1423 |
(NUMERAL_BIT1 (NUMERAL_BIT1 (NUMERAL_BIT1 ALT_ZERO))))))
|
|
1424 |
op & a b)"
|
|
1425 |
by (import word32 AND_EVAL2)
|
|
1426 |
|
|
1427 |
lemma EOR_EVAL2: "ALL b a.
|
|
1428 |
bitwise_eor (n2w a) (n2w b) =
|
|
1429 |
n2w (BITWISE
|
|
1430 |
(NUMERAL
|
|
1431 |
(NUMERAL_BIT2
|
|
1432 |
(NUMERAL_BIT1
|
|
1433 |
(NUMERAL_BIT1 (NUMERAL_BIT1 (NUMERAL_BIT1 ALT_ZERO))))))
|
|
1434 |
(%x y. x ~= y) a b)"
|
|
1435 |
by (import word32 EOR_EVAL2)
|
|
1436 |
|
|
1437 |
lemma BITWISE_EVAL2: "ALL n oper x y.
|
|
1438 |
BITWISE n oper x y =
|
|
1439 |
(if n = 0 then 0
|
|
1440 |
else 2 * BITWISE (n - 1) oper (x div 2) (y div 2) +
|
|
1441 |
(if oper (ODD x) (ODD y) then 1 else 0))"
|
|
1442 |
by (import word32 BITWISE_EVAL2)
|
|
1443 |
|
|
1444 |
lemma BITSwLT_THM: "ALL h l n. BITSw h l n < 2 ^ (Suc h - l)"
|
|
1445 |
by (import word32 BITSwLT_THM)
|
|
1446 |
|
|
1447 |
lemma BITSw_COMP_THM: "ALL h1 l1 h2 l2 n.
|
|
1448 |
h2 + l1 <= h1 -->
|
|
1449 |
BITS h2 l2 (BITSw h1 l1 n) = BITSw (h2 + l1) (l2 + l1) n"
|
|
1450 |
by (import word32 BITSw_COMP_THM)
|
|
1451 |
|
|
1452 |
lemma BITSw_DIV_THM: "ALL h l n x. BITSw h l x div 2 ^ n = BITSw h (l + n) x"
|
|
1453 |
by (import word32 BITSw_DIV_THM)
|
|
1454 |
|
|
1455 |
lemma BITw_THM: "ALL b n. BITw b n = (BITSw b b n = 1)"
|
|
1456 |
by (import word32 BITw_THM)
|
|
1457 |
|
|
1458 |
lemma SLICEw_THM: "ALL n h l. SLICEw h l n = BITSw h l n * 2 ^ l"
|
|
1459 |
by (import word32 SLICEw_THM)
|
|
1460 |
|
|
1461 |
lemma BITS_SLICEw_THM: "ALL h l n. BITS h l (SLICEw h l n) = BITSw h l n"
|
|
1462 |
by (import word32 BITS_SLICEw_THM)
|
|
1463 |
|
|
1464 |
lemma SLICEw_ZERO_THM: "ALL n h. SLICEw h 0 n = BITSw h 0 n"
|
|
1465 |
by (import word32 SLICEw_ZERO_THM)
|
|
1466 |
|
|
1467 |
lemma SLICEw_COMP_THM: "ALL h m l a.
|
|
1468 |
Suc m <= h & l <= m --> SLICEw h (Suc m) a + SLICEw m l a = SLICEw h l a"
|
|
1469 |
by (import word32 SLICEw_COMP_THM)
|
|
1470 |
|
|
1471 |
lemma BITSw_ZERO: "ALL h l n. h < l --> BITSw h l n = 0"
|
|
1472 |
by (import word32 BITSw_ZERO)
|
|
1473 |
|
|
1474 |
lemma SLICEw_ZERO: "ALL h l n. h < l --> SLICEw h l n = 0"
|
|
1475 |
by (import word32 SLICEw_ZERO)
|
|
1476 |
|
|
1477 |
;end_setup
|
|
1478 |
|
|
1479 |
end
|
|
1480 |
|