src/HOL/NatBin.thy
author wenzelm
Wed, 29 Aug 2007 11:10:28 +0200
changeset 24470 41c81e23c08d
parent 24093 5d0ecd0c8f3c
child 25481 aa16cd919dcc
permissions -rw-r--r--
removed Hoare/hoare.ML, Hoare/hoareAbort.ML, ex/svc_oracle.ML (which can be mistaken as attached ML script on case-insensitive file-system);
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
23164
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
     1
(*  Title:      HOL/NatBin.thy
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
     2
    ID:         $Id$
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
     4
    Copyright   1999  University of Cambridge
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
     5
*)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
     6
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
     7
header {* Binary arithmetic for the natural numbers *}
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
     8
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
     9
theory NatBin
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    10
imports IntDiv
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    11
begin
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    12
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    13
text {*
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    14
  Arithmetic for naturals is reduced to that for the non-negative integers.
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    15
*}
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    16
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    17
instance nat :: number
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    18
  nat_number_of_def [code inline]: "number_of v == nat (number_of (v\<Colon>int))" ..
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    19
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    20
abbreviation (xsymbols)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    21
  square :: "'a::power => 'a"  ("(_\<twosuperior>)" [1000] 999) where
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    22
  "x\<twosuperior> == x^2"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    23
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    24
notation (latex output)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    25
  square  ("(_\<twosuperior>)" [1000] 999)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    26
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    27
notation (HTML output)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    28
  square  ("(_\<twosuperior>)" [1000] 999)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    29
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    30
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    31
subsection{*Function @{term nat}: Coercion from Type @{typ int} to @{typ nat}*}
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    32
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    33
declare nat_0 [simp] nat_1 [simp]
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    34
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    35
lemma nat_number_of [simp]: "nat (number_of w) = number_of w"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    36
by (simp add: nat_number_of_def)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    37
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    38
lemma nat_numeral_0_eq_0 [simp]: "Numeral0 = (0::nat)"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    39
by (simp add: nat_number_of_def)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    40
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    41
lemma nat_numeral_1_eq_1 [simp]: "Numeral1 = (1::nat)"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    42
by (simp add: nat_1 nat_number_of_def)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    43
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    44
lemma numeral_1_eq_Suc_0: "Numeral1 = Suc 0"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    45
by (simp add: nat_numeral_1_eq_1)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    46
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    47
lemma numeral_2_eq_2: "2 = Suc (Suc 0)"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    48
apply (unfold nat_number_of_def)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    49
apply (rule nat_2)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    50
done
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    51
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    52
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    53
text{*Distributive laws for type @{text nat}.  The others are in theory
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    54
   @{text IntArith}, but these require div and mod to be defined for type
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    55
   "int".  They also need some of the lemmas proved above.*}
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    56
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    57
lemma nat_div_distrib: "(0::int) <= z ==> nat (z div z') = nat z div nat z'"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    58
apply (case_tac "0 <= z'")
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    59
apply (auto simp add: div_nonneg_neg_le0 DIVISION_BY_ZERO_DIV)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    60
apply (case_tac "z' = 0", simp add: DIVISION_BY_ZERO)
23365
f31794033ae1 removed constant int :: nat => int;
huffman
parents: 23307
diff changeset
    61
apply (auto elim!: nonneg_eq_int)
23164
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    62
apply (rename_tac m m')
23365
f31794033ae1 removed constant int :: nat => int;
huffman
parents: 23307
diff changeset
    63
apply (subgoal_tac "0 <= int m div int m'")
23164
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    64
 prefer 2 apply (simp add: nat_numeral_0_eq_0 pos_imp_zdiv_nonneg_iff) 
23307
2fe3345035c7 modify proofs to avoid referring to int::nat=>int
huffman
parents: 23294
diff changeset
    65
apply (rule of_nat_eq_iff [where 'a=int, THEN iffD1], simp)
23365
f31794033ae1 removed constant int :: nat => int;
huffman
parents: 23307
diff changeset
    66
apply (rule_tac r = "int (m mod m') " in quorem_div)
23164
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    67
 prefer 2 apply force
23365
f31794033ae1 removed constant int :: nat => int;
huffman
parents: 23307
diff changeset
    68
apply (simp add: nat_less_iff [symmetric] quorem_def nat_numeral_0_eq_0
23307
2fe3345035c7 modify proofs to avoid referring to int::nat=>int
huffman
parents: 23294
diff changeset
    69
                 of_nat_add [symmetric] of_nat_mult [symmetric]
2fe3345035c7 modify proofs to avoid referring to int::nat=>int
huffman
parents: 23294
diff changeset
    70
            del: of_nat_add of_nat_mult)
23164
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    71
done
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    72
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    73
(*Fails if z'<0: the LHS collapses to (nat z) but the RHS doesn't*)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    74
lemma nat_mod_distrib:
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    75
     "[| (0::int) <= z;  0 <= z' |] ==> nat (z mod z') = nat z mod nat z'"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    76
apply (case_tac "z' = 0", simp add: DIVISION_BY_ZERO)
23365
f31794033ae1 removed constant int :: nat => int;
huffman
parents: 23307
diff changeset
    77
apply (auto elim!: nonneg_eq_int)
23164
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    78
apply (rename_tac m m')
23365
f31794033ae1 removed constant int :: nat => int;
huffman
parents: 23307
diff changeset
    79
apply (subgoal_tac "0 <= int m mod int m'")
f31794033ae1 removed constant int :: nat => int;
huffman
parents: 23307
diff changeset
    80
 prefer 2 apply (simp add: nat_less_iff nat_numeral_0_eq_0 pos_mod_sign)
f31794033ae1 removed constant int :: nat => int;
huffman
parents: 23307
diff changeset
    81
apply (rule int_int_eq [THEN iffD1], simp)
f31794033ae1 removed constant int :: nat => int;
huffman
parents: 23307
diff changeset
    82
apply (rule_tac q = "int (m div m') " in quorem_mod)
23164
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    83
 prefer 2 apply force
23365
f31794033ae1 removed constant int :: nat => int;
huffman
parents: 23307
diff changeset
    84
apply (simp add: nat_less_iff [symmetric] quorem_def nat_numeral_0_eq_0
23307
2fe3345035c7 modify proofs to avoid referring to int::nat=>int
huffman
parents: 23294
diff changeset
    85
                 of_nat_add [symmetric] of_nat_mult [symmetric]
2fe3345035c7 modify proofs to avoid referring to int::nat=>int
huffman
parents: 23294
diff changeset
    86
            del: of_nat_add of_nat_mult)
23164
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    87
done
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    88
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    89
text{*Suggested by Matthias Daum*}
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    90
lemma int_div_less_self: "\<lbrakk>0 < x; 1 < k\<rbrakk> \<Longrightarrow> x div k < (x::int)"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    91
apply (subgoal_tac "nat x div nat k < nat x")
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    92
 apply (simp (asm_lr) add: nat_div_distrib [symmetric])
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    93
apply (rule Divides.div_less_dividend, simp_all) 
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    94
done
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    95
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    96
subsection{*Function @{term int}: Coercion from Type @{typ nat} to @{typ int}*}
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    97
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    98
(*"neg" is used in rewrite rules for binary comparisons*)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
    99
lemma int_nat_number_of [simp]:
23365
f31794033ae1 removed constant int :: nat => int;
huffman
parents: 23307
diff changeset
   100
     "int (number_of v) =  
23307
2fe3345035c7 modify proofs to avoid referring to int::nat=>int
huffman
parents: 23294
diff changeset
   101
         (if neg (number_of v :: int) then 0  
2fe3345035c7 modify proofs to avoid referring to int::nat=>int
huffman
parents: 23294
diff changeset
   102
          else (number_of v :: int))"
2fe3345035c7 modify proofs to avoid referring to int::nat=>int
huffman
parents: 23294
diff changeset
   103
by (simp del: nat_number_of
2fe3345035c7 modify proofs to avoid referring to int::nat=>int
huffman
parents: 23294
diff changeset
   104
	 add: neg_nat nat_number_of_def not_neg_nat add_assoc)
2fe3345035c7 modify proofs to avoid referring to int::nat=>int
huffman
parents: 23294
diff changeset
   105
23164
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   106
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   107
subsubsection{*Successor *}
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   108
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   109
lemma Suc_nat_eq_nat_zadd1: "(0::int) <= z ==> Suc (nat z) = nat (1 + z)"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   110
apply (rule sym)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   111
apply (simp add: nat_eq_iff int_Suc)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   112
done
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   113
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   114
lemma Suc_nat_number_of_add:
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   115
     "Suc (number_of v + n) =  
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   116
        (if neg (number_of v :: int) then 1+n else number_of (Numeral.succ v) + n)" 
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   117
by (simp del: nat_number_of 
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   118
         add: nat_number_of_def neg_nat
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   119
              Suc_nat_eq_nat_zadd1 number_of_succ) 
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   120
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   121
lemma Suc_nat_number_of [simp]:
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   122
     "Suc (number_of v) =  
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   123
        (if neg (number_of v :: int) then 1 else number_of (Numeral.succ v))"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   124
apply (cut_tac n = 0 in Suc_nat_number_of_add)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   125
apply (simp cong del: if_weak_cong)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   126
done
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   127
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   128
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   129
subsubsection{*Addition *}
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   130
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   131
(*"neg" is used in rewrite rules for binary comparisons*)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   132
lemma add_nat_number_of [simp]:
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   133
     "(number_of v :: nat) + number_of v' =  
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   134
         (if neg (number_of v :: int) then number_of v'  
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   135
          else if neg (number_of v' :: int) then number_of v  
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   136
          else number_of (v + v'))"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   137
by (force dest!: neg_nat
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   138
          simp del: nat_number_of
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   139
          simp add: nat_number_of_def nat_add_distrib [symmetric]) 
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   140
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   141
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   142
subsubsection{*Subtraction *}
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   143
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   144
lemma diff_nat_eq_if:
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   145
     "nat z - nat z' =  
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   146
        (if neg z' then nat z   
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   147
         else let d = z-z' in     
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   148
              if neg d then 0 else nat d)"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   149
apply (simp add: Let_def nat_diff_distrib [symmetric] neg_eq_less_0 not_neg_eq_ge_0)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   150
done
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   151
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   152
lemma diff_nat_number_of [simp]: 
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   153
     "(number_of v :: nat) - number_of v' =  
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   154
        (if neg (number_of v' :: int) then number_of v  
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   155
         else let d = number_of (v + uminus v') in     
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   156
              if neg d then 0 else nat d)"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   157
by (simp del: nat_number_of add: diff_nat_eq_if nat_number_of_def) 
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   158
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   159
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   160
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   161
subsubsection{*Multiplication *}
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   162
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   163
lemma mult_nat_number_of [simp]:
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   164
     "(number_of v :: nat) * number_of v' =  
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   165
       (if neg (number_of v :: int) then 0 else number_of (v * v'))"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   166
by (force dest!: neg_nat
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   167
          simp del: nat_number_of
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   168
          simp add: nat_number_of_def nat_mult_distrib [symmetric]) 
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   169
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   170
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   171
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   172
subsubsection{*Quotient *}
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   173
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   174
lemma div_nat_number_of [simp]:
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   175
     "(number_of v :: nat)  div  number_of v' =  
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   176
          (if neg (number_of v :: int) then 0  
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   177
           else nat (number_of v div number_of v'))"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   178
by (force dest!: neg_nat
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   179
          simp del: nat_number_of
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   180
          simp add: nat_number_of_def nat_div_distrib [symmetric]) 
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   181
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   182
lemma one_div_nat_number_of [simp]:
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   183
     "(Suc 0)  div  number_of v' = (nat (1 div number_of v'))" 
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   184
by (simp del: nat_numeral_1_eq_1 add: numeral_1_eq_Suc_0 [symmetric]) 
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   185
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   186
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   187
subsubsection{*Remainder *}
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   188
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   189
lemma mod_nat_number_of [simp]:
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   190
     "(number_of v :: nat)  mod  number_of v' =  
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   191
        (if neg (number_of v :: int) then 0  
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   192
         else if neg (number_of v' :: int) then number_of v  
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   193
         else nat (number_of v mod number_of v'))"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   194
by (force dest!: neg_nat
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   195
          simp del: nat_number_of
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   196
          simp add: nat_number_of_def nat_mod_distrib [symmetric]) 
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   197
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   198
lemma one_mod_nat_number_of [simp]:
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   199
     "(Suc 0)  mod  number_of v' =  
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   200
        (if neg (number_of v' :: int) then Suc 0
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   201
         else nat (1 mod number_of v'))"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   202
by (simp del: nat_numeral_1_eq_1 add: numeral_1_eq_Suc_0 [symmetric]) 
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   203
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   204
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   205
subsubsection{* Divisibility *}
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   206
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   207
lemmas dvd_eq_mod_eq_0_number_of =
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   208
  dvd_eq_mod_eq_0 [of "number_of x" "number_of y", standard]
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   209
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   210
declare dvd_eq_mod_eq_0_number_of [simp]
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   211
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   212
ML
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   213
{*
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   214
val nat_number_of_def = thm"nat_number_of_def";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   215
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   216
val nat_number_of = thm"nat_number_of";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   217
val nat_numeral_0_eq_0 = thm"nat_numeral_0_eq_0";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   218
val nat_numeral_1_eq_1 = thm"nat_numeral_1_eq_1";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   219
val numeral_1_eq_Suc_0 = thm"numeral_1_eq_Suc_0";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   220
val numeral_2_eq_2 = thm"numeral_2_eq_2";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   221
val nat_div_distrib = thm"nat_div_distrib";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   222
val nat_mod_distrib = thm"nat_mod_distrib";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   223
val int_nat_number_of = thm"int_nat_number_of";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   224
val Suc_nat_eq_nat_zadd1 = thm"Suc_nat_eq_nat_zadd1";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   225
val Suc_nat_number_of_add = thm"Suc_nat_number_of_add";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   226
val Suc_nat_number_of = thm"Suc_nat_number_of";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   227
val add_nat_number_of = thm"add_nat_number_of";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   228
val diff_nat_eq_if = thm"diff_nat_eq_if";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   229
val diff_nat_number_of = thm"diff_nat_number_of";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   230
val mult_nat_number_of = thm"mult_nat_number_of";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   231
val div_nat_number_of = thm"div_nat_number_of";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   232
val mod_nat_number_of = thm"mod_nat_number_of";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   233
*}
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   234
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   235
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   236
subsection{*Comparisons*}
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   237
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   238
subsubsection{*Equals (=) *}
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   239
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   240
lemma eq_nat_nat_iff:
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   241
     "[| (0::int) <= z;  0 <= z' |] ==> (nat z = nat z') = (z=z')"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   242
by (auto elim!: nonneg_eq_int)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   243
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   244
(*"neg" is used in rewrite rules for binary comparisons*)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   245
lemma eq_nat_number_of [simp]:
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   246
     "((number_of v :: nat) = number_of v') =  
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   247
      (if neg (number_of v :: int) then (iszero (number_of v' :: int) | neg (number_of v' :: int))  
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   248
       else if neg (number_of v' :: int) then iszero (number_of v :: int)  
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   249
       else iszero (number_of (v + uminus v') :: int))"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   250
apply (simp only: simp_thms neg_nat not_neg_eq_ge_0 nat_number_of_def
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   251
                  eq_nat_nat_iff eq_number_of_eq nat_0 iszero_def
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   252
            split add: split_if cong add: imp_cong)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   253
apply (simp only: nat_eq_iff nat_eq_iff2)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   254
apply (simp add: not_neg_eq_ge_0 [symmetric])
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   255
done
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   256
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   257
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   258
subsubsection{*Less-than (<) *}
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   259
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   260
(*"neg" is used in rewrite rules for binary comparisons*)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   261
lemma less_nat_number_of [simp]:
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   262
     "((number_of v :: nat) < number_of v') =  
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   263
         (if neg (number_of v :: int) then neg (number_of (uminus v') :: int)  
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   264
          else neg (number_of (v + uminus v') :: int))"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   265
by (simp only: simp_thms neg_nat not_neg_eq_ge_0 nat_number_of_def
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   266
                nat_less_eq_zless less_number_of_eq_neg zless_nat_eq_int_zless
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   267
         cong add: imp_cong, simp add: Pls_def)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   268
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   269
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   270
(*Maps #n to n for n = 0, 1, 2*)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   271
lemmas numerals = nat_numeral_0_eq_0 nat_numeral_1_eq_1 numeral_2_eq_2
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   272
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   273
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   274
subsection{*Powers with Numeric Exponents*}
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   275
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   276
text{*We cannot refer to the number @{term 2} in @{text Ring_and_Field.thy}.
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   277
We cannot prove general results about the numeral @{term "-1"}, so we have to
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   278
use @{term "- 1"} instead.*}
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   279
23277
aa158e145ea3 generalize class constraints on some lemmas
huffman
parents: 23164
diff changeset
   280
lemma power2_eq_square: "(a::'a::recpower)\<twosuperior> = a * a"
23164
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   281
  by (simp add: numeral_2_eq_2 Power.power_Suc)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   282
23277
aa158e145ea3 generalize class constraints on some lemmas
huffman
parents: 23164
diff changeset
   283
lemma zero_power2 [simp]: "(0::'a::{semiring_1,recpower})\<twosuperior> = 0"
23164
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   284
  by (simp add: power2_eq_square)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   285
23277
aa158e145ea3 generalize class constraints on some lemmas
huffman
parents: 23164
diff changeset
   286
lemma one_power2 [simp]: "(1::'a::{semiring_1,recpower})\<twosuperior> = 1"
23164
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   287
  by (simp add: power2_eq_square)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   288
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   289
lemma power3_eq_cube: "(x::'a::recpower) ^ 3 = x * x * x"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   290
  apply (subgoal_tac "3 = Suc (Suc (Suc 0))")
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   291
  apply (erule ssubst)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   292
  apply (simp add: power_Suc mult_ac)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   293
  apply (unfold nat_number_of_def)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   294
  apply (subst nat_eq_iff)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   295
  apply simp
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   296
done
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   297
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   298
text{*Squares of literal numerals will be evaluated.*}
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   299
lemmas power2_eq_square_number_of =
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   300
    power2_eq_square [of "number_of w", standard]
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   301
declare power2_eq_square_number_of [simp]
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   302
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   303
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   304
lemma zero_le_power2[simp]: "0 \<le> (a\<twosuperior>::'a::{ordered_idom,recpower})"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   305
  by (simp add: power2_eq_square)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   306
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   307
lemma zero_less_power2[simp]:
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   308
     "(0 < a\<twosuperior>) = (a \<noteq> (0::'a::{ordered_idom,recpower}))"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   309
  by (force simp add: power2_eq_square zero_less_mult_iff linorder_neq_iff)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   310
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   311
lemma power2_less_0[simp]:
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   312
  fixes a :: "'a::{ordered_idom,recpower}"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   313
  shows "~ (a\<twosuperior> < 0)"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   314
by (force simp add: power2_eq_square mult_less_0_iff) 
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   315
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   316
lemma zero_eq_power2[simp]:
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   317
     "(a\<twosuperior> = 0) = (a = (0::'a::{ordered_idom,recpower}))"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   318
  by (force simp add: power2_eq_square mult_eq_0_iff)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   319
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   320
lemma abs_power2[simp]:
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   321
     "abs(a\<twosuperior>) = (a\<twosuperior>::'a::{ordered_idom,recpower})"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   322
  by (simp add: power2_eq_square abs_mult abs_mult_self)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   323
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   324
lemma power2_abs[simp]:
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   325
     "(abs a)\<twosuperior> = (a\<twosuperior>::'a::{ordered_idom,recpower})"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   326
  by (simp add: power2_eq_square abs_mult_self)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   327
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   328
lemma power2_minus[simp]:
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   329
     "(- a)\<twosuperior> = (a\<twosuperior>::'a::{comm_ring_1,recpower})"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   330
  by (simp add: power2_eq_square)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   331
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   332
lemma power2_le_imp_le:
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   333
  fixes x y :: "'a::{ordered_semidom,recpower}"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   334
  shows "\<lbrakk>x\<twosuperior> \<le> y\<twosuperior>; 0 \<le> y\<rbrakk> \<Longrightarrow> x \<le> y"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   335
unfolding numeral_2_eq_2 by (rule power_le_imp_le_base)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   336
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   337
lemma power2_less_imp_less:
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   338
  fixes x y :: "'a::{ordered_semidom,recpower}"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   339
  shows "\<lbrakk>x\<twosuperior> < y\<twosuperior>; 0 \<le> y\<rbrakk> \<Longrightarrow> x < y"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   340
by (rule power_less_imp_less_base)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   341
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   342
lemma power2_eq_imp_eq:
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   343
  fixes x y :: "'a::{ordered_semidom,recpower}"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   344
  shows "\<lbrakk>x\<twosuperior> = y\<twosuperior>; 0 \<le> x; 0 \<le> y\<rbrakk> \<Longrightarrow> x = y"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   345
unfolding numeral_2_eq_2 by (erule (2) power_eq_imp_eq_base, simp)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   346
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   347
lemma power_minus1_even[simp]: "(- 1) ^ (2*n) = (1::'a::{comm_ring_1,recpower})"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   348
apply (induct "n")
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   349
apply (auto simp add: power_Suc power_add)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   350
done
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   351
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   352
lemma power_even_eq: "(a::'a::recpower) ^ (2*n) = (a^n)^2"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   353
by (subst mult_commute) (simp add: power_mult)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   354
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   355
lemma power_odd_eq: "(a::int) ^ Suc(2*n) = a * (a^n)^2"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   356
by (simp add: power_even_eq) 
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   357
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   358
lemma power_minus_even [simp]:
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   359
     "(-a) ^ (2*n) = (a::'a::{comm_ring_1,recpower}) ^ (2*n)"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   360
by (simp add: power_minus1_even power_minus [of a]) 
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   361
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   362
lemma zero_le_even_power'[simp]:
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   363
     "0 \<le> (a::'a::{ordered_idom,recpower}) ^ (2*n)"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   364
proof (induct "n")
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   365
  case 0
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   366
    show ?case by (simp add: zero_le_one)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   367
next
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   368
  case (Suc n)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   369
    have "a ^ (2 * Suc n) = (a*a) * a ^ (2*n)" 
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   370
      by (simp add: mult_ac power_add power2_eq_square)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   371
    thus ?case
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   372
      by (simp add: prems zero_le_mult_iff)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   373
qed
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   374
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   375
lemma odd_power_less_zero:
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   376
     "(a::'a::{ordered_idom,recpower}) < 0 ==> a ^ Suc(2*n) < 0"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   377
proof (induct "n")
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   378
  case 0
23389
aaca6a8e5414 tuned proofs: avoid implicit prems;
wenzelm
parents: 23365
diff changeset
   379
  then show ?case by (simp add: Power.power_Suc)
23164
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   380
next
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   381
  case (Suc n)
23389
aaca6a8e5414 tuned proofs: avoid implicit prems;
wenzelm
parents: 23365
diff changeset
   382
  have "a ^ Suc (2 * Suc n) = (a*a) * a ^ Suc(2*n)" 
aaca6a8e5414 tuned proofs: avoid implicit prems;
wenzelm
parents: 23365
diff changeset
   383
    by (simp add: mult_ac power_add power2_eq_square Power.power_Suc)
aaca6a8e5414 tuned proofs: avoid implicit prems;
wenzelm
parents: 23365
diff changeset
   384
  thus ?case
aaca6a8e5414 tuned proofs: avoid implicit prems;
wenzelm
parents: 23365
diff changeset
   385
    by (simp add: prems mult_less_0_iff mult_neg_neg)
23164
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   386
qed
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   387
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   388
lemma odd_0_le_power_imp_0_le:
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   389
     "0 \<le> a  ^ Suc(2*n) ==> 0 \<le> (a::'a::{ordered_idom,recpower})"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   390
apply (insert odd_power_less_zero [of a n]) 
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   391
apply (force simp add: linorder_not_less [symmetric]) 
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   392
done
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   393
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   394
text{*Simprules for comparisons where common factors can be cancelled.*}
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   395
lemmas zero_compare_simps =
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   396
    add_strict_increasing add_strict_increasing2 add_increasing
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   397
    zero_le_mult_iff zero_le_divide_iff 
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   398
    zero_less_mult_iff zero_less_divide_iff 
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   399
    mult_le_0_iff divide_le_0_iff 
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   400
    mult_less_0_iff divide_less_0_iff 
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   401
    zero_le_power2 power2_less_0
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   402
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   403
subsubsection{*Nat *}
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   404
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   405
lemma Suc_pred': "0 < n ==> n = Suc(n - 1)"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   406
by (simp add: numerals)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   407
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   408
(*Expresses a natural number constant as the Suc of another one.
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   409
  NOT suitable for rewriting because n recurs in the condition.*)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   410
lemmas expand_Suc = Suc_pred' [of "number_of v", standard]
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   411
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   412
subsubsection{*Arith *}
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   413
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   414
lemma Suc_eq_add_numeral_1: "Suc n = n + 1"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   415
by (simp add: numerals)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   416
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   417
lemma Suc_eq_add_numeral_1_left: "Suc n = 1 + n"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   418
by (simp add: numerals)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   419
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   420
(* These two can be useful when m = number_of... *)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   421
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   422
lemma add_eq_if: "(m::nat) + n = (if m=0 then n else Suc ((m - 1) + n))"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   423
apply (case_tac "m")
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   424
apply (simp_all add: numerals)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   425
done
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   426
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   427
lemma mult_eq_if: "(m::nat) * n = (if m=0 then 0 else n + ((m - 1) * n))"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   428
apply (case_tac "m")
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   429
apply (simp_all add: numerals)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   430
done
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   431
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   432
lemma power_eq_if: "(p ^ m :: nat) = (if m=0 then 1 else p * (p ^ (m - 1)))"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   433
apply (case_tac "m")
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   434
apply (simp_all add: numerals)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   435
done
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   436
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   437
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   438
subsection{*Comparisons involving (0::nat) *}
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   439
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   440
text{*Simplification already does @{term "n<0"}, @{term "n\<le>0"} and @{term "0\<le>n"}.*}
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   441
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   442
lemma eq_number_of_0 [simp]:
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   443
     "(number_of v = (0::nat)) =  
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   444
      (if neg (number_of v :: int) then True else iszero (number_of v :: int))"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   445
by (simp del: nat_numeral_0_eq_0 add: nat_numeral_0_eq_0 [symmetric] iszero_0)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   446
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   447
lemma eq_0_number_of [simp]:
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   448
     "((0::nat) = number_of v) =  
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   449
      (if neg (number_of v :: int) then True else iszero (number_of v :: int))"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   450
by (rule trans [OF eq_sym_conv eq_number_of_0])
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   451
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   452
lemma less_0_number_of [simp]:
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   453
     "((0::nat) < number_of v) = neg (number_of (uminus v) :: int)"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   454
by (simp del: nat_numeral_0_eq_0 add: nat_numeral_0_eq_0 [symmetric] Pls_def)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   455
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   456
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   457
lemma neg_imp_number_of_eq_0: "neg (number_of v :: int) ==> number_of v = (0::nat)"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   458
by (simp del: nat_numeral_0_eq_0 add: nat_numeral_0_eq_0 [symmetric] iszero_0)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   459
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   460
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   461
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   462
subsection{*Comparisons involving  @{term Suc} *}
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   463
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   464
lemma eq_number_of_Suc [simp]:
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   465
     "(number_of v = Suc n) =  
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   466
        (let pv = number_of (Numeral.pred v) in  
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   467
         if neg pv then False else nat pv = n)"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   468
apply (simp only: simp_thms Let_def neg_eq_less_0 linorder_not_less 
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   469
                  number_of_pred nat_number_of_def 
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   470
            split add: split_if)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   471
apply (rule_tac x = "number_of v" in spec)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   472
apply (auto simp add: nat_eq_iff)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   473
done
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   474
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   475
lemma Suc_eq_number_of [simp]:
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   476
     "(Suc n = number_of v) =  
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   477
        (let pv = number_of (Numeral.pred v) in  
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   478
         if neg pv then False else nat pv = n)"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   479
by (rule trans [OF eq_sym_conv eq_number_of_Suc])
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   480
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   481
lemma less_number_of_Suc [simp]:
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   482
     "(number_of v < Suc n) =  
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   483
        (let pv = number_of (Numeral.pred v) in  
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   484
         if neg pv then True else nat pv < n)"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   485
apply (simp only: simp_thms Let_def neg_eq_less_0 linorder_not_less 
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   486
                  number_of_pred nat_number_of_def  
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   487
            split add: split_if)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   488
apply (rule_tac x = "number_of v" in spec)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   489
apply (auto simp add: nat_less_iff)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   490
done
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   491
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   492
lemma less_Suc_number_of [simp]:
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   493
     "(Suc n < number_of v) =  
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   494
        (let pv = number_of (Numeral.pred v) in  
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   495
         if neg pv then False else n < nat pv)"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   496
apply (simp only: simp_thms Let_def neg_eq_less_0 linorder_not_less 
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   497
                  number_of_pred nat_number_of_def
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   498
            split add: split_if)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   499
apply (rule_tac x = "number_of v" in spec)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   500
apply (auto simp add: zless_nat_eq_int_zless)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   501
done
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   502
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   503
lemma le_number_of_Suc [simp]:
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   504
     "(number_of v <= Suc n) =  
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   505
        (let pv = number_of (Numeral.pred v) in  
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   506
         if neg pv then True else nat pv <= n)"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   507
by (simp add: Let_def less_Suc_number_of linorder_not_less [symmetric])
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   508
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   509
lemma le_Suc_number_of [simp]:
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   510
     "(Suc n <= number_of v) =  
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   511
        (let pv = number_of (Numeral.pred v) in  
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   512
         if neg pv then False else n <= nat pv)"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   513
by (simp add: Let_def less_number_of_Suc linorder_not_less [symmetric])
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   514
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   515
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   516
lemma lemma1: "(m+m = n+n) = (m = (n::int))"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   517
by auto
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   518
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   519
lemma lemma2: "m+m ~= (1::int) + (n + n)"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   520
apply auto
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   521
apply (drule_tac f = "%x. x mod 2" in arg_cong)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   522
apply (simp add: zmod_zadd1_eq)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   523
done
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   524
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   525
lemma eq_number_of_BIT_BIT:
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   526
     "((number_of (v BIT x) ::int) = number_of (w BIT y)) =  
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   527
      (x=y & (((number_of v) ::int) = number_of w))"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   528
apply (simp only: number_of_BIT lemma1 lemma2 eq_commute
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   529
               OrderedGroup.add_left_cancel add_assoc OrderedGroup.add_0_left
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   530
            split add: bit.split)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   531
apply simp
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   532
done
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   533
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   534
lemma eq_number_of_BIT_Pls:
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   535
     "((number_of (v BIT x) ::int) = Numeral0) =  
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   536
      (x=bit.B0 & (((number_of v) ::int) = Numeral0))"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   537
apply (simp only: simp_thms  add: number_of_BIT number_of_Pls eq_commute
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   538
            split add: bit.split cong: imp_cong)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   539
apply (rule_tac x = "number_of v" in spec, safe)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   540
apply (simp_all (no_asm_use))
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   541
apply (drule_tac f = "%x. x mod 2" in arg_cong)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   542
apply (simp add: zmod_zadd1_eq)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   543
done
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   544
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   545
lemma eq_number_of_BIT_Min:
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   546
     "((number_of (v BIT x) ::int) = number_of Numeral.Min) =  
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   547
      (x=bit.B1 & (((number_of v) ::int) = number_of Numeral.Min))"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   548
apply (simp only: simp_thms  add: number_of_BIT number_of_Min eq_commute
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   549
            split add: bit.split cong: imp_cong)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   550
apply (rule_tac x = "number_of v" in spec, auto)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   551
apply (drule_tac f = "%x. x mod 2" in arg_cong, auto)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   552
done
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   553
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   554
lemma eq_number_of_Pls_Min: "(Numeral0 ::int) ~= number_of Numeral.Min"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   555
by auto
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   556
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   557
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   558
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   559
subsection{*Max and Min Combined with @{term Suc} *}
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   560
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   561
lemma max_number_of_Suc [simp]:
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   562
     "max (Suc n) (number_of v) =  
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   563
        (let pv = number_of (Numeral.pred v) in  
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   564
         if neg pv then Suc n else Suc(max n (nat pv)))"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   565
apply (simp only: Let_def neg_eq_less_0 number_of_pred nat_number_of_def 
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   566
            split add: split_if nat.split)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   567
apply (rule_tac x = "number_of v" in spec) 
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   568
apply auto
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   569
done
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   570
 
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   571
lemma max_Suc_number_of [simp]:
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   572
     "max (number_of v) (Suc n) =  
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   573
        (let pv = number_of (Numeral.pred v) in  
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   574
         if neg pv then Suc n else Suc(max (nat pv) n))"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   575
apply (simp only: Let_def neg_eq_less_0 number_of_pred nat_number_of_def 
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   576
            split add: split_if nat.split)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   577
apply (rule_tac x = "number_of v" in spec) 
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   578
apply auto
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   579
done
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   580
 
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   581
lemma min_number_of_Suc [simp]:
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   582
     "min (Suc n) (number_of v) =  
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   583
        (let pv = number_of (Numeral.pred v) in  
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   584
         if neg pv then 0 else Suc(min n (nat pv)))"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   585
apply (simp only: Let_def neg_eq_less_0 number_of_pred nat_number_of_def 
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   586
            split add: split_if nat.split)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   587
apply (rule_tac x = "number_of v" in spec) 
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   588
apply auto
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   589
done
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   590
 
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   591
lemma min_Suc_number_of [simp]:
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   592
     "min (number_of v) (Suc n) =  
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   593
        (let pv = number_of (Numeral.pred v) in  
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   594
         if neg pv then 0 else Suc(min (nat pv) n))"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   595
apply (simp only: Let_def neg_eq_less_0 number_of_pred nat_number_of_def 
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   596
            split add: split_if nat.split)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   597
apply (rule_tac x = "number_of v" in spec) 
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   598
apply auto
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   599
done
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   600
 
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   601
subsection{*Literal arithmetic involving powers*}
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   602
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   603
lemma nat_power_eq: "(0::int) <= z ==> nat (z^n) = nat z ^ n"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   604
apply (induct "n")
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   605
apply (simp_all (no_asm_simp) add: nat_mult_distrib)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   606
done
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   607
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   608
lemma power_nat_number_of:
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   609
     "(number_of v :: nat) ^ n =  
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   610
       (if neg (number_of v :: int) then 0^n else nat ((number_of v :: int) ^ n))"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   611
by (simp only: simp_thms neg_nat not_neg_eq_ge_0 nat_number_of_def nat_power_eq
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   612
         split add: split_if cong: imp_cong)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   613
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   614
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   615
lemmas power_nat_number_of_number_of = power_nat_number_of [of _ "number_of w", standard]
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   616
declare power_nat_number_of_number_of [simp]
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   617
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   618
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   619
23294
9302a50a5bc9 generalize zpower_number_of_{even,odd} lemmas
huffman
parents: 23277
diff changeset
   620
text{*For arbitrary rings*}
23164
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   621
23294
9302a50a5bc9 generalize zpower_number_of_{even,odd} lemmas
huffman
parents: 23277
diff changeset
   622
lemma power_number_of_even:
9302a50a5bc9 generalize zpower_number_of_{even,odd} lemmas
huffman
parents: 23277
diff changeset
   623
  fixes z :: "'a::{number_ring,recpower}"
9302a50a5bc9 generalize zpower_number_of_{even,odd} lemmas
huffman
parents: 23277
diff changeset
   624
  shows "z ^ number_of (w BIT bit.B0) = (let w = z ^ (number_of w) in w * w)"
23164
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   625
unfolding Let_def nat_number_of_def number_of_BIT bit.cases
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   626
apply (rule_tac x = "number_of w" in spec, clarify)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   627
apply (case_tac " (0::int) <= x")
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   628
apply (auto simp add: nat_mult_distrib power_even_eq power2_eq_square)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   629
done
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   630
23294
9302a50a5bc9 generalize zpower_number_of_{even,odd} lemmas
huffman
parents: 23277
diff changeset
   631
lemma power_number_of_odd:
9302a50a5bc9 generalize zpower_number_of_{even,odd} lemmas
huffman
parents: 23277
diff changeset
   632
  fixes z :: "'a::{number_ring,recpower}"
9302a50a5bc9 generalize zpower_number_of_{even,odd} lemmas
huffman
parents: 23277
diff changeset
   633
  shows "z ^ number_of (w BIT bit.B1) = (if (0::int) <= number_of w
23164
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   634
     then (let w = z ^ (number_of w) in z * w * w) else 1)"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   635
unfolding Let_def nat_number_of_def number_of_BIT bit.cases
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   636
apply (rule_tac x = "number_of w" in spec, auto)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   637
apply (simp only: nat_add_distrib nat_mult_distrib)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   638
apply simp
23294
9302a50a5bc9 generalize zpower_number_of_{even,odd} lemmas
huffman
parents: 23277
diff changeset
   639
apply (auto simp add: nat_add_distrib nat_mult_distrib power_even_eq power2_eq_square neg_nat power_Suc)
23164
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   640
done
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   641
23294
9302a50a5bc9 generalize zpower_number_of_{even,odd} lemmas
huffman
parents: 23277
diff changeset
   642
lemmas zpower_number_of_even = power_number_of_even [where 'a=int]
9302a50a5bc9 generalize zpower_number_of_{even,odd} lemmas
huffman
parents: 23277
diff changeset
   643
lemmas zpower_number_of_odd = power_number_of_odd [where 'a=int]
23164
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   644
23294
9302a50a5bc9 generalize zpower_number_of_{even,odd} lemmas
huffman
parents: 23277
diff changeset
   645
lemmas power_number_of_even_number_of [simp] =
9302a50a5bc9 generalize zpower_number_of_{even,odd} lemmas
huffman
parents: 23277
diff changeset
   646
    power_number_of_even [of "number_of v", standard]
23164
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   647
23294
9302a50a5bc9 generalize zpower_number_of_{even,odd} lemmas
huffman
parents: 23277
diff changeset
   648
lemmas power_number_of_odd_number_of [simp] =
9302a50a5bc9 generalize zpower_number_of_{even,odd} lemmas
huffman
parents: 23277
diff changeset
   649
    power_number_of_odd [of "number_of v", standard]
23164
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   650
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   651
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   652
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   653
ML
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   654
{*
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   655
val numerals = thms"numerals";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   656
val numeral_ss = simpset() addsimps numerals;
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   657
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   658
val nat_bin_arith_setup =
24093
5d0ecd0c8f3c tuned LinArith setup;
wenzelm
parents: 24075
diff changeset
   659
 LinArith.map_data
23164
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   660
   (fn {add_mono_thms, mult_mono_thms, inj_thms, lessD, neqE, simpset} =>
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   661
     {add_mono_thms = add_mono_thms, mult_mono_thms = mult_mono_thms,
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   662
      inj_thms = inj_thms,
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   663
      lessD = lessD, neqE = neqE,
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   664
      simpset = simpset addsimps [Suc_nat_number_of, int_nat_number_of,
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   665
                                  not_neg_number_of_Pls,
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   666
                                  neg_number_of_Min,neg_number_of_BIT]})
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   667
*}
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   668
24075
366d4d234814 arith method setup: proper context;
wenzelm
parents: 23969
diff changeset
   669
declaration {* K nat_bin_arith_setup *}
23164
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   670
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   671
(* Enable arith to deal with div/mod k where k is a numeral: *)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   672
declare split_div[of _ _ "number_of k", standard, arith_split]
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   673
declare split_mod[of _ _ "number_of k", standard, arith_split]
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   674
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   675
lemma nat_number_of_Pls: "Numeral0 = (0::nat)"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   676
  by (simp add: number_of_Pls nat_number_of_def)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   677
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   678
lemma nat_number_of_Min: "number_of Numeral.Min = (0::nat)"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   679
  apply (simp only: number_of_Min nat_number_of_def nat_zminus_int)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   680
  done
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   681
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   682
lemma nat_number_of_BIT_1:
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   683
  "number_of (w BIT bit.B1) =
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   684
    (if neg (number_of w :: int) then 0
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   685
     else let n = number_of w in Suc (n + n))"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   686
  apply (simp only: nat_number_of_def Let_def split: split_if)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   687
  apply (intro conjI impI)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   688
   apply (simp add: neg_nat neg_number_of_BIT)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   689
  apply (rule int_int_eq [THEN iffD1])
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   690
  apply (simp only: not_neg_nat neg_number_of_BIT int_Suc zadd_int [symmetric] simp_thms)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   691
  apply (simp only: number_of_BIT zadd_assoc split: bit.split)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   692
  apply simp
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   693
  done
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   694
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   695
lemma nat_number_of_BIT_0:
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   696
    "number_of (w BIT bit.B0) = (let n::nat = number_of w in n + n)"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   697
  apply (simp only: nat_number_of_def Let_def)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   698
  apply (cases "neg (number_of w :: int)")
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   699
   apply (simp add: neg_nat neg_number_of_BIT)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   700
  apply (rule int_int_eq [THEN iffD1])
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   701
  apply (simp only: not_neg_nat neg_number_of_BIT int_Suc zadd_int [symmetric] simp_thms)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   702
  apply (simp only: number_of_BIT zadd_assoc)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   703
  apply simp
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   704
  done
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   705
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   706
lemmas nat_number =
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   707
  nat_number_of_Pls nat_number_of_Min
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   708
  nat_number_of_BIT_1 nat_number_of_BIT_0
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   709
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   710
lemma Let_Suc [simp]: "Let (Suc n) f == f (Suc n)"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   711
  by (simp add: Let_def)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   712
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   713
lemma power_m1_even: "(-1) ^ (2*n) = (1::'a::{number_ring,recpower})"
23294
9302a50a5bc9 generalize zpower_number_of_{even,odd} lemmas
huffman
parents: 23277
diff changeset
   714
by (simp add: power_mult power_Suc); 
23164
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   715
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   716
lemma power_m1_odd: "(-1) ^ Suc(2*n) = (-1::'a::{number_ring,recpower})"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   717
by (simp add: power_mult power_Suc); 
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   718
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   719
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   720
subsection{*Literal arithmetic and @{term of_nat}*}
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   721
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   722
lemma of_nat_double:
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   723
     "0 \<le> x ==> of_nat (nat (2 * x)) = of_nat (nat x) + of_nat (nat x)"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   724
by (simp only: mult_2 nat_add_distrib of_nat_add) 
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   725
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   726
lemma nat_numeral_m1_eq_0: "-1 = (0::nat)"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   727
by (simp only: nat_number_of_def)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   728
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   729
lemma of_nat_number_of_lemma:
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   730
     "of_nat (number_of v :: nat) =  
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   731
         (if 0 \<le> (number_of v :: int) 
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   732
          then (number_of v :: 'a :: number_ring)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   733
          else 0)"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   734
by (simp add: int_number_of_def nat_number_of_def number_of_eq of_nat_nat);
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   735
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   736
lemma of_nat_number_of_eq [simp]:
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   737
     "of_nat (number_of v :: nat) =  
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   738
         (if neg (number_of v :: int) then 0  
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   739
          else (number_of v :: 'a :: number_ring))"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   740
by (simp only: of_nat_number_of_lemma neg_def, simp) 
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   741
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   742
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   743
subsection {*Lemmas for the Combination and Cancellation Simprocs*}
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   744
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   745
lemma nat_number_of_add_left:
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   746
     "number_of v + (number_of v' + (k::nat)) =  
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   747
         (if neg (number_of v :: int) then number_of v' + k  
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   748
          else if neg (number_of v' :: int) then number_of v + k  
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   749
          else number_of (v + v') + k)"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   750
by simp
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   751
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   752
lemma nat_number_of_mult_left:
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   753
     "number_of v * (number_of v' * (k::nat)) =  
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   754
         (if neg (number_of v :: int) then 0
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   755
          else number_of (v * v') * k)"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   756
by simp
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   757
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   758
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   759
subsubsection{*For @{text combine_numerals}*}
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   760
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   761
lemma left_add_mult_distrib: "i*u + (j*u + k) = (i+j)*u + (k::nat)"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   762
by (simp add: add_mult_distrib)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   763
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   764
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   765
subsubsection{*For @{text cancel_numerals}*}
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   766
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   767
lemma nat_diff_add_eq1:
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   768
     "j <= (i::nat) ==> ((i*u + m) - (j*u + n)) = (((i-j)*u + m) - n)"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   769
by (simp split add: nat_diff_split add: add_mult_distrib)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   770
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   771
lemma nat_diff_add_eq2:
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   772
     "i <= (j::nat) ==> ((i*u + m) - (j*u + n)) = (m - ((j-i)*u + n))"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   773
by (simp split add: nat_diff_split add: add_mult_distrib)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   774
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   775
lemma nat_eq_add_iff1:
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   776
     "j <= (i::nat) ==> (i*u + m = j*u + n) = ((i-j)*u + m = n)"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   777
by (auto split add: nat_diff_split simp add: add_mult_distrib)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   778
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   779
lemma nat_eq_add_iff2:
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   780
     "i <= (j::nat) ==> (i*u + m = j*u + n) = (m = (j-i)*u + n)"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   781
by (auto split add: nat_diff_split simp add: add_mult_distrib)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   782
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   783
lemma nat_less_add_iff1:
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   784
     "j <= (i::nat) ==> (i*u + m < j*u + n) = ((i-j)*u + m < n)"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   785
by (auto split add: nat_diff_split simp add: add_mult_distrib)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   786
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   787
lemma nat_less_add_iff2:
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   788
     "i <= (j::nat) ==> (i*u + m < j*u + n) = (m < (j-i)*u + n)"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   789
by (auto split add: nat_diff_split simp add: add_mult_distrib)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   790
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   791
lemma nat_le_add_iff1:
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   792
     "j <= (i::nat) ==> (i*u + m <= j*u + n) = ((i-j)*u + m <= n)"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   793
by (auto split add: nat_diff_split simp add: add_mult_distrib)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   794
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   795
lemma nat_le_add_iff2:
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   796
     "i <= (j::nat) ==> (i*u + m <= j*u + n) = (m <= (j-i)*u + n)"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   797
by (auto split add: nat_diff_split simp add: add_mult_distrib)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   798
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   799
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   800
subsubsection{*For @{text cancel_numeral_factors} *}
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   801
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   802
lemma nat_mult_le_cancel1: "(0::nat) < k ==> (k*m <= k*n) = (m<=n)"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   803
by auto
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   804
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   805
lemma nat_mult_less_cancel1: "(0::nat) < k ==> (k*m < k*n) = (m<n)"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   806
by auto
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   807
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   808
lemma nat_mult_eq_cancel1: "(0::nat) < k ==> (k*m = k*n) = (m=n)"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   809
by auto
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   810
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   811
lemma nat_mult_div_cancel1: "(0::nat) < k ==> (k*m) div (k*n) = (m div n)"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   812
by auto
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   813
23969
ef782bbf2d09 Added cancel simprocs for dvd on nat and int
nipkow
parents: 23389
diff changeset
   814
lemma nat_mult_dvd_cancel_disj[simp]:
ef782bbf2d09 Added cancel simprocs for dvd on nat and int
nipkow
parents: 23389
diff changeset
   815
  "(k*m) dvd (k*n) = (k=0 | m dvd (n::nat))"
ef782bbf2d09 Added cancel simprocs for dvd on nat and int
nipkow
parents: 23389
diff changeset
   816
by(auto simp: dvd_eq_mod_eq_0 mod_mult_distrib2[symmetric])
ef782bbf2d09 Added cancel simprocs for dvd on nat and int
nipkow
parents: 23389
diff changeset
   817
ef782bbf2d09 Added cancel simprocs for dvd on nat and int
nipkow
parents: 23389
diff changeset
   818
lemma nat_mult_dvd_cancel1: "0 < k \<Longrightarrow> (k*m) dvd (k*n::nat) = (m dvd n)"
ef782bbf2d09 Added cancel simprocs for dvd on nat and int
nipkow
parents: 23389
diff changeset
   819
by(auto)
ef782bbf2d09 Added cancel simprocs for dvd on nat and int
nipkow
parents: 23389
diff changeset
   820
23164
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   821
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   822
subsubsection{*For @{text cancel_factor} *}
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   823
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   824
lemma nat_mult_le_cancel_disj: "(k*m <= k*n) = ((0::nat) < k --> m<=n)"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   825
by auto
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   826
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   827
lemma nat_mult_less_cancel_disj: "(k*m < k*n) = ((0::nat) < k & m<n)"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   828
by auto
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   829
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   830
lemma nat_mult_eq_cancel_disj: "(k*m = k*n) = (k = (0::nat) | m=n)"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   831
by auto
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   832
23969
ef782bbf2d09 Added cancel simprocs for dvd on nat and int
nipkow
parents: 23389
diff changeset
   833
lemma nat_mult_div_cancel_disj[simp]:
23164
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   834
     "(k*m) div (k*n) = (if k = (0::nat) then 0 else m div n)"
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   835
by (simp add: nat_mult_div_cancel1)
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   836
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   837
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   838
subsection {* legacy ML bindings *}
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   839
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   840
ML
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   841
{*
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   842
val eq_nat_nat_iff = thm"eq_nat_nat_iff";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   843
val eq_nat_number_of = thm"eq_nat_number_of";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   844
val less_nat_number_of = thm"less_nat_number_of";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   845
val power2_eq_square = thm "power2_eq_square";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   846
val zero_le_power2 = thm "zero_le_power2";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   847
val zero_less_power2 = thm "zero_less_power2";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   848
val zero_eq_power2 = thm "zero_eq_power2";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   849
val abs_power2 = thm "abs_power2";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   850
val power2_abs = thm "power2_abs";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   851
val power2_minus = thm "power2_minus";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   852
val power_minus1_even = thm "power_minus1_even";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   853
val power_minus_even = thm "power_minus_even";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   854
val odd_power_less_zero = thm "odd_power_less_zero";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   855
val odd_0_le_power_imp_0_le = thm "odd_0_le_power_imp_0_le";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   856
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   857
val Suc_pred' = thm"Suc_pred'";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   858
val expand_Suc = thm"expand_Suc";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   859
val Suc_eq_add_numeral_1 = thm"Suc_eq_add_numeral_1";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   860
val Suc_eq_add_numeral_1_left = thm"Suc_eq_add_numeral_1_left";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   861
val add_eq_if = thm"add_eq_if";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   862
val mult_eq_if = thm"mult_eq_if";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   863
val power_eq_if = thm"power_eq_if";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   864
val eq_number_of_0 = thm"eq_number_of_0";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   865
val eq_0_number_of = thm"eq_0_number_of";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   866
val less_0_number_of = thm"less_0_number_of";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   867
val neg_imp_number_of_eq_0 = thm"neg_imp_number_of_eq_0";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   868
val eq_number_of_Suc = thm"eq_number_of_Suc";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   869
val Suc_eq_number_of = thm"Suc_eq_number_of";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   870
val less_number_of_Suc = thm"less_number_of_Suc";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   871
val less_Suc_number_of = thm"less_Suc_number_of";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   872
val le_number_of_Suc = thm"le_number_of_Suc";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   873
val le_Suc_number_of = thm"le_Suc_number_of";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   874
val eq_number_of_BIT_BIT = thm"eq_number_of_BIT_BIT";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   875
val eq_number_of_BIT_Pls = thm"eq_number_of_BIT_Pls";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   876
val eq_number_of_BIT_Min = thm"eq_number_of_BIT_Min";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   877
val eq_number_of_Pls_Min = thm"eq_number_of_Pls_Min";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   878
val of_nat_number_of_eq = thm"of_nat_number_of_eq";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   879
val nat_power_eq = thm"nat_power_eq";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   880
val power_nat_number_of = thm"power_nat_number_of";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   881
val zpower_number_of_even = thm"zpower_number_of_even";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   882
val zpower_number_of_odd = thm"zpower_number_of_odd";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   883
val nat_number_of_Pls = thm"nat_number_of_Pls";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   884
val nat_number_of_Min = thm"nat_number_of_Min";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   885
val Let_Suc = thm"Let_Suc";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   886
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   887
val nat_number = thms"nat_number";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   888
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   889
val nat_number_of_add_left = thm"nat_number_of_add_left";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   890
val nat_number_of_mult_left = thm"nat_number_of_mult_left";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   891
val left_add_mult_distrib = thm"left_add_mult_distrib";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   892
val nat_diff_add_eq1 = thm"nat_diff_add_eq1";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   893
val nat_diff_add_eq2 = thm"nat_diff_add_eq2";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   894
val nat_eq_add_iff1 = thm"nat_eq_add_iff1";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   895
val nat_eq_add_iff2 = thm"nat_eq_add_iff2";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   896
val nat_less_add_iff1 = thm"nat_less_add_iff1";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   897
val nat_less_add_iff2 = thm"nat_less_add_iff2";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   898
val nat_le_add_iff1 = thm"nat_le_add_iff1";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   899
val nat_le_add_iff2 = thm"nat_le_add_iff2";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   900
val nat_mult_le_cancel1 = thm"nat_mult_le_cancel1";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   901
val nat_mult_less_cancel1 = thm"nat_mult_less_cancel1";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   902
val nat_mult_eq_cancel1 = thm"nat_mult_eq_cancel1";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   903
val nat_mult_div_cancel1 = thm"nat_mult_div_cancel1";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   904
val nat_mult_le_cancel_disj = thm"nat_mult_le_cancel_disj";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   905
val nat_mult_less_cancel_disj = thm"nat_mult_less_cancel_disj";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   906
val nat_mult_eq_cancel_disj = thm"nat_mult_eq_cancel_disj";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   907
val nat_mult_div_cancel_disj = thm"nat_mult_div_cancel_disj";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   908
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   909
val power_minus_even = thm"power_minus_even";
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   910
*}
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   911
69e55066dbca moved Integ files to canonical place;
wenzelm
parents:
diff changeset
   912
end