src/HOL/Integ/Numeral.thy
changeset 22744 5cbe966d67a2
parent 22473 753123c89d72
child 22801 caffcb450ef4
equal deleted inserted replaced
22743:e2b06bfe471a 22744:5cbe966d67a2
    30 
    30 
    31 datatype bit = B0 | B1
    31 datatype bit = B0 | B1
    32 
    32 
    33 definition
    33 definition
    34   Pls :: int where
    34   Pls :: int where
    35   "Pls = 0"
    35   [code nofunc]:"Pls = 0"
    36 
    36 
    37 definition
    37 definition
    38   Min :: int where
    38   Min :: int where
    39   "Min = - 1"
    39   [code nofunc]:"Min = - 1"
    40 
    40 
    41 definition
    41 definition
    42   Bit :: "int \<Rightarrow> bit \<Rightarrow> int" (infixl "BIT" 90) where
    42   Bit :: "int \<Rightarrow> bit \<Rightarrow> int" (infixl "BIT" 90) where
    43   "k BIT b = (case b of B0 \<Rightarrow> 0 | B1 \<Rightarrow> 1) + k + k"
    43   [code nofunc]: "k BIT b = (case b of B0 \<Rightarrow> 0 | B1 \<Rightarrow> 1) + k + k"
    44 
    44 
    45 class number = type + -- {* for numeric types: nat, int, real, \dots *}
    45 class number = type + -- {* for numeric types: nat, int, real, \dots *}
    46   fixes number_of :: "int \<Rightarrow> 'a"
    46   fixes number_of :: "int \<Rightarrow> 'a"
    47 
    47 
    48 syntax
    48 syntax
    66 lemma Let_1 [simp]: "Let 1 f = f 1"
    66 lemma Let_1 [simp]: "Let 1 f = f 1"
    67   unfolding Let_def ..
    67   unfolding Let_def ..
    68 
    68 
    69 definition
    69 definition
    70   succ :: "int \<Rightarrow> int" where
    70   succ :: "int \<Rightarrow> int" where
    71   "succ k = k + 1"
    71   [code nofunc]: "succ k = k + 1"
    72 
    72 
    73 definition
    73 definition
    74   pred :: "int \<Rightarrow> int" where
    74   pred :: "int \<Rightarrow> int" where
    75   "pred k = k - 1"
    75   [code nofunc]: "pred k = k - 1"
    76 
    76 
    77 declare
    77 declare
    78  max_def[of "number_of u" "number_of v", standard, simp]
    78  max_def[of "number_of u" "number_of v", standard, simp]
    79  min_def[of "number_of u" "number_of v", standard, simp]
    79  min_def[of "number_of u" "number_of v", standard, simp]
    80   -- {* unfolding @{text minx} and @{text max} on numerals *}
    80   -- {* unfolding @{text minx} and @{text max} on numerals *}