| author | wenzelm |
| Mon, 20 Oct 2025 21:07:53 +0200 | |
| changeset 83323 | 08722f90a439 |
| parent 82580 | cf506179fc4c |
| permissions | -rw-r--r-- |
| 81714 | 1 |
(* Author: Florian Haftmann, TU Muenchen *) |
2 |
||
3 |
section \<open>Test of target-language bit operations\<close> |
|
4 |
||
5 |
theory Generate_Target_Bit_Operations |
|
6 |
imports |
|
7 |
"HOL-Library.Code_Test" |
|
8 |
begin |
|
9 |
||
|
81999
513f8fa74c82
more explicit tests for non-PolyML SML platforms
haftmann
parents:
81818
diff
changeset
|
10 |
context |
|
513f8fa74c82
more explicit tests for non-PolyML SML platforms
haftmann
parents:
81818
diff
changeset
|
11 |
includes bit_operations_syntax |
|
513f8fa74c82
more explicit tests for non-PolyML SML platforms
haftmann
parents:
81818
diff
changeset
|
12 |
begin |
| 81714 | 13 |
|
|
81999
513f8fa74c82
more explicit tests for non-PolyML SML platforms
haftmann
parents:
81818
diff
changeset
|
14 |
qualified definition computations where |
| 81714 | 15 |
\<open>computations = ( |
16 |
[bit (473514 :: integer) 5, bit (- 805167 :: integer) 7], |
|
17 |
[473514 AND 767063, - 805167 AND 767063, 473514 AND - 314527, - 805167 AND - 314527 :: integer], |
|
18 |
[473514 OR 767063, - 805167 OR 767063, 473514 OR - 314527, - 805167 OR - 314527 :: integer], |
|
19 |
[473514 XOR 767063, - 805167 XOR 767063, 473514 XOR - 314527, - 805167 XOR - 314527 :: integer], |
|
20 |
[NOT 473513, NOT (- 805167) :: integer], |
|
21 |
mask 39 :: integer, |
|
22 |
[set_bit 15 473514, set_bit 11 (- 805167) :: integer], |
|
23 |
[unset_bit 13 473514, unset_bit 12 (- 805167) :: integer], |
|
24 |
[flip_bit 15 473514, flip_bit 12 (- 805167) :: integer], |
|
25 |
[push_bit 12 473514, push_bit 12 (- 805167) :: integer], |
|
26 |
[drop_bit 12 473514, drop_bit 12 (- 805167) :: integer], |
|
27 |
[take_bit 12 473514, take_bit 12 (- 805167) :: integer], |
|
28 |
[signed_take_bit 12 473514, signed_take_bit 12 (- 805167) :: integer] |
|
29 |
)\<close> |
|
30 |
||
|
81999
513f8fa74c82
more explicit tests for non-PolyML SML platforms
haftmann
parents:
81818
diff
changeset
|
31 |
qualified definition results where |
| 81714 | 32 |
\<open>results = ( |
33 |
[True, True], |
|
34 |
[208898, 242769, 209184, - 839103 :: integer], |
|
35 |
[1031679, - 280873, - 50197, - 280591 :: integer], |
|
36 |
[822781, - 523642, - 259381, 558512 :: integer], |
|
37 |
[- 473514, 805166 :: integer], |
|
38 |
549755813887 :: integer, |
|
39 |
[506282, - 803119 :: integer], |
|
40 |
[465322, - 809263 :: integer], |
|
41 |
[506282, - 809263 :: integer], |
|
42 |
[1939513344, - 3297964032 :: integer], |
|
43 |
[115, - 197 :: integer], |
|
44 |
[2474, 1745 :: integer], |
|
45 |
[- 1622, - 2351 :: integer] |
|
46 |
)\<close> |
|
47 |
||
|
81999
513f8fa74c82
more explicit tests for non-PolyML SML platforms
haftmann
parents:
81818
diff
changeset
|
48 |
qualified definition check where |
| 81714 | 49 |
\<open>check \<longleftrightarrow> computations = results\<close> |
50 |
||
51 |
lemma check |
|
52 |
by code_simp |
|
53 |
||
54 |
lemma check |
|
55 |
by normalization |
|
56 |
||
57 |
lemma check |
|
58 |
by eval |
|
59 |
||
60 |
test_code check in Scala |
|
61 |
||
|
81999
513f8fa74c82
more explicit tests for non-PolyML SML platforms
haftmann
parents:
81818
diff
changeset
|
62 |
end |
| 81818 | 63 |
|
| 81714 | 64 |
end |