src/HOL/Integ/Numeral.thy
author haftmann
Fri, 20 Apr 2007 11:21:42 +0200
changeset 22744 5cbe966d67a2
parent 22473 753123c89d72
child 22801 caffcb450ef4
permissions -rw-r--r--
Isar definitions are now added explicitly to code theorem table
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
     1
(*  Title:      HOL/Integ/Numeral.thy
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
     2
    ID:         $Id$
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
     4
    Copyright   1994  University of Cambridge
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
     5
*)
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
     6
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
     7
header {* Arithmetic on Binary Integers *}
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
     8
15131
c69542757a4d New theory header syntax.
nipkow
parents: 15013
diff changeset
     9
theory Numeral
15620
8ccdc8bc66a2 replaced bool by a new datatype "bit" for binary numerals
paulson
parents: 15140
diff changeset
    10
imports IntDef Datatype
16417
9bc16273c2d4 migrated theory headers to new format
haftmann
parents: 15620
diff changeset
    11
uses "../Tools/numeral_syntax.ML"
15131
c69542757a4d New theory header syntax.
nipkow
parents: 15013
diff changeset
    12
begin
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
    13
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
    14
text {*
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
    15
  This formalization defines binary arithmetic in terms of the integers
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
    16
  rather than using a datatype. This avoids multiple representations (leading
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
    17
  zeroes, etc.)  See @{text "ZF/Integ/twos-compl.ML"}, function @{text
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
    18
  int_of_binary}, for the numerical interpretation.
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
    19
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
    20
  The representation expects that @{text "(m mod 2)"} is 0 or 1,
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
    21
  even if m is negative;
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
    22
  For instance, @{text "-5 div 2 = -3"} and @{text "-5 mod 2 = 1"}; thus
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
    23
  @{text "-5 = (-3)*2 + 1"}.
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
    24
*}
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
    25
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
    26
text{*
21834
770ce948a59b clarifed comment
haftmann
parents: 21820
diff changeset
    27
  This type avoids the use of type @{typ bool}, which would make
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
    28
  all of the rewrite rules higher-order.
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
    29
*}
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
    30
15620
8ccdc8bc66a2 replaced bool by a new datatype "bit" for binary numerals
paulson
parents: 15140
diff changeset
    31
datatype bit = B0 | B1
8ccdc8bc66a2 replaced bool by a new datatype "bit" for binary numerals
paulson
parents: 15140
diff changeset
    32
21779
6d44dbae4bfa authentic syntax for Pls/Min/Bit;
wenzelm
parents: 21404
diff changeset
    33
definition
21820
2f2b6a965ccc introduced mk/dest_numeral/number for mk/dest_binum etc.
haftmann
parents: 21779
diff changeset
    34
  Pls :: int where
22744
5cbe966d67a2 Isar definitions are now added explicitly to code theorem table
haftmann
parents: 22473
diff changeset
    35
  [code nofunc]:"Pls = 0"
21779
6d44dbae4bfa authentic syntax for Pls/Min/Bit;
wenzelm
parents: 21404
diff changeset
    36
6d44dbae4bfa authentic syntax for Pls/Min/Bit;
wenzelm
parents: 21404
diff changeset
    37
definition
21820
2f2b6a965ccc introduced mk/dest_numeral/number for mk/dest_binum etc.
haftmann
parents: 21779
diff changeset
    38
  Min :: int where
22744
5cbe966d67a2 Isar definitions are now added explicitly to code theorem table
haftmann
parents: 22473
diff changeset
    39
  [code nofunc]:"Min = - 1"
21779
6d44dbae4bfa authentic syntax for Pls/Min/Bit;
wenzelm
parents: 21404
diff changeset
    40
6d44dbae4bfa authentic syntax for Pls/Min/Bit;
wenzelm
parents: 21404
diff changeset
    41
definition
6d44dbae4bfa authentic syntax for Pls/Min/Bit;
wenzelm
parents: 21404
diff changeset
    42
  Bit :: "int \<Rightarrow> bit \<Rightarrow> int" (infixl "BIT" 90) where
22744
5cbe966d67a2 Isar definitions are now added explicitly to code theorem table
haftmann
parents: 22473
diff changeset
    43
  [code nofunc]: "k BIT b = (case b of B0 \<Rightarrow> 0 | B1 \<Rightarrow> 1) + k + k"
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
    44
22473
753123c89d72 explizit "type" superclass
haftmann
parents: 22187
diff changeset
    45
class number = type + -- {* for numeric types: nat, int, real, \dots *}
21820
2f2b6a965ccc introduced mk/dest_numeral/number for mk/dest_binum etc.
haftmann
parents: 21779
diff changeset
    46
  fixes number_of :: "int \<Rightarrow> 'a"
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
    47
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
    48
syntax
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
    49
  "_Numeral" :: "num_const \<Rightarrow> 'a"    ("_")
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
    50
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
    51
setup NumeralSyntax.setup
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
    52
19380
b808efaa5828 tuned syntax/abbreviations;
wenzelm
parents: 16417
diff changeset
    53
abbreviation
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
    54
  "Numeral0 \<equiv> number_of Pls"
21404
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 20900
diff changeset
    55
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 20900
diff changeset
    56
abbreviation
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
    57
  "Numeral1 \<equiv> number_of (Pls BIT B1)"
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
    58
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
    59
lemma Let_number_of [simp]: "Let (number_of v) f = f (number_of v)"
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
    60
  -- {* Unfold all @{text let}s involving constants *}
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
    61
  unfolding Let_def ..
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
    62
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
    63
lemma Let_0 [simp]: "Let 0 f = f 0"
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
    64
  unfolding Let_def ..
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
    65
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
    66
lemma Let_1 [simp]: "Let 1 f = f 1"
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
    67
  unfolding Let_def ..
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
    68
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
    69
definition
21404
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 20900
diff changeset
    70
  succ :: "int \<Rightarrow> int" where
22744
5cbe966d67a2 Isar definitions are now added explicitly to code theorem table
haftmann
parents: 22473
diff changeset
    71
  [code nofunc]: "succ k = k + 1"
21404
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 20900
diff changeset
    72
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 20900
diff changeset
    73
definition
eb85850d3eb7 more robust syntax for definition/abbreviation/notation;
wenzelm
parents: 20900
diff changeset
    74
  pred :: "int \<Rightarrow> int" where
22744
5cbe966d67a2 Isar definitions are now added explicitly to code theorem table
haftmann
parents: 22473
diff changeset
    75
  [code nofunc]: "pred k = k - 1"
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
    76
22187
a2c4861363d5 Allows evaluation of min/max o numerals.
nipkow
parents: 21834
diff changeset
    77
declare
a2c4861363d5 Allows evaluation of min/max o numerals.
nipkow
parents: 21834
diff changeset
    78
 max_def[of "number_of u" "number_of v", standard, simp]
a2c4861363d5 Allows evaluation of min/max o numerals.
nipkow
parents: 21834
diff changeset
    79
 min_def[of "number_of u" "number_of v", standard, simp]
a2c4861363d5 Allows evaluation of min/max o numerals.
nipkow
parents: 21834
diff changeset
    80
  -- {* unfolding @{text minx} and @{text max} on numerals *}
a2c4861363d5 Allows evaluation of min/max o numerals.
nipkow
parents: 21834
diff changeset
    81
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
    82
lemmas numeral_simps = 
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
    83
  succ_def pred_def Pls_def Min_def Bit_def
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
    84
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
    85
text {* Removal of leading zeroes *}
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
    86
20699
0cc77abb185a refinements in codegen serializer
haftmann
parents: 20596
diff changeset
    87
lemma Pls_0_eq [simp, code func]:
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
    88
  "Pls BIT B0 = Pls"
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
    89
  unfolding numeral_simps by simp
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
    90
20699
0cc77abb185a refinements in codegen serializer
haftmann
parents: 20596
diff changeset
    91
lemma Min_1_eq [simp, code func]:
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
    92
  "Min BIT B1 = Min"
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
    93
  unfolding numeral_simps by simp
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
    94
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
    95
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
    96
subsection {* The Functions @{term succ}, @{term pred} and @{term uminus} *}
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
    97
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
    98
lemma succ_Pls [simp]:
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
    99
  "succ Pls = Pls BIT B1"
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   100
  unfolding numeral_simps by simp
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   101
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   102
lemma succ_Min [simp]:
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   103
  "succ Min = Pls"
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   104
  unfolding numeral_simps by simp
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   105
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   106
lemma succ_1 [simp]:
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   107
  "succ (k BIT B1) = succ k BIT B0"
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   108
  unfolding numeral_simps by simp
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   109
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   110
lemma succ_0 [simp]:
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   111
  "succ (k BIT B0) = k BIT B1"
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   112
  unfolding numeral_simps by simp
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   113
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   114
lemma pred_Pls [simp]:
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   115
  "pred Pls = Min"
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   116
  unfolding numeral_simps by simp
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   117
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   118
lemma pred_Min [simp]:
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   119
  "pred Min = Min BIT B0"
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   120
  unfolding numeral_simps by simp
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   121
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   122
lemma pred_1 [simp]:
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   123
  "pred (k BIT B1) = k BIT B0"
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   124
  unfolding numeral_simps by simp
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   125
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   126
lemma pred_0 [simp]:
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   127
  "pred (k BIT B0) = pred k BIT B1"
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   128
  unfolding numeral_simps by simp 
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   129
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   130
lemma minus_Pls [simp]:
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   131
  "- Pls = Pls"
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   132
  unfolding numeral_simps by simp 
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   133
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   134
lemma minus_Min [simp]:
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   135
  "- Min = Pls BIT B1"
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   136
  unfolding numeral_simps by simp 
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   137
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   138
lemma minus_1 [simp]:
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   139
  "- (k BIT B1) = pred (- k) BIT B1"
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   140
  unfolding numeral_simps by simp 
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   141
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   142
lemma minus_0 [simp]:
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   143
  "- (k BIT B0) = (- k) BIT B0"
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   144
  unfolding numeral_simps by simp 
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   145
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   146
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   147
subsection {*
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   148
  Binary Addition and Multiplication: @{term "op + \<Colon> int \<Rightarrow> int \<Rightarrow> int"}
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   149
    and @{term "op * \<Colon> int \<Rightarrow> int \<Rightarrow> int"}
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   150
*}
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   151
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   152
lemma add_Pls [simp]:
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   153
  "Pls + k = k"
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   154
  unfolding numeral_simps by simp 
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   155
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   156
lemma add_Min [simp]:
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   157
  "Min + k = pred k"
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   158
  unfolding numeral_simps by simp
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   159
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   160
lemma add_BIT_11 [simp]:
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   161
  "(k BIT B1) + (l BIT B1) = (k + succ l) BIT B0"
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   162
  unfolding numeral_simps by simp
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   163
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   164
lemma add_BIT_10 [simp]:
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   165
  "(k BIT B1) + (l BIT B0) = (k + l) BIT B1"
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   166
  unfolding numeral_simps by simp
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   167
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   168
lemma add_BIT_0 [simp]:
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   169
  "(k BIT B0) + (l BIT b) = (k + l) BIT b"
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   170
  unfolding numeral_simps by simp 
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   171
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   172
lemma add_Pls_right [simp]:
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   173
  "k + Pls = k"
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   174
  unfolding numeral_simps by simp 
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   175
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   176
lemma add_Min_right [simp]:
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   177
  "k + Min = pred k"
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   178
  unfolding numeral_simps by simp 
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   179
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   180
lemma mult_Pls [simp]:
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   181
  "Pls * w = Pls"
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   182
  unfolding numeral_simps by simp 
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   183
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   184
lemma mult_Min [simp]:
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   185
  "Min * k = - k"
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   186
  unfolding numeral_simps by simp 
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   187
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   188
lemma mult_num1 [simp]:
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   189
  "(k BIT B1) * l = ((k * l) BIT B0) + l"
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   190
  unfolding numeral_simps int_distrib by simp 
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   191
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   192
lemma mult_num0 [simp]:
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   193
  "(k BIT B0) * l = (k * l) BIT B0"
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   194
  unfolding numeral_simps int_distrib by simp 
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   195
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   196
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   197
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   198
subsection {* Converting Numerals to Rings: @{term number_of} *}
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   199
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   200
axclass number_ring \<subseteq> number, comm_ring_1
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   201
  number_of_eq: "number_of k = of_int k"
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   202
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   203
lemma number_of_succ:
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   204
  "number_of (succ k) = (1 + number_of k ::'a::number_ring)"
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   205
  unfolding number_of_eq numeral_simps by simp
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   206
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   207
lemma number_of_pred:
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   208
  "number_of (pred w) = (- 1 + number_of w ::'a::number_ring)"
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   209
  unfolding number_of_eq numeral_simps by simp
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   210
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   211
lemma number_of_minus:
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   212
  "number_of (uminus w) = (- (number_of w)::'a::number_ring)"
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   213
  unfolding number_of_eq numeral_simps by simp
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   214
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   215
lemma number_of_add:
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   216
  "number_of (v + w) = (number_of v + number_of w::'a::number_ring)"
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   217
  unfolding number_of_eq numeral_simps by simp
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   218
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   219
lemma number_of_mult:
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   220
  "number_of (v * w) = (number_of v * number_of w::'a::number_ring)"
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   221
  unfolding number_of_eq numeral_simps by simp
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   222
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   223
text {*
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   224
  The correctness of shifting.
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   225
  But it doesn't seem to give a measurable speed-up.
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   226
*}
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   227
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   228
lemma double_number_of_BIT:
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   229
  "(1 + 1) * number_of w = (number_of (w BIT B0) ::'a::number_ring)"
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   230
  unfolding number_of_eq numeral_simps left_distrib by simp
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   231
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   232
text {*
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   233
  Converting numerals 0 and 1 to their abstract versions.
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   234
*}
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   235
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   236
lemma numeral_0_eq_0 [simp]:
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   237
  "Numeral0 = (0::'a::number_ring)"
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   238
  unfolding number_of_eq numeral_simps by simp
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   239
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   240
lemma numeral_1_eq_1 [simp]:
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   241
  "Numeral1 = (1::'a::number_ring)"
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   242
  unfolding number_of_eq numeral_simps by simp
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   243
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   244
text {*
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   245
  Special-case simplification for small constants.
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   246
*}
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   247
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   248
text{*
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   249
  Unary minus for the abstract constant 1. Cannot be inserted
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   250
  as a simprule until later: it is @{text number_of_Min} re-oriented!
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   251
*}
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   252
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   253
lemma numeral_m1_eq_minus_1:
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   254
  "(-1::'a::number_ring) = - 1"
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   255
  unfolding number_of_eq numeral_simps by simp
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   256
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   257
lemma mult_minus1 [simp]:
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   258
  "-1 * z = -(z::'a::number_ring)"
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   259
  unfolding number_of_eq numeral_simps by simp
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   260
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   261
lemma mult_minus1_right [simp]:
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   262
  "z * -1 = -(z::'a::number_ring)"
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   263
  unfolding number_of_eq numeral_simps by simp
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   264
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   265
(*Negation of a coefficient*)
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   266
lemma minus_number_of_mult [simp]:
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   267
   "- (number_of w) * z = number_of (uminus w) * (z::'a::number_ring)"
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   268
   unfolding number_of_eq by simp
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   269
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   270
text {* Subtraction *}
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   271
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   272
lemma diff_number_of_eq:
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   273
  "number_of v - number_of w =
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   274
    (number_of (v + uminus w)::'a::number_ring)"
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   275
  unfolding number_of_eq by simp
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   276
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   277
lemma number_of_Pls:
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   278
  "number_of Pls = (0::'a::number_ring)"
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   279
  unfolding number_of_eq numeral_simps by simp
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   280
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   281
lemma number_of_Min:
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   282
  "number_of Min = (- 1::'a::number_ring)"
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   283
  unfolding number_of_eq numeral_simps by simp
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   284
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   285
lemma number_of_BIT:
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   286
  "number_of(w BIT x) = (case x of B0 => 0 | B1 => (1::'a::number_ring))
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   287
    + (number_of w) + (number_of w)"
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   288
  unfolding number_of_eq numeral_simps by (simp split: bit.split)
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   289
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   290
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   291
subsection {* Equality of Binary Numbers *}
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   292
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   293
text {* First version by Norbert Voelker *}
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   294
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   295
lemma eq_number_of_eq:
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   296
  "((number_of x::'a::number_ring) = number_of y) =
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   297
   iszero (number_of (x + uminus y) :: 'a)"
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   298
  unfolding iszero_def number_of_add number_of_minus
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   299
  by (simp add: compare_rls)
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   300
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   301
lemma iszero_number_of_Pls:
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   302
  "iszero ((number_of Pls)::'a::number_ring)"
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   303
  unfolding iszero_def numeral_0_eq_0 ..
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   304
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   305
lemma nonzero_number_of_Min:
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   306
  "~ iszero ((number_of Min)::'a::number_ring)"
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   307
  unfolding iszero_def numeral_m1_eq_minus_1 by simp
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   308
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   309
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   310
subsection {* Comparisons, for Ordered Rings *}
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   311
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   312
lemma double_eq_0_iff:
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   313
  "(a + a = 0) = (a = (0::'a::ordered_idom))"
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   314
proof -
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   315
  have "a + a = (1 + 1) * a" unfolding left_distrib by simp
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   316
  with zero_less_two [where 'a = 'a]
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   317
  show ?thesis by force
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   318
qed
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   319
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   320
lemma le_imp_0_less: 
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   321
  assumes le: "0 \<le> z"
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   322
  shows "(0::int) < 1 + z"
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   323
proof -
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   324
  have "0 \<le> z" .
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   325
  also have "... < z + 1" by (rule less_add_one) 
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   326
  also have "... = 1 + z" by (simp add: add_ac)
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   327
  finally show "0 < 1 + z" .
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   328
qed
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   329
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   330
lemma odd_nonzero:
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   331
  "1 + z + z \<noteq> (0::int)";
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   332
proof (cases z rule: int_cases)
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   333
  case (nonneg n)
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   334
  have le: "0 \<le> z+z" by (simp add: nonneg add_increasing) 
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   335
  thus ?thesis using  le_imp_0_less [OF le]
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   336
    by (auto simp add: add_assoc) 
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   337
next
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   338
  case (neg n)
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   339
  show ?thesis
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   340
  proof
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   341
    assume eq: "1 + z + z = 0"
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   342
    have "0 < 1 + (int n + int n)"
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   343
      by (simp add: le_imp_0_less add_increasing) 
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   344
    also have "... = - (1 + z + z)" 
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   345
      by (simp add: neg add_assoc [symmetric]) 
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   346
    also have "... = 0" by (simp add: eq) 
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   347
    finally have "0<0" ..
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   348
    thus False by blast
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   349
  qed
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   350
qed
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   351
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   352
text {* The premise involving @{term Ints} prevents @{term "a = 1/2"}. *}
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   353
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   354
lemma Ints_odd_nonzero:
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   355
  assumes in_Ints: "a \<in> Ints"
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   356
  shows "1 + a + a \<noteq> (0::'a::ordered_idom)"
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   357
proof -
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   358
  from in_Ints have "a \<in> range of_int" unfolding Ints_def [symmetric] .
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   359
  then obtain z where a: "a = of_int z" ..
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   360
  show ?thesis
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   361
  proof
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   362
    assume eq: "1 + a + a = 0"
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   363
    hence "of_int (1 + z + z) = (of_int 0 :: 'a)" by (simp add: a)
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   364
    hence "1 + z + z = 0" by (simp only: of_int_eq_iff)
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   365
    with odd_nonzero show False by blast
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   366
  qed
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   367
qed 
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   368
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   369
lemma Ints_number_of:
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   370
  "(number_of w :: 'a::number_ring) \<in> Ints"
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   371
  unfolding number_of_eq Ints_def by simp
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   372
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   373
lemma iszero_number_of_BIT:
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   374
  "iszero (number_of (w BIT x)::'a) = 
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   375
   (x = B0 \<and> iszero (number_of w::'a::{ordered_idom,number_ring}))"
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   376
  by (simp add: iszero_def number_of_eq numeral_simps double_eq_0_iff 
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   377
    Ints_odd_nonzero Ints_def split: bit.split)
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   378
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   379
lemma iszero_number_of_0:
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   380
  "iszero (number_of (w BIT B0) :: 'a::{ordered_idom,number_ring}) = 
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   381
  iszero (number_of w :: 'a)"
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   382
  by (simp only: iszero_number_of_BIT simp_thms)
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   383
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   384
lemma iszero_number_of_1:
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   385
  "~ iszero (number_of (w BIT B1)::'a::{ordered_idom,number_ring})"
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   386
  by (simp add: iszero_number_of_BIT) 
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   387
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   388
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   389
subsection {* The Less-Than Relation *}
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   390
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   391
lemma less_number_of_eq_neg:
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   392
  "((number_of x::'a::{ordered_idom,number_ring}) < number_of y)
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   393
  = neg (number_of (x + uminus y) :: 'a)"
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   394
apply (subst less_iff_diff_less_0) 
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   395
apply (simp add: neg_def diff_minus number_of_add number_of_minus)
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   396
done
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   397
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   398
text {*
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   399
  If @{term Numeral0} is rewritten to 0 then this rule can't be applied:
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   400
  @{term Numeral0} IS @{term "number_of Pls"}
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   401
*}
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   402
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   403
lemma not_neg_number_of_Pls:
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   404
  "~ neg (number_of Pls ::'a::{ordered_idom,number_ring})"
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   405
  by (simp add: neg_def numeral_0_eq_0)
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   406
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   407
lemma neg_number_of_Min:
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   408
  "neg (number_of Min ::'a::{ordered_idom,number_ring})"
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   409
  by (simp add: neg_def zero_less_one numeral_m1_eq_minus_1)
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   410
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   411
lemma double_less_0_iff:
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   412
  "(a + a < 0) = (a < (0::'a::ordered_idom))"
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   413
proof -
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   414
  have "(a + a < 0) = ((1+1)*a < 0)" by (simp add: left_distrib)
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   415
  also have "... = (a < 0)"
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   416
    by (simp add: mult_less_0_iff zero_less_two 
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   417
                  order_less_not_sym [OF zero_less_two]) 
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   418
  finally show ?thesis .
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   419
qed
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   420
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   421
lemma odd_less_0:
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   422
  "(1 + z + z < 0) = (z < (0::int))";
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   423
proof (cases z rule: int_cases)
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   424
  case (nonneg n)
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   425
  thus ?thesis by (simp add: linorder_not_less add_assoc add_increasing
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   426
                             le_imp_0_less [THEN order_less_imp_le])  
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   427
next
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   428
  case (neg n)
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   429
  thus ?thesis by (simp del: int_Suc
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   430
    add: int_Suc0_eq_1 [symmetric] zadd_int compare_rls)
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   431
qed
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   432
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   433
text {* The premise involving @{term Ints} prevents @{term "a = 1/2"}. *}
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   434
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   435
lemma Ints_odd_less_0: 
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   436
  assumes in_Ints: "a \<in> Ints"
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   437
  shows "(1 + a + a < 0) = (a < (0::'a::ordered_idom))";
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   438
proof -
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   439
  from in_Ints have "a \<in> range of_int" unfolding Ints_def [symmetric] .
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   440
  then obtain z where a: "a = of_int z" ..
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   441
  hence "((1::'a) + a + a < 0) = (of_int (1 + z + z) < (of_int 0 :: 'a))"
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   442
    by (simp add: a)
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   443
  also have "... = (z < 0)" by (simp only: of_int_less_iff odd_less_0)
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   444
  also have "... = (a < 0)" by (simp add: a)
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   445
  finally show ?thesis .
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   446
qed
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   447
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   448
lemma neg_number_of_BIT:
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   449
  "neg (number_of (w BIT x)::'a) = 
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   450
  neg (number_of w :: 'a::{ordered_idom,number_ring})"
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   451
  by (simp add: neg_def number_of_eq numeral_simps double_less_0_iff
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   452
    Ints_odd_less_0 Ints_def split: bit.split)
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   453
20596
haftmann
parents: 20500
diff changeset
   454
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   455
text {* Less-Than or Equals *}
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   456
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   457
text {* Reduces @{term "a\<le>b"} to @{term "~ (b<a)"} for ALL numerals. *}
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   458
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   459
lemmas le_number_of_eq_not_less =
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   460
  linorder_not_less [of "number_of w" "number_of v", symmetric, 
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   461
  standard]
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   462
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   463
lemma le_number_of_eq:
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   464
    "((number_of x::'a::{ordered_idom,number_ring}) \<le> number_of y)
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   465
     = (~ (neg (number_of (y + uminus x) :: 'a)))"
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   466
by (simp add: le_number_of_eq_not_less less_number_of_eq_neg)
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   467
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   468
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   469
text {* Absolute value (@{term abs}) *}
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   470
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   471
lemma abs_number_of:
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   472
  "abs(number_of x::'a::{ordered_idom,number_ring}) =
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   473
   (if number_of x < (0::'a) then -number_of x else number_of x)"
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   474
  by (simp add: abs_if)
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   475
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   476
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   477
text {* Re-orientation of the equation nnn=x *}
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   478
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   479
lemma number_of_reorient:
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   480
  "(number_of w = x) = (x = number_of w)"
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   481
  by auto
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   482
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   483
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   484
subsection {* Simplification of arithmetic operations on integer constants. *}
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   485
20900
c1ba49ade6a5 standardized facts;
wenzelm
parents: 20699
diff changeset
   486
lemmas arith_extra_simps [standard] =
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   487
  number_of_add [symmetric]
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   488
  number_of_minus [symmetric] numeral_m1_eq_minus_1 [symmetric]
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   489
  number_of_mult [symmetric]
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   490
  diff_number_of_eq abs_number_of 
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   491
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   492
text {*
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   493
  For making a minimal simpset, one must include these default simprules.
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   494
  Also include @{text simp_thms}.
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   495
*}
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   496
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   497
lemmas arith_simps = 
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   498
  bit.distinct
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   499
  Pls_0_eq Min_1_eq
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   500
  pred_Pls pred_Min pred_1 pred_0
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   501
  succ_Pls succ_Min succ_1 succ_0
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   502
  add_Pls add_Min add_BIT_0 add_BIT_10 add_BIT_11
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   503
  minus_Pls minus_Min minus_1 minus_0
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   504
  mult_Pls mult_Min mult_num1 mult_num0 
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   505
  add_Pls_right add_Min_right
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   506
  abs_zero abs_one arith_extra_simps
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   507
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   508
text {* Simplification of relational operations *}
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   509
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   510
lemmas rel_simps = 
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   511
  eq_number_of_eq iszero_number_of_Pls nonzero_number_of_Min
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   512
  iszero_number_of_0 iszero_number_of_1
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   513
  less_number_of_eq_neg
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   514
  not_neg_number_of_Pls not_neg_0 not_neg_1 not_iszero_1
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   515
  neg_number_of_Min neg_number_of_BIT
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   516
  le_number_of_eq
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   517
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   518
declare arith_extra_simps [simp]
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   519
declare rel_simps [simp]
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   520
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   521
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   522
subsection {* Simplification of arithmetic when nested to the right. *}
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   523
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   524
lemma add_number_of_left [simp]:
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   525
  "number_of v + (number_of w + z) =
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   526
   (number_of(v + w) + z::'a::number_ring)"
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   527
  by (simp add: add_assoc [symmetric])
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   528
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   529
lemma mult_number_of_left [simp]:
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   530
  "number_of v * (number_of w * z) =
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   531
   (number_of(v * w) * z::'a::number_ring)"
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   532
  by (simp add: mult_assoc [symmetric])
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   533
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   534
lemma add_number_of_diff1:
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   535
  "number_of v + (number_of w - c) = 
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   536
  number_of(v + w) - (c::'a::number_ring)"
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   537
  by (simp add: diff_minus add_number_of_left)
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   538
20485
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   539
lemma add_number_of_diff2 [simp]:
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   540
  "number_of v + (c - number_of w) =
3078fd2eec7b got rid of Numeral.bin type
haftmann
parents: 20355
diff changeset
   541
   number_of (v + uminus w) + (c::'a::number_ring)"
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   542
apply (subst diff_number_of_eq [symmetric])
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   543
apply (simp only: compare_rls)
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   544
done
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   545
19380
b808efaa5828 tuned syntax/abbreviations;
wenzelm
parents: 16417
diff changeset
   546
20500
11da1ce8dbd8 hid succ, pred in Numeral.thy
haftmann
parents: 20485
diff changeset
   547
hide (open) const Pls Min B0 B1 succ pred
19380
b808efaa5828 tuned syntax/abbreviations;
wenzelm
parents: 16417
diff changeset
   548
15013
34264f5e4691 new treatment of binary numerals
paulson
parents:
diff changeset
   549
end