| author | wenzelm | 
| Sat, 23 May 2020 21:58:44 +0200 | |
| changeset 71872 | b5191ededb6c | 
| parent 70342 | e4d626692640 | 
| permissions | -rw-r--r-- | 
| 70342 
e4d626692640
clear separation of types for bits (False / True) and Z2 (0 / 1)
 haftmann parents: 
70191diff
changeset | 1 | (* Title: HOL/Word/Bits_Z2.thy | 
| 54224 
9fda41a04c32
separated bit operations on type bit from generic syntactic bit operations
 haftmann parents: diff
changeset | 2 | Author: Author: Brian Huffman, PSU and Gerwin Klein, NICTA | 
| 
9fda41a04c32
separated bit operations on type bit from generic syntactic bit operations
 haftmann parents: diff
changeset | 3 | *) | 
| 
9fda41a04c32
separated bit operations on type bit from generic syntactic bit operations
 haftmann parents: diff
changeset | 4 | |
| 61799 | 5 | section \<open>Bit operations in $\cal Z_2$\<close> | 
| 54224 
9fda41a04c32
separated bit operations on type bit from generic syntactic bit operations
 haftmann parents: diff
changeset | 6 | |
| 70342 
e4d626692640
clear separation of types for bits (False / True) and Z2 (0 / 1)
 haftmann parents: 
70191diff
changeset | 7 | theory Bits_Z2 | 
| 
e4d626692640
clear separation of types for bits (False / True) and Z2 (0 / 1)
 haftmann parents: 
70191diff
changeset | 8 | imports Bits "HOL-Library.Z2" | 
| 54224 
9fda41a04c32
separated bit operations on type bit from generic syntactic bit operations
 haftmann parents: diff
changeset | 9 | begin | 
| 
9fda41a04c32
separated bit operations on type bit from generic syntactic bit operations
 haftmann parents: diff
changeset | 10 | |
| 70191 | 11 | instantiation bit :: bit_operations | 
| 54224 
9fda41a04c32
separated bit operations on type bit from generic syntactic bit operations
 haftmann parents: diff
changeset | 12 | begin | 
| 
9fda41a04c32
separated bit operations on type bit from generic syntactic bit operations
 haftmann parents: diff
changeset | 13 | |
| 65363 | 14 | primrec bitNOT_bit | 
| 15 | where | |
| 16 | "NOT 0 = (1::bit)" | |
| 54224 
9fda41a04c32
separated bit operations on type bit from generic syntactic bit operations
 haftmann parents: diff
changeset | 17 | | "NOT 1 = (0::bit)" | 
| 
9fda41a04c32
separated bit operations on type bit from generic syntactic bit operations
 haftmann parents: diff
changeset | 18 | |
| 65363 | 19 | primrec bitAND_bit | 
| 20 | where | |
| 21 | "0 AND y = (0::bit)" | |
| 54224 
9fda41a04c32
separated bit operations on type bit from generic syntactic bit operations
 haftmann parents: diff
changeset | 22 | | "1 AND y = (y::bit)" | 
| 
9fda41a04c32
separated bit operations on type bit from generic syntactic bit operations
 haftmann parents: diff
changeset | 23 | |
| 65363 | 24 | primrec bitOR_bit | 
| 25 | where | |
| 26 | "0 OR y = (y::bit)" | |
| 54224 
9fda41a04c32
separated bit operations on type bit from generic syntactic bit operations
 haftmann parents: diff
changeset | 27 | | "1 OR y = (1::bit)" | 
| 
9fda41a04c32
separated bit operations on type bit from generic syntactic bit operations
 haftmann parents: diff
changeset | 28 | |
| 65363 | 29 | primrec bitXOR_bit | 
| 30 | where | |
| 31 | "0 XOR y = (y::bit)" | |
| 54224 
9fda41a04c32
separated bit operations on type bit from generic syntactic bit operations
 haftmann parents: diff
changeset | 32 | | "1 XOR y = (NOT y :: bit)" | 
| 
9fda41a04c32
separated bit operations on type bit from generic syntactic bit operations
 haftmann parents: diff
changeset | 33 | |
| 
9fda41a04c32
separated bit operations on type bit from generic syntactic bit operations
 haftmann parents: diff
changeset | 34 | instance .. | 
| 
9fda41a04c32
separated bit operations on type bit from generic syntactic bit operations
 haftmann parents: diff
changeset | 35 | |
| 
9fda41a04c32
separated bit operations on type bit from generic syntactic bit operations
 haftmann parents: diff
changeset | 36 | end | 
| 
9fda41a04c32
separated bit operations on type bit from generic syntactic bit operations
 haftmann parents: diff
changeset | 37 | |
| 
9fda41a04c32
separated bit operations on type bit from generic syntactic bit operations
 haftmann parents: diff
changeset | 38 | lemmas bit_simps = | 
| 
9fda41a04c32
separated bit operations on type bit from generic syntactic bit operations
 haftmann parents: diff
changeset | 39 | bitNOT_bit.simps bitAND_bit.simps bitOR_bit.simps bitXOR_bit.simps | 
| 
9fda41a04c32
separated bit operations on type bit from generic syntactic bit operations
 haftmann parents: diff
changeset | 40 | |
| 65363 | 41 | lemma bit_extra_simps [simp]: | 
| 42 | "x AND 0 = 0" | |
| 43 | "x AND 1 = x" | |
| 44 | "x OR 1 = 1" | |
| 45 | "x OR 0 = x" | |
| 46 | "x XOR 1 = NOT x" | |
| 47 | "x XOR 0 = x" | |
| 48 | for x :: bit | |
| 67120 | 49 | by (cases x; auto)+ | 
| 54224 
9fda41a04c32
separated bit operations on type bit from generic syntactic bit operations
 haftmann parents: diff
changeset | 50 | |
| 65363 | 51 | lemma bit_ops_comm: | 
| 52 | "x AND y = y AND x" | |
| 53 | "x OR y = y OR x" | |
| 54 | "x XOR y = y XOR x" | |
| 55 | for x :: bit | |
| 67120 | 56 | by (cases y; auto)+ | 
| 54224 
9fda41a04c32
separated bit operations on type bit from generic syntactic bit operations
 haftmann parents: diff
changeset | 57 | |
| 65363 | 58 | lemma bit_ops_same [simp]: | 
| 59 | "x AND x = x" | |
| 60 | "x OR x = x" | |
| 61 | "x XOR x = 0" | |
| 62 | for x :: bit | |
| 67120 | 63 | by (cases x; auto)+ | 
| 54224 
9fda41a04c32
separated bit operations on type bit from generic syntactic bit operations
 haftmann parents: diff
changeset | 64 | |
| 65363 | 65 | lemma bit_not_not [simp]: "NOT (NOT x) = x" | 
| 66 | for x :: bit | |
| 54224 
9fda41a04c32
separated bit operations on type bit from generic syntactic bit operations
 haftmann parents: diff
changeset | 67 | by (cases x) auto | 
| 
9fda41a04c32
separated bit operations on type bit from generic syntactic bit operations
 haftmann parents: diff
changeset | 68 | |
| 65363 | 69 | lemma bit_or_def: "b OR c = NOT (NOT b AND NOT c)" | 
| 70 | for b c :: bit | |
| 71 | by (induct b) simp_all | |
| 54224 
9fda41a04c32
separated bit operations on type bit from generic syntactic bit operations
 haftmann parents: diff
changeset | 72 | |
| 65363 | 73 | lemma bit_xor_def: "b XOR c = (b AND NOT c) OR (NOT b AND c)" | 
| 74 | for b c :: bit | |
| 75 | by (induct b) simp_all | |
| 54224 
9fda41a04c32
separated bit operations on type bit from generic syntactic bit operations
 haftmann parents: diff
changeset | 76 | |
| 65363 | 77 | lemma bit_NOT_eq_1_iff [simp]: "NOT b = 1 \<longleftrightarrow> b = 0" | 
| 78 | for b :: bit | |
| 79 | by (induct b) simp_all | |
| 54224 
9fda41a04c32
separated bit operations on type bit from generic syntactic bit operations
 haftmann parents: diff
changeset | 80 | |
| 65363 | 81 | lemma bit_AND_eq_1_iff [simp]: "a AND b = 1 \<longleftrightarrow> a = 1 \<and> b = 1" | 
| 82 | for a b :: bit | |
| 83 | by (induct a) simp_all | |
| 54224 
9fda41a04c32
separated bit operations on type bit from generic syntactic bit operations
 haftmann parents: diff
changeset | 84 | |
| 70183 
3ea80c950023
incorporated various material from the AFP into the distribution
 haftmann parents: 
67120diff
changeset | 85 | lemma bit_nand_same [simp]: "x AND NOT x = 0" | 
| 
3ea80c950023
incorporated various material from the AFP into the distribution
 haftmann parents: 
67120diff
changeset | 86 | for x :: bit | 
| 
3ea80c950023
incorporated various material from the AFP into the distribution
 haftmann parents: 
67120diff
changeset | 87 | by (cases x) simp_all | 
| 
3ea80c950023
incorporated various material from the AFP into the distribution
 haftmann parents: 
67120diff
changeset | 88 | |
| 54224 
9fda41a04c32
separated bit operations on type bit from generic syntactic bit operations
 haftmann parents: diff
changeset | 89 | end |