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