src/HOL/ex/BinEx.thy
author huffman
Sun, 24 Sep 2006 05:49:50 +0200
changeset 20692 6df83a636e67
parent 16417 9bc16273c2d4
child 20807 bd3b60f9a343
permissions -rw-r--r--
generalized types of sums, summable, and suminf
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5545
9117a0e2bf31 added correctness proofs for arithmetic
paulson
parents: 5199
diff changeset
     1
(*  Title:      HOL/ex/BinEx.thy
9117a0e2bf31 added correctness proofs for arithmetic
paulson
parents: 5199
diff changeset
     2
    ID:         $Id$
9117a0e2bf31 added correctness proofs for arithmetic
paulson
parents: 5199
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
9117a0e2bf31 added correctness proofs for arithmetic
paulson
parents: 5199
diff changeset
     4
    Copyright   1998  University of Cambridge
9117a0e2bf31 added correctness proofs for arithmetic
paulson
parents: 5199
diff changeset
     5
*)
9117a0e2bf31 added correctness proofs for arithmetic
paulson
parents: 5199
diff changeset
     6
11024
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
     7
header {* Binary arithmetic examples *}
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
     8
16417
9bc16273c2d4 migrated theory headers to new format
haftmann
parents: 15965
diff changeset
     9
theory BinEx imports Main begin
11024
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
    10
14113
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    11
subsection {* Regression Testing for Cancellation Simprocs *}
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    12
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    13
(*taken from HOL/Integ/int_arith1.ML *)
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    14
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    15
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    16
lemma "l + 2 + 2 + 2 + (l + 2) + (oo + 2) = (uu::int)"
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    17
apply simp  oops
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    18
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    19
lemma "2*u = (u::int)"
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    20
apply simp  oops
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    21
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    22
lemma "(i + j + 12 + (k::int)) - 15 = y"
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    23
apply simp  oops
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    24
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    25
lemma "(i + j + 12 + (k::int)) - 5 = y"
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    26
apply simp  oops
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    27
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    28
lemma "y - b < (b::int)"
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    29
apply simp  oops
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    30
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    31
lemma "y - (3*b + c) < (b::int) - 2*c"
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    32
apply simp  oops
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    33
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    34
lemma "(2*x - (u*v) + y) - v*3*u = (w::int)"
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    35
apply simp  oops
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    36
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    37
lemma "(2*x*u*v + (u*v)*4 + y) - v*u*4 = (w::int)"
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    38
apply simp  oops
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    39
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    40
lemma "(2*x*u*v + (u*v)*4 + y) - v*u = (w::int)"
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    41
apply simp  oops
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    42
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    43
lemma "u*v - (x*u*v + (u*v)*4 + y) = (w::int)"
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    44
apply simp  oops
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    45
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    46
lemma "(i + j + 12 + (k::int)) = u + 15 + y"
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    47
apply simp  oops
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    48
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    49
lemma "(i + j*2 + 12 + (k::int)) = j + 5 + y"
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    50
apply simp  oops
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    51
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    52
lemma "2*y + 3*z + 6*w + 2*y + 3*z + 2*u = 2*y' + 3*z' + 6*w' + 2*y' + 3*z' + u + (vv::int)"
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    53
apply simp  oops
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    54
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    55
lemma "a + -(b+c) + b = (d::int)"
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    56
apply simp  oops
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    57
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    58
lemma "a + -(b+c) - b = (d::int)"
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    59
apply simp  oops
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    60
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    61
(*negative numerals*)
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    62
lemma "(i + j + -2 + (k::int)) - (u + 5 + y) = zz"
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    63
apply simp  oops
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    64
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    65
lemma "(i + j + -3 + (k::int)) < u + 5 + y"
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    66
apply simp  oops
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    67
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    68
lemma "(i + j + 3 + (k::int)) < u + -6 + y"
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    69
apply simp  oops
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    70
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    71
lemma "(i + j + -12 + (k::int)) - 15 = y"
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    72
apply simp  oops
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    73
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    74
lemma "(i + j + 12 + (k::int)) - -15 = y"
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    75
apply simp  oops
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    76
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    77
lemma "(i + j + -12 + (k::int)) - -15 = y"
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    78
apply simp  oops
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    79
14124
883c38e2d4c0 Added some regression testing for simprocs
paulson
parents: 14113
diff changeset
    80
lemma "- (2*i) + 3  + (2*i + 4) = (0::int)"
883c38e2d4c0 Added some regression testing for simprocs
paulson
parents: 14113
diff changeset
    81
apply simp  oops
883c38e2d4c0 Added some regression testing for simprocs
paulson
parents: 14113
diff changeset
    82
883c38e2d4c0 Added some regression testing for simprocs
paulson
parents: 14113
diff changeset
    83
14113
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    84
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    85
subsection {* Arithmetic Method Tests *}
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    86
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    87
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    88
lemma "!!a::int. [| a <= b; c <= d; x+y<z |] ==> a+c <= b+d"
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    89
by arith
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    90
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    91
lemma "!!a::int. [| a < b; c < d |] ==> a-d+ 2 <= b+(-c)"
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    92
by arith
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    93
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    94
lemma "!!a::int. [| a < b; c < d |] ==> a+c+ 1 < b+d"
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    95
by arith
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    96
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    97
lemma "!!a::int. [| a <= b; b+b <= c |] ==> a+a <= c"
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    98
by arith
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
    99
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
   100
lemma "!!a::int. [| a+b <= i+j; a<=b; i<=j |] ==> a+a <= j+j"
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
   101
by arith
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
   102
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
   103
lemma "!!a::int. [| a+b < i+j; a<b; i<j |] ==> a+a - - -1 < j+j - 3"
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
   104
by arith
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
   105
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
   106
lemma "!!a::int. a+b+c <= i+j+k & a<=b & b<=c & i<=j & j<=k --> a+a+a <= k+k+k"
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
   107
by arith
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
   108
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
   109
lemma "!!a::int. [| a+b+c+d <= i+j+k+l; a<=b; b<=c; c<=d; i<=j; j<=k; k<=l |]
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
   110
      ==> a <= l"
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
   111
by arith
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
   112
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
   113
lemma "!!a::int. [| a+b+c+d <= i+j+k+l; a<=b; b<=c; c<=d; i<=j; j<=k; k<=l |]
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
   114
      ==> a+a+a+a <= l+l+l+l"
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
   115
by arith
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
   116
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
   117
lemma "!!a::int. [| a+b+c+d <= i+j+k+l; a<=b; b<=c; c<=d; i<=j; j<=k; k<=l |]
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
   118
      ==> a+a+a+a+a <= l+l+l+l+i"
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
   119
by arith
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
   120
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
   121
lemma "!!a::int. [| a+b+c+d <= i+j+k+l; a<=b; b<=c; c<=d; i<=j; j<=k; k<=l |]
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
   122
      ==> a+a+a+a+a+a <= l+l+l+l+i+l"
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
   123
by arith
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
   124
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
   125
lemma "!!a::int. [| a+b+c+d <= i+j+k+l; a<=b; b<=c; c<=d; i<=j; j<=k; k<=l |]
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
   126
      ==> 6*a <= 5*l+i"
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
   127
by arith
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
   128
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
   129
7b3513ba0f86 Fixing a simproc bug
paulson
parents: 13491
diff changeset
   130
11024
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   131
subsection {* The Integers *}
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   132
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   133
text {* Addition *}
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   134
11704
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   135
lemma "(13::int) + 19 = 32"
11024
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   136
  by simp
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   137
11704
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   138
lemma "(1234::int) + 5678 = 6912"
11024
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   139
  by simp
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   140
11704
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   141
lemma "(1359::int) + -2468 = -1109"
11024
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   142
  by simp
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   143
11704
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   144
lemma "(93746::int) + -46375 = 47371"
11024
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   145
  by simp
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   146
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   147
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   148
text {* \medskip Negation *}
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   149
11704
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   150
lemma "- (65745::int) = -65745"
11024
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   151
  by simp
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   152
11704
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   153
lemma "- (-54321::int) = 54321"
11024
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   154
  by simp
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   155
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   156
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   157
text {* \medskip Multiplication *}
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   158
11704
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   159
lemma "(13::int) * 19 = 247"
11024
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   160
  by simp
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   161
11704
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   162
lemma "(-84::int) * 51 = -4284"
11024
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   163
  by simp
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   164
11704
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   165
lemma "(255::int) * 255 = 65025"
11024
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   166
  by simp
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   167
11704
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   168
lemma "(1359::int) * -2468 = -3354012"
11024
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   169
  by simp
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   170
11704
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   171
lemma "(89::int) * 10 \<noteq> 889"
11024
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   172
  by simp
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   173
11704
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   174
lemma "(13::int) < 18 - 4"
11024
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   175
  by simp
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   176
11704
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   177
lemma "(-345::int) < -242 + -100"
11024
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   178
  by simp
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   179
11704
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   180
lemma "(13557456::int) < 18678654"
11024
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   181
  by simp
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   182
11868
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11704
diff changeset
   183
lemma "(999999::int) \<le> (1000001 + 1) - 2"
11024
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   184
  by simp
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   185
11704
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   186
lemma "(1234567::int) \<le> 1234567"
11024
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   187
  by simp
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   188
15965
f422f8283491 Use of IntInf.int instead of int in most numeric simprocs; avoids
paulson
parents: 15013
diff changeset
   189
text{*No integer overflow!*}
f422f8283491 Use of IntInf.int instead of int in most numeric simprocs; avoids
paulson
parents: 15013
diff changeset
   190
lemma "1234567 * (1234567::int) < 1234567*1234567*1234567"
f422f8283491 Use of IntInf.int instead of int in most numeric simprocs; avoids
paulson
parents: 15013
diff changeset
   191
  by simp
f422f8283491 Use of IntInf.int instead of int in most numeric simprocs; avoids
paulson
parents: 15013
diff changeset
   192
11024
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   193
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   194
text {* \medskip Quotient and Remainder *}
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   195
11704
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   196
lemma "(10::int) div 3 = 3"
11024
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   197
  by simp
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   198
11868
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11704
diff changeset
   199
lemma "(10::int) mod 3 = 1"
11024
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   200
  by simp
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   201
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   202
text {* A negative divisor *}
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   203
11704
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   204
lemma "(10::int) div -3 = -4"
11024
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   205
  by simp
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   206
11704
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   207
lemma "(10::int) mod -3 = -2"
11024
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   208
  by simp
5545
9117a0e2bf31 added correctness proofs for arithmetic
paulson
parents: 5199
diff changeset
   209
11024
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   210
text {*
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   211
  A negative dividend\footnote{The definition agrees with mathematical
15965
f422f8283491 Use of IntInf.int instead of int in most numeric simprocs; avoids
paulson
parents: 15013
diff changeset
   212
  convention and with ML, but not with the hardware of most computers}
11024
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   213
*}
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   214
11704
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   215
lemma "(-10::int) div 3 = -4"
11024
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   216
  by simp
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   217
11704
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   218
lemma "(-10::int) mod 3 = 2"
11024
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   219
  by simp
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   220
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   221
text {* A negative dividend \emph{and} divisor *}
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   222
11704
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   223
lemma "(-10::int) div -3 = 3"
11024
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   224
  by simp
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   225
11704
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   226
lemma "(-10::int) mod -3 = -1"
11024
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   227
  by simp
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   228
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   229
text {* A few bigger examples *}
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   230
11868
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11704
diff changeset
   231
lemma "(8452::int) mod 3 = 1"
11024
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   232
  by simp
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   233
11704
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   234
lemma "(59485::int) div 434 = 137"
11024
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   235
  by simp
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   236
11704
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   237
lemma "(1000006::int) mod 10 = 6"
11024
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   238
  by simp
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   239
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   240
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   241
text {* \medskip Division by shifting *}
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   242
11704
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   243
lemma "10000000 div 2 = (5000000::int)"
11024
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   244
  by simp
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   245
11868
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11704
diff changeset
   246
lemma "10000001 mod 2 = (1::int)"
11024
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   247
  by simp
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   248
11704
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   249
lemma "10000055 div 32 = (312501::int)"
11024
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   250
  by simp
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   251
11704
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   252
lemma "10000055 mod 32 = (23::int)"
11024
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   253
  by simp
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   254
11704
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   255
lemma "100094 div 144 = (695::int)"
11024
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   256
  by simp
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   257
11704
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   258
lemma "100094 mod 144 = (14::int)"
11024
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   259
  by simp
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   260
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   261
12613
279facb4253a Literal arithmetic: raising numbers to powers (nat, int, real, hypreal)
paulson
parents: 11868
diff changeset
   262
text {* \medskip Powers *}
279facb4253a Literal arithmetic: raising numbers to powers (nat, int, real, hypreal)
paulson
parents: 11868
diff changeset
   263
279facb4253a Literal arithmetic: raising numbers to powers (nat, int, real, hypreal)
paulson
parents: 11868
diff changeset
   264
lemma "2 ^ 10 = (1024::int)"
279facb4253a Literal arithmetic: raising numbers to powers (nat, int, real, hypreal)
paulson
parents: 11868
diff changeset
   265
  by simp
279facb4253a Literal arithmetic: raising numbers to powers (nat, int, real, hypreal)
paulson
parents: 11868
diff changeset
   266
279facb4253a Literal arithmetic: raising numbers to powers (nat, int, real, hypreal)
paulson
parents: 11868
diff changeset
   267
lemma "-3 ^ 7 = (-2187::int)"
279facb4253a Literal arithmetic: raising numbers to powers (nat, int, real, hypreal)
paulson
parents: 11868
diff changeset
   268
  by simp
279facb4253a Literal arithmetic: raising numbers to powers (nat, int, real, hypreal)
paulson
parents: 11868
diff changeset
   269
279facb4253a Literal arithmetic: raising numbers to powers (nat, int, real, hypreal)
paulson
parents: 11868
diff changeset
   270
lemma "13 ^ 7 = (62748517::int)"
279facb4253a Literal arithmetic: raising numbers to powers (nat, int, real, hypreal)
paulson
parents: 11868
diff changeset
   271
  by simp
279facb4253a Literal arithmetic: raising numbers to powers (nat, int, real, hypreal)
paulson
parents: 11868
diff changeset
   272
279facb4253a Literal arithmetic: raising numbers to powers (nat, int, real, hypreal)
paulson
parents: 11868
diff changeset
   273
lemma "3 ^ 15 = (14348907::int)"
279facb4253a Literal arithmetic: raising numbers to powers (nat, int, real, hypreal)
paulson
parents: 11868
diff changeset
   274
  by simp
279facb4253a Literal arithmetic: raising numbers to powers (nat, int, real, hypreal)
paulson
parents: 11868
diff changeset
   275
279facb4253a Literal arithmetic: raising numbers to powers (nat, int, real, hypreal)
paulson
parents: 11868
diff changeset
   276
lemma "-5 ^ 11 = (-48828125::int)"
279facb4253a Literal arithmetic: raising numbers to powers (nat, int, real, hypreal)
paulson
parents: 11868
diff changeset
   277
  by simp
279facb4253a Literal arithmetic: raising numbers to powers (nat, int, real, hypreal)
paulson
parents: 11868
diff changeset
   278
279facb4253a Literal arithmetic: raising numbers to powers (nat, int, real, hypreal)
paulson
parents: 11868
diff changeset
   279
11024
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   280
subsection {* The Natural Numbers *}
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   281
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   282
text {* Successor *}
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   283
11704
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   284
lemma "Suc 99999 = 100000"
11024
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   285
  by (simp add: Suc_nat_number_of)
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   286
    -- {* not a default rewrite since sometimes we want to have @{text "Suc #nnn"} *}
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   287
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   288
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   289
text {* \medskip Addition *}
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   290
11704
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   291
lemma "(13::nat) + 19 = 32"
11024
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   292
  by simp
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   293
11704
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   294
lemma "(1234::nat) + 5678 = 6912"
11024
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   295
  by simp
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   296
11704
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   297
lemma "(973646::nat) + 6475 = 980121"
11024
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   298
  by simp
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   299
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   300
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   301
text {* \medskip Subtraction *}
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   302
11704
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   303
lemma "(32::nat) - 14 = 18"
11024
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   304
  by simp
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   305
11868
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11704
diff changeset
   306
lemma "(14::nat) - 15 = 0"
11024
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   307
  by simp
5545
9117a0e2bf31 added correctness proofs for arithmetic
paulson
parents: 5199
diff changeset
   308
11868
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11704
diff changeset
   309
lemma "(14::nat) - 1576644 = 0"
11024
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   310
  by simp
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   311
11704
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   312
lemma "(48273776::nat) - 3873737 = 44400039"
11024
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   313
  by simp
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   314
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   315
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   316
text {* \medskip Multiplication *}
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   317
11704
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   318
lemma "(12::nat) * 11 = 132"
11024
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   319
  by simp
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   320
11704
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   321
lemma "(647::nat) * 3643 = 2357021"
11024
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   322
  by simp
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   323
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   324
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   325
text {* \medskip Quotient and Remainder *}
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   326
11704
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   327
lemma "(10::nat) div 3 = 3"
11024
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   328
  by simp
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   329
11868
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11704
diff changeset
   330
lemma "(10::nat) mod 3 = 1"
11024
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   331
  by simp
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   332
11704
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   333
lemma "(10000::nat) div 9 = 1111"
11024
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   334
  by simp
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   335
11868
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11704
diff changeset
   336
lemma "(10000::nat) mod 9 = 1"
11024
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   337
  by simp
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   338
11704
3c50a2cd6f00 * sane numerals (stage 2): plain "num" syntax (removed "#");
wenzelm
parents: 11701
diff changeset
   339
lemma "(10000::nat) div 16 = 625"
11024
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   340
  by simp
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   341
11868
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11704
diff changeset
   342
lemma "(10000::nat) mod 16 = 0"
11024
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   343
  by simp
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   344
5545
9117a0e2bf31 added correctness proofs for arithmetic
paulson
parents: 5199
diff changeset
   345
12613
279facb4253a Literal arithmetic: raising numbers to powers (nat, int, real, hypreal)
paulson
parents: 11868
diff changeset
   346
text {* \medskip Powers *}
279facb4253a Literal arithmetic: raising numbers to powers (nat, int, real, hypreal)
paulson
parents: 11868
diff changeset
   347
279facb4253a Literal arithmetic: raising numbers to powers (nat, int, real, hypreal)
paulson
parents: 11868
diff changeset
   348
lemma "2 ^ 12 = (4096::nat)"
279facb4253a Literal arithmetic: raising numbers to powers (nat, int, real, hypreal)
paulson
parents: 11868
diff changeset
   349
  by simp
279facb4253a Literal arithmetic: raising numbers to powers (nat, int, real, hypreal)
paulson
parents: 11868
diff changeset
   350
279facb4253a Literal arithmetic: raising numbers to powers (nat, int, real, hypreal)
paulson
parents: 11868
diff changeset
   351
lemma "3 ^ 10 = (59049::nat)"
279facb4253a Literal arithmetic: raising numbers to powers (nat, int, real, hypreal)
paulson
parents: 11868
diff changeset
   352
  by simp
279facb4253a Literal arithmetic: raising numbers to powers (nat, int, real, hypreal)
paulson
parents: 11868
diff changeset
   353
279facb4253a Literal arithmetic: raising numbers to powers (nat, int, real, hypreal)
paulson
parents: 11868
diff changeset
   354
lemma "12 ^ 7 = (35831808::nat)"
279facb4253a Literal arithmetic: raising numbers to powers (nat, int, real, hypreal)
paulson
parents: 11868
diff changeset
   355
  by simp
279facb4253a Literal arithmetic: raising numbers to powers (nat, int, real, hypreal)
paulson
parents: 11868
diff changeset
   356
279facb4253a Literal arithmetic: raising numbers to powers (nat, int, real, hypreal)
paulson
parents: 11868
diff changeset
   357
lemma "3 ^ 14 = (4782969::nat)"
279facb4253a Literal arithmetic: raising numbers to powers (nat, int, real, hypreal)
paulson
parents: 11868
diff changeset
   358
  by simp
279facb4253a Literal arithmetic: raising numbers to powers (nat, int, real, hypreal)
paulson
parents: 11868
diff changeset
   359
279facb4253a Literal arithmetic: raising numbers to powers (nat, int, real, hypreal)
paulson
parents: 11868
diff changeset
   360
lemma "5 ^ 11 = (48828125::nat)"
279facb4253a Literal arithmetic: raising numbers to powers (nat, int, real, hypreal)
paulson
parents: 11868
diff changeset
   361
  by simp
279facb4253a Literal arithmetic: raising numbers to powers (nat, int, real, hypreal)
paulson
parents: 11868
diff changeset
   362
279facb4253a Literal arithmetic: raising numbers to powers (nat, int, real, hypreal)
paulson
parents: 11868
diff changeset
   363
11024
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   364
text {* \medskip Testing the cancellation of complementary terms *}
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   365
11868
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11704
diff changeset
   366
lemma "y + (x + -x) = (0::int) + y"
11024
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   367
  by simp
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   368
11868
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11704
diff changeset
   369
lemma "y + (-x + (- y + x)) = (0::int)"
11024
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   370
  by simp
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   371
11868
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11704
diff changeset
   372
lemma "-x + (y + (- y + x)) = (0::int)"
11024
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   373
  by simp
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   374
11868
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11704
diff changeset
   375
lemma "x + (x + (- x + (- x + (- y + - z)))) = (0::int) - y - z"
11024
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   376
  by simp
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   377
11868
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11704
diff changeset
   378
lemma "x + x - x - x - y - z = (0::int) - y - z"
11024
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   379
  by simp
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   380
11868
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11704
diff changeset
   381
lemma "x + y + z - (x + z) = y - (0::int)"
11024
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   382
  by simp
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   383
11868
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11704
diff changeset
   384
lemma "x + (y + (y + (y + (-x + -x)))) = (0::int) + y - x + y + y"
11024
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   385
  by simp
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   386
11868
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11704
diff changeset
   387
lemma "x + (y + (y + (y + (-y + -x)))) = y + (0::int) + y"
11024
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   388
  by simp
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   389
11868
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11704
diff changeset
   390
lemma "x + y - x + z - x - y - z + x < (1::int)"
11024
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   391
  by simp
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   392
23bf8d787b04 converted to new-style theories;
wenzelm
parents: 9297
diff changeset
   393
15013
34264f5e4691 new treatment of binary numerals
paulson
parents: 14398
diff changeset
   394
text{*The proofs about arithmetic yielding normal forms have been deleted:
34264f5e4691 new treatment of binary numerals
paulson
parents: 14398
diff changeset
   395
 they are irrelevant with the new treatment of numerals.*}
13192
e961c197f141 fixed a proof near the end
paulson
parents: 13187
diff changeset
   396
5545
9117a0e2bf31 added correctness proofs for arithmetic
paulson
parents: 5199
diff changeset
   397
end