src/HOL/Word/Bits.thy
changeset 61799 4cf66f21b764
parent 58874 7172c7ffb047
child 65363 5eb619751b14
equal deleted inserted replaced
61798:27f3c10b0b50 61799:4cf66f21b764
     1 (*  Title:      HOL/Word/Bits.thy
     1 (*  Title:      HOL/Word/Bits.thy
     2     Author:     Author: Brian Huffman, PSU and Gerwin Klein, NICTA
     2     Author:     Author: Brian Huffman, PSU and Gerwin Klein, NICTA
     3 *)
     3 *)
     4 
     4 
     5 section {* Syntactic classes for bitwise operations *}
     5 section \<open>Syntactic classes for bitwise operations\<close>
     6 
     6 
     7 theory Bits
     7 theory Bits
     8 imports Main
     8 imports Main
     9 begin
     9 begin
    10 
    10 
    12   fixes bitNOT :: "'a \<Rightarrow> 'a"       ("NOT _" [70] 71)
    12   fixes bitNOT :: "'a \<Rightarrow> 'a"       ("NOT _" [70] 71)
    13     and bitAND :: "'a \<Rightarrow> 'a \<Rightarrow> 'a" (infixr "AND" 64)
    13     and bitAND :: "'a \<Rightarrow> 'a \<Rightarrow> 'a" (infixr "AND" 64)
    14     and bitOR  :: "'a \<Rightarrow> 'a \<Rightarrow> 'a" (infixr "OR"  59)
    14     and bitOR  :: "'a \<Rightarrow> 'a \<Rightarrow> 'a" (infixr "OR"  59)
    15     and bitXOR :: "'a \<Rightarrow> 'a \<Rightarrow> 'a" (infixr "XOR" 59)
    15     and bitXOR :: "'a \<Rightarrow> 'a \<Rightarrow> 'a" (infixr "XOR" 59)
    16 
    16 
    17 text {*
    17 text \<open>
    18   We want the bitwise operations to bind slightly weaker
    18   We want the bitwise operations to bind slightly weaker
    19   than @{text "+"} and @{text "-"}, but @{text "~~"} to 
    19   than \<open>+\<close> and \<open>-\<close>, but \<open>~~\<close> to 
    20   bind slightly stronger than @{text "*"}.
    20   bind slightly stronger than \<open>*\<close>.
    21 *}
    21 \<close>
    22 
    22 
    23 text {*
    23 text \<open>
    24   Testing and shifting operations.
    24   Testing and shifting operations.
    25 *}
    25 \<close>
    26 
    26 
    27 class bits = bit +
    27 class bits = bit +
    28   fixes test_bit :: "'a \<Rightarrow> nat \<Rightarrow> bool" (infixl "!!" 100)
    28   fixes test_bit :: "'a \<Rightarrow> nat \<Rightarrow> bool" (infixl "!!" 100)
    29     and lsb      :: "'a \<Rightarrow> bool"
    29     and lsb      :: "'a \<Rightarrow> bool"
    30     and set_bit  :: "'a \<Rightarrow> nat \<Rightarrow> bool \<Rightarrow> 'a"
    30     and set_bit  :: "'a \<Rightarrow> nat \<Rightarrow> bool \<Rightarrow> 'a"