| author | immler | 
| Tue, 04 Jul 2017 09:36:25 +0100 | |
| changeset 66252 | b73f94b366b7 | 
| parent 65363 | 5eb619751b14 | 
| child 66453 | cc19f7ca2ed6 | 
| permissions | -rw-r--r-- | 
| 55210 | 1 | (* Title: HOL/Word/Bits_Bit.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 | |
| 54854 
3324a0078636
prefer "Bits" as theory name for abstract bit operations, similar to "Orderings", "Lattices", "Groups" etc.
 haftmann parents: 
54394diff
changeset | 7 | theory Bits_Bit | 
| 
3324a0078636
prefer "Bits" as theory name for abstract bit operations, similar to "Orderings", "Lattices", "Groups" etc.
 haftmann parents: 
54394diff
changeset | 8 | imports Bits "~~/src/HOL/Library/Bit" | 
| 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 | |
| 
9fda41a04c32
separated bit operations on type bit from generic syntactic bit operations
 haftmann parents: diff
changeset | 11 | instantiation bit :: bit | 
| 
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 | |
| 54224 
9fda41a04c32
separated bit operations on type bit from generic syntactic bit operations
 haftmann parents: diff
changeset | 49 | by (cases x, auto)+ | 
| 
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 | |
| 54224 
9fda41a04c32
separated bit operations on type bit from generic syntactic bit operations
 haftmann parents: diff
changeset | 56 | by (cases y, auto)+ | 
| 
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 | |
| 54224 
9fda41a04c32
separated bit operations on type bit from generic syntactic bit operations
 haftmann parents: diff
changeset | 63 | by (cases x, auto)+ | 
| 
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 | |
| 
9fda41a04c32
separated bit operations on type bit from generic syntactic bit operations
 haftmann parents: diff
changeset | 85 | end |