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