src/HOL/Word/Bits.thy
author paulson <lp15@cam.ac.uk>
Tue Apr 25 16:39:54 2017 +0100 (2017-04-25)
changeset 65578 e4997c181cce
parent 65363 5eb619751b14
child 70175 85fb1a585f52
permissions -rw-r--r--
New material from PNT proof, as well as more default [simp] declarations. Also removed duplicate theorems about geometric series
wenzelm@55210
     1
(*  Title:      HOL/Word/Bits.thy
haftmann@37655
     2
    Author:     Author: Brian Huffman, PSU and Gerwin Klein, NICTA
kleing@24334
     3
*)
kleing@24334
     4
wenzelm@61799
     5
section \<open>Syntactic classes for bitwise operations\<close>
kleing@24333
     6
haftmann@54854
     7
theory Bits
wenzelm@65363
     8
  imports Main
kleing@24333
     9
begin
kleing@24333
    10
haftmann@29608
    11
class bit =
wenzelm@65363
    12
  fixes bitNOT :: "'a \<Rightarrow> 'a"  ("NOT _" [70] 71)
wenzelm@65363
    13
    and bitAND :: "'a \<Rightarrow> 'a \<Rightarrow> 'a"  (infixr "AND" 64)
wenzelm@65363
    14
    and bitOR :: "'a \<Rightarrow> 'a \<Rightarrow> 'a"  (infixr "OR"  59)
wenzelm@65363
    15
    and bitXOR :: "'a \<Rightarrow> 'a \<Rightarrow> 'a"  (infixr "XOR" 59)
kleing@24333
    16
wenzelm@61799
    17
text \<open>
kleing@24333
    18
  We want the bitwise operations to bind slightly weaker
wenzelm@65363
    19
  than \<open>+\<close> and \<open>-\<close>, but \<open>~~\<close> to
wenzelm@61799
    20
  bind slightly stronger than \<open>*\<close>.
wenzelm@61799
    21
\<close>
huffman@24352
    22
wenzelm@65363
    23
text \<open>Testing and shifting operations.\<close>
haftmann@26559
    24
haftmann@26559
    25
class bits = bit +
wenzelm@65363
    26
  fixes test_bit :: "'a \<Rightarrow> nat \<Rightarrow> bool"  (infixl "!!" 100)
wenzelm@65363
    27
    and lsb :: "'a \<Rightarrow> bool"
wenzelm@65363
    28
    and set_bit :: "'a \<Rightarrow> nat \<Rightarrow> bool \<Rightarrow> 'a"
wenzelm@65363
    29
    and set_bits :: "(nat \<Rightarrow> bool) \<Rightarrow> 'a"  (binder "BITS " 10)
wenzelm@65363
    30
    and shiftl :: "'a \<Rightarrow> nat \<Rightarrow> 'a"  (infixl "<<" 55)
wenzelm@65363
    31
    and shiftr :: "'a \<Rightarrow> nat \<Rightarrow> 'a"  (infixl ">>" 55)
haftmann@26559
    32
haftmann@26559
    33
class bitss = bits +
wenzelm@65363
    34
  fixes msb :: "'a \<Rightarrow> bool"
kleing@24333
    35
haftmann@25762
    36
end