joined theories IntDef, Numeral, IntArith to theory Int
authorhaftmann
Tue Jan 15 16:19:23 2008 +0100 (2008-01-15)
changeset 259198b1c0d434824
parent 25918 82dd239e0f65
child 25920 8df5eabda5f6
joined theories IntDef, Numeral, IntArith to theory Int
NEWS
src/HOL/Algebra/IntRing.thy
src/HOL/Arith_Tools.thy
src/HOL/Complex/ex/linreif.ML
src/HOL/Complex/ex/mireif.ML
src/HOL/Hyperreal/NSA.thy
src/HOL/Import/HOL/HOL4Prob.thy
src/HOL/Import/HOL/HOL4Real.thy
src/HOL/Import/HOL/HOL4Vec.thy
src/HOL/Import/HOL/HOL4Word32.thy
src/HOL/Int.thy
src/HOL/IntArith.thy
src/HOL/IntDef.thy
src/HOL/IntDiv.thy
src/HOL/IsaMakefile
src/HOL/Library/Code_Integer.thy
src/HOL/Library/Efficient_Nat.thy
src/HOL/Library/Eval.thy
src/HOL/Library/Word.thy
src/HOL/NatBin.thy
src/HOL/Nominal/nominal_atoms.ML
src/HOL/Numeral.thy
src/HOL/Presburger.thy
src/HOL/SetInterval.thy
src/HOL/Tools/ComputeNumeral.thy
src/HOL/Tools/Qelim/cooper_data.ML
src/HOL/Tools/lin_arith.ML
src/HOL/Tools/numeral.ML
src/HOL/Tools/numeral_syntax.ML
src/HOL/Word/BinBoolList.thy
src/HOL/Word/BinGeneral.thy
src/HOL/Word/BinOperations.thy
src/HOL/Word/Num_Lemmas.thy
src/HOL/Word/WordArith.thy
src/HOL/Word/WordDefinition.thy
src/HOL/Word/WordShift.thy
src/HOL/ex/SVC_Oracle.thy
src/HOL/hologic.ML
src/HOL/int_arith1.ML
src/HOL/nat_simprocs.ML
src/Provers/Arith/assoc_fold.ML
     1.1 --- a/NEWS	Tue Jan 15 16:19:21 2008 +0100
     1.2 +++ b/NEWS	Tue Jan 15 16:19:23 2008 +0100
     1.3 @@ -25,8 +25,14 @@
     1.4  
     1.5  *** HOL ***
     1.6  
     1.7 +* Merged theories IntDef, Numeral and IntArith into unified theory Int.
     1.8 +INCOMPATIBILITY.
     1.9 +
    1.10 +* Theory Library/Code_Index: type "index" now represents natural numbers rather
    1.11 +than integers.  INCOMPATIBILITY.
    1.12 +
    1.13  * New class "uminus" with operation "uminus" (split of from class "minus"
    1.14 -which now only has operation "minus", binary).
    1.15 +which now only has operation "minus", binary).  INCOMPATIBILITY.
    1.16  
    1.17  * New primrec package.  Specification syntax conforms in style to
    1.18  definition/function/....  No separate induction rule is provided.
    1.19 @@ -40,14 +46,14 @@
    1.20  * Library/ListSpace: new theory of arithmetic vector operations.
    1.21  
    1.22  * Constants "card", "internal_split", "option_map" now with authentic
    1.23 -syntax.
    1.24 +syntax.  INCOMPATIBILITY.
    1.25  
    1.26  * Definitions subset_def, psubset_def, set_diff_def, Compl_def,
    1.27  le_bool_def, less_bool_def, le_fun_def, less_fun_def, inf_bool_def,
    1.28  sup_bool_def, Inf_bool_def, Sup_bool_def, inf_fun_def, sup_fun_def,
    1.29  Inf_fun_def, Sup_fun_def, inf_set_def, sup_set_def, Inf_set_def,
    1.30  Sup_set_def, le_def, less_def, option_map_def now with object
    1.31 -equality.
    1.32 +equality.  INCOMPATIBILITY.
    1.33  
    1.34  * New method "induction_scheme" derives user-specified induction rules
    1.35  from wellfounded induction and completeness of patterns. This factors
     2.1 --- a/src/HOL/Algebra/IntRing.thy	Tue Jan 15 16:19:21 2008 +0100
     2.2 +++ b/src/HOL/Algebra/IntRing.thy	Tue Jan 15 16:19:23 2008 +0100
     2.3 @@ -5,7 +5,7 @@
     2.4  *)
     2.5  
     2.6  theory IntRing
     2.7 -imports QuotRing IntDef
     2.8 +imports QuotRing Int
     2.9  begin
    2.10  
    2.11  
     3.1 --- a/src/HOL/Arith_Tools.thy	Tue Jan 15 16:19:21 2008 +0100
     3.2 +++ b/src/HOL/Arith_Tools.thy	Tue Jan 15 16:19:23 2008 +0100
     3.3 @@ -30,8 +30,8 @@
     3.4    the right simplification, but with some redundant inequality
     3.5    tests.*}
     3.6  lemma neg_number_of_pred_iff_0:
     3.7 -  "neg (number_of (Numeral.pred v)::int) = (number_of v = (0::nat))"
     3.8 -apply (subgoal_tac "neg (number_of (Numeral.pred v)) = (number_of v < Suc 0) ")
     3.9 +  "neg (number_of (Int.pred v)::int) = (number_of v = (0::nat))"
    3.10 +apply (subgoal_tac "neg (number_of (Int.pred v)) = (number_of v < Suc 0) ")
    3.11  apply (simp only: less_Suc_eq_le le_0_eq)
    3.12  apply (subst less_number_of_Suc, simp)
    3.13  done
    3.14 @@ -40,7 +40,7 @@
    3.15     simproc*}
    3.16  lemma Suc_diff_number_of:
    3.17       "neg (number_of (uminus v)::int) ==>
    3.18 -      Suc m - (number_of v) = m - (number_of (Numeral.pred v))"
    3.19 +      Suc m - (number_of v) = m - (number_of (Int.pred v))"
    3.20  apply (subst Suc_diff_eq_diff_pred)
    3.21  apply simp
    3.22  apply (simp del: nat_numeral_1_eq_1)
    3.23 @@ -56,13 +56,13 @@
    3.24  
    3.25  lemma nat_case_number_of [simp]:
    3.26       "nat_case a f (number_of v) =
    3.27 -        (let pv = number_of (Numeral.pred v) in
    3.28 +        (let pv = number_of (Int.pred v) in
    3.29           if neg pv then a else f (nat pv))"
    3.30  by (simp split add: nat.split add: Let_def neg_number_of_pred_iff_0)
    3.31  
    3.32  lemma nat_case_add_eq_if [simp]:
    3.33       "nat_case a f ((number_of v) + n) =
    3.34 -       (let pv = number_of (Numeral.pred v) in
    3.35 +       (let pv = number_of (Int.pred v) in
    3.36           if neg pv then nat_case a f n else f (nat pv + n))"
    3.37  apply (subst add_eq_if)
    3.38  apply (simp split add: nat.split
    3.39 @@ -73,7 +73,7 @@
    3.40  
    3.41  lemma nat_rec_number_of [simp]:
    3.42       "nat_rec a f (number_of v) =
    3.43 -        (let pv = number_of (Numeral.pred v) in
    3.44 +        (let pv = number_of (Int.pred v) in
    3.45           if neg pv then a else f (nat pv) (nat_rec a f (nat pv)))"
    3.46  apply (case_tac " (number_of v) ::nat")
    3.47  apply (simp_all (no_asm_simp) add: Let_def neg_number_of_pred_iff_0)
    3.48 @@ -82,7 +82,7 @@
    3.49  
    3.50  lemma nat_rec_add_eq_if [simp]:
    3.51       "nat_rec a f (number_of v + n) =
    3.52 -        (let pv = number_of (Numeral.pred v) in
    3.53 +        (let pv = number_of (Int.pred v) in
    3.54           if neg pv then nat_rec a f n
    3.55                     else f (nat pv + n) (nat_rec a f (nat pv + n)))"
    3.56  apply (subst add_eq_if)
     4.1 --- a/src/HOL/Complex/ex/linreif.ML	Tue Jan 15 16:19:21 2008 +0100
     4.2 +++ b/src/HOL/Complex/ex/linreif.ML	Tue Jan 15 16:19:23 2008 +0100
     4.3 @@ -33,8 +33,8 @@
     4.4        | Const (@{const_name "HOL.times"},_)$t1$t2 => (case (num_of_term vs t1) of C i => 
     4.5            Mul (i,num_of_term vs t2)
     4.6          | _ => error "num_of_term: unsupported Multiplication")
     4.7 -      | Const("RealDef.real",_) $ Const (@{const_name "Numeral.number_of"},_)$t' => C (HOLogic.dest_numeral t')
     4.8 -      | Const (@{const_name "Numeral.number_of"},_)$t' => C (HOLogic.dest_numeral t')
     4.9 +      | Const("RealDef.real",_) $ Const (@{const_name "Int.number_of"},_)$t' => C (HOLogic.dest_numeral t')
    4.10 +      | Const (@{const_name "Int.number_of"},_)$t' => C (HOLogic.dest_numeral t')
    4.11        | _ => error ("num_of_term: unknown term " ^ (Display.raw_string_of_term t));
    4.12  
    4.13  (* pseudo reification : term -> fm *)
     5.1 --- a/src/HOL/Complex/ex/mireif.ML	Tue Jan 15 16:19:21 2008 +0100
     5.2 +++ b/src/HOL/Complex/ex/mireif.ML	Tue Jan 15 16:19:23 2008 +0100
     5.3 @@ -32,8 +32,8 @@
     5.4                                     | _ => error "num_of_term: unsupported Multiplication")
     5.5        | Const("RealDef.real",_)$ (Const (@{const_name "RComplete.floor"},_)$ t') => Floor (num_of_term vs t')
     5.6        | Const("RealDef.real",_)$ (Const (@{const_name "RComplete.ceiling"},_)$ t') => Neg(Floor (Neg (num_of_term vs t')))
     5.7 -      | Const("RealDef.real",_) $ Const (@{const_name "Numeral.number_of"},_)$t' => C (HOLogic.dest_numeral t')
     5.8 -      | Const (@{const_name "Numeral.number_of"},_)$t' => C (HOLogic.dest_numeral t')
     5.9 +      | Const("RealDef.real",_) $ Const (@{const_name "Int.number_of"},_)$t' => C (HOLogic.dest_numeral t')
    5.10 +      | Const (@{const_name "Int.number_of"},_)$t' => C (HOLogic.dest_numeral t')
    5.11        | _ => error ("num_of_term: unknown term " ^ (Display.raw_string_of_term t));
    5.12          
    5.13  
    5.14 @@ -44,7 +44,7 @@
    5.15        | Const("False",_) => F
    5.16        | Const(@{const_name HOL.less},_)$t1$t2 => Lt (Sub (num_of_term vs t1,num_of_term vs t2))
    5.17        | Const(@{const_name HOL.less_eq},_)$t1$t2 => Le (Sub (num_of_term vs t1,num_of_term vs t2))
    5.18 -      | Const (@{const_name "MIR.rdvd"},_ )$ (Const("RealDef.real",_) $ (Const(@{const_name "Numeral.number_of"},_)$t1))$t2 => 
    5.19 +      | Const (@{const_name "MIR.rdvd"},_ )$ (Const("RealDef.real",_) $ (Const(@{const_name "Int.number_of"},_)$t1))$t2 => 
    5.20          Dvd (HOLogic.dest_numeral t1, num_of_term vs t2)
    5.21        | Const("op =",eqT)$t1$t2 => 
    5.22          if (domain_type eqT = @{typ real})
     6.1 --- a/src/HOL/Hyperreal/NSA.thy	Tue Jan 15 16:19:21 2008 +0100
     6.2 +++ b/src/HOL/Hyperreal/NSA.thy	Tue Jan 15 16:19:23 2008 +0100
     6.3 @@ -678,11 +678,11 @@
     6.4    case u of
     6.5        Const(@{const_name HOL.zero}, _) => NONE
     6.6      | Const(@{const_name HOL.one}, _) => NONE
     6.7 -    | Const(@{const_name Numeral.number_of}, _) $ _ => NONE
     6.8 +    | Const(@{const_name Int.number_of}, _) $ _ => NONE
     6.9      | _ => SOME (case t of
    6.10                  Const(@{const_name HOL.zero}, _) => meta_zero_approx_reorient
    6.11                | Const(@{const_name HOL.one}, _) => meta_one_approx_reorient
    6.12 -              | Const(@{const_name Numeral.number_of}, _) $ _ =>
    6.13 +              | Const(@{const_name Int.number_of}, _) $ _ =>
    6.14                                   meta_number_of_approx_reorient);
    6.15  
    6.16  in
     7.1 --- a/src/HOL/Import/HOL/HOL4Prob.thy	Tue Jan 15 16:19:21 2008 +0100
     7.2 +++ b/src/HOL/Import/HOL/HOL4Prob.thy	Tue Jan 15 16:19:23 2008 +0100
     7.3 @@ -37,7 +37,7 @@
     7.4     ((op div::nat => nat => nat) (0::nat)
     7.5       ((number_of \<Colon> int => nat)
     7.6         ((op BIT \<Colon> int => bit => int)
     7.7 -         ((op BIT \<Colon> int => bit => int) (Numeral.Pls \<Colon> int) (bit.B1::bit))
     7.8 +         ((op BIT \<Colon> int => bit => int) (Int.Pls \<Colon> int) (bit.B1::bit))
     7.9           (bit.B0::bit))))
    7.10     (0::nat))
    7.11   ((op &::bool => bool => bool)
    7.12 @@ -45,18 +45,18 @@
    7.13       ((op div::nat => nat => nat) (1::nat)
    7.14         ((number_of \<Colon> int => nat)
    7.15           ((op BIT \<Colon> int => bit => int)
    7.16 -           ((op BIT \<Colon> int => bit => int) (Numeral.Pls \<Colon> int) (bit.B1::bit))
    7.17 +           ((op BIT \<Colon> int => bit => int) (Int.Pls \<Colon> int) (bit.B1::bit))
    7.18             (bit.B0::bit))))
    7.19       (0::nat))
    7.20     ((op =::nat => nat => bool)
    7.21       ((op div::nat => nat => nat)
    7.22         ((number_of \<Colon> int => nat)
    7.23           ((op BIT \<Colon> int => bit => int)
    7.24 -           ((op BIT \<Colon> int => bit => int) (Numeral.Pls \<Colon> int) (bit.B1::bit))
    7.25 +           ((op BIT \<Colon> int => bit => int) (Int.Pls \<Colon> int) (bit.B1::bit))
    7.26             (bit.B0::bit)))
    7.27         ((number_of \<Colon> int => nat)
    7.28           ((op BIT \<Colon> int => bit => int)
    7.29 -           ((op BIT \<Colon> int => bit => int) (Numeral.Pls \<Colon> int) (bit.B1::bit))
    7.30 +           ((op BIT \<Colon> int => bit => int) (Int.Pls \<Colon> int) (bit.B1::bit))
    7.31             (bit.B0::bit))))
    7.32       (1::nat)))"
    7.33    by (import prob_extra DIV_TWO_BASIC)
    7.34 @@ -77,17 +77,17 @@
    7.35          ((op ^::nat => nat => nat)
    7.36            ((number_of \<Colon> int => nat)
    7.37              ((op BIT \<Colon> int => bit => int)
    7.38 -              ((op BIT \<Colon> int => bit => int) (Numeral.Pls \<Colon> int) (bit.B1::bit))
    7.39 +              ((op BIT \<Colon> int => bit => int) (Int.Pls \<Colon> int) (bit.B1::bit))
    7.40                (bit.B0::bit)))
    7.41            ((Suc::nat => nat) n))
    7.42          ((number_of \<Colon> int => nat)
    7.43            ((op BIT \<Colon> int => bit => int)
    7.44 -            ((op BIT \<Colon> int => bit => int) (Numeral.Pls \<Colon> int) (bit.B1::bit))
    7.45 +            ((op BIT \<Colon> int => bit => int) (Int.Pls \<Colon> int) (bit.B1::bit))
    7.46              (bit.B0::bit))))
    7.47        ((op ^::nat => nat => nat)
    7.48          ((number_of \<Colon> int => nat)
    7.49            ((op BIT \<Colon> int => bit => int)
    7.50 -            ((op BIT \<Colon> int => bit => int) (Numeral.Pls \<Colon> int) (bit.B1::bit))
    7.51 +            ((op BIT \<Colon> int => bit => int) (Int.Pls \<Colon> int) (bit.B1::bit))
    7.52              (bit.B0::bit)))
    7.53          n))"
    7.54    by (import prob_extra EXP_DIV_TWO)
    7.55 @@ -127,7 +127,7 @@
    7.56   ((op /::real => real => real) (1::real)
    7.57     ((number_of \<Colon> int => real)
    7.58       ((op BIT \<Colon> int => bit => int)
    7.59 -       ((op BIT \<Colon> int => bit => int) (Numeral.Pls \<Colon> int) (bit.B1::bit))
    7.60 +       ((op BIT \<Colon> int => bit => int) (Int.Pls \<Colon> int) (bit.B1::bit))
    7.61         (bit.B0::bit))))"
    7.62    by (import prob_extra HALF_POS)
    7.63  
    7.64 @@ -135,12 +135,12 @@
    7.65   ((op *::real => real => real)
    7.66     ((number_of \<Colon> int => real)
    7.67       ((op BIT \<Colon> int => bit => int)
    7.68 -       ((op BIT \<Colon> int => bit => int) (Numeral.Pls \<Colon> int) (bit.B1::bit))
    7.69 +       ((op BIT \<Colon> int => bit => int) (Int.Pls \<Colon> int) (bit.B1::bit))
    7.70         (bit.B0::bit)))
    7.71     ((op /::real => real => real) (1::real)
    7.72       ((number_of \<Colon> int => real)
    7.73         ((op BIT \<Colon> int => bit => int)
    7.74 -         ((op BIT \<Colon> int => bit => int) (Numeral.Pls \<Colon> int) (bit.B1::bit))
    7.75 +         ((op BIT \<Colon> int => bit => int) (Int.Pls \<Colon> int) (bit.B1::bit))
    7.76           (bit.B0::bit)))))
    7.77   (1::real)"
    7.78    by (import prob_extra HALF_CANCEL)
    7.79 @@ -152,7 +152,7 @@
    7.80          ((op /::real => real => real) (1::real)
    7.81            ((number_of \<Colon> int => real)
    7.82              ((op BIT \<Colon> int => bit => int)
    7.83 -              ((op BIT \<Colon> int => bit => int) (Numeral.Pls \<Colon> int) (bit.B1::bit))
    7.84 +              ((op BIT \<Colon> int => bit => int) (Int.Pls \<Colon> int) (bit.B1::bit))
    7.85                (bit.B0::bit))))
    7.86          n))"
    7.87    by (import prob_extra POW_HALF_POS)
    7.88 @@ -167,7 +167,7 @@
    7.89                 ((op /::real => real => real) (1::real)
    7.90                   ((number_of \<Colon> int => real)
    7.91                     ((op BIT \<Colon> int => bit => int)
    7.92 -                     ((op BIT \<Colon> int => bit => int) (Numeral.Pls \<Colon> int)
    7.93 +                     ((op BIT \<Colon> int => bit => int) (Int.Pls \<Colon> int)
    7.94                         (bit.B1::bit))
    7.95                       (bit.B0::bit))))
    7.96                 n)
    7.97 @@ -175,7 +175,7 @@
    7.98                 ((op /::real => real => real) (1::real)
    7.99                   ((number_of \<Colon> int => real)
   7.100                     ((op BIT \<Colon> int => bit => int)
   7.101 -                     ((op BIT \<Colon> int => bit => int) (Numeral.Pls \<Colon> int)
   7.102 +                     ((op BIT \<Colon> int => bit => int) (Int.Pls \<Colon> int)
   7.103                         (bit.B1::bit))
   7.104                       (bit.B0::bit))))
   7.105                 m))))"
   7.106 @@ -188,19 +188,19 @@
   7.107          ((op /::real => real => real) (1::real)
   7.108            ((number_of \<Colon> int => real)
   7.109              ((op BIT \<Colon> int => bit => int)
   7.110 -              ((op BIT \<Colon> int => bit => int) (Numeral.Pls \<Colon> int) (bit.B1::bit))
   7.111 +              ((op BIT \<Colon> int => bit => int) (Int.Pls \<Colon> int) (bit.B1::bit))
   7.112                (bit.B0::bit))))
   7.113          n)
   7.114        ((op *::real => real => real)
   7.115          ((number_of \<Colon> int => real)
   7.116            ((op BIT \<Colon> int => bit => int)
   7.117 -            ((op BIT \<Colon> int => bit => int) (Numeral.Pls \<Colon> int) (bit.B1::bit))
   7.118 +            ((op BIT \<Colon> int => bit => int) (Int.Pls \<Colon> int) (bit.B1::bit))
   7.119              (bit.B0::bit)))
   7.120          ((op ^::real => nat => real)
   7.121            ((op /::real => real => real) (1::real)
   7.122              ((number_of \<Colon> int => real)
   7.123                ((op BIT \<Colon> int => bit => int)
   7.124 -                ((op BIT \<Colon> int => bit => int) (Numeral.Pls \<Colon> int)
   7.125 +                ((op BIT \<Colon> int => bit => int) (Int.Pls \<Colon> int)
   7.126                    (bit.B1::bit))
   7.127                  (bit.B0::bit))))
   7.128            ((Suc::nat => nat) n))))"
   7.129 @@ -229,12 +229,12 @@
   7.130     ((op /::real => real => real) (1::real)
   7.131       ((number_of \<Colon> int => real)
   7.132         ((op BIT \<Colon> int => bit => int)
   7.133 -         ((op BIT \<Colon> int => bit => int) (Numeral.Pls \<Colon> int) (bit.B1::bit))
   7.134 +         ((op BIT \<Colon> int => bit => int) (Int.Pls \<Colon> int) (bit.B1::bit))
   7.135           (bit.B0::bit)))))
   7.136   ((op /::real => real => real) (1::real)
   7.137     ((number_of \<Colon> int => real)
   7.138       ((op BIT \<Colon> int => bit => int)
   7.139 -       ((op BIT \<Colon> int => bit => int) (Numeral.Pls \<Colon> int) (bit.B1::bit))
   7.140 +       ((op BIT \<Colon> int => bit => int) (Int.Pls \<Colon> int) (bit.B1::bit))
   7.141         (bit.B0::bit))))"
   7.142    by (import prob_extra ONE_MINUS_HALF)
   7.143  
   7.144 @@ -242,7 +242,7 @@
   7.145   ((op /::real => real => real) (1::real)
   7.146     ((number_of \<Colon> int => real)
   7.147       ((op BIT \<Colon> int => bit => int)
   7.148 -       ((op BIT \<Colon> int => bit => int) (Numeral.Pls \<Colon> int) (bit.B1::bit))
   7.149 +       ((op BIT \<Colon> int => bit => int) (Int.Pls \<Colon> int) (bit.B1::bit))
   7.150         (bit.B0::bit))))
   7.151   (1::real)"
   7.152    by (import prob_extra HALF_LT_1)
   7.153 @@ -254,7 +254,7 @@
   7.154          ((op /::real => real => real) (1::real)
   7.155            ((number_of \<Colon> int => real)
   7.156              ((op BIT \<Colon> int => bit => int)
   7.157 -              ((op BIT \<Colon> int => bit => int) (Numeral.Pls \<Colon> int) (bit.B1::bit))
   7.158 +              ((op BIT \<Colon> int => bit => int) (Int.Pls \<Colon> int) (bit.B1::bit))
   7.159                (bit.B0::bit))))
   7.160          n)
   7.161        ((inverse::real => real)
   7.162 @@ -262,7 +262,7 @@
   7.163            ((op ^::nat => nat => nat)
   7.164              ((number_of \<Colon> int => nat)
   7.165                ((op BIT \<Colon> int => bit => int)
   7.166 -                ((op BIT \<Colon> int => bit => int) (Numeral.Pls \<Colon> int)
   7.167 +                ((op BIT \<Colon> int => bit => int) (Int.Pls \<Colon> int)
   7.168                    (bit.B1::bit))
   7.169                  (bit.B0::bit)))
   7.170              n))))"
   7.171 @@ -1407,7 +1407,7 @@
   7.172            ((op /::real => real => real) (1::real)
   7.173              ((number_of \<Colon> int => real)
   7.174                ((op BIT \<Colon> int => bit => int)
   7.175 -                ((op BIT \<Colon> int => bit => int) (Numeral.Pls \<Colon> int)
   7.176 +                ((op BIT \<Colon> int => bit => int) (Int.Pls \<Colon> int)
   7.177                    (bit.B1::bit))
   7.178                  (bit.B0::bit))))
   7.179            ((size::bool list => nat)
   7.180 @@ -1416,7 +1416,7 @@
   7.181            ((op /::real => real => real) (1::real)
   7.182              ((number_of \<Colon> int => real)
   7.183                ((op BIT \<Colon> int => bit => int)
   7.184 -                ((op BIT \<Colon> int => bit => int) (Numeral.Pls \<Colon> int)
   7.185 +                ((op BIT \<Colon> int => bit => int) (Int.Pls \<Colon> int)
   7.186                    (bit.B1::bit))
   7.187                  (bit.B0::bit))))
   7.188            ((size::bool list => nat)
   7.189 @@ -1425,7 +1425,7 @@
   7.190          ((op /::real => real => real) (1::real)
   7.191            ((number_of \<Colon> int => real)
   7.192              ((op BIT \<Colon> int => bit => int)
   7.193 -              ((op BIT \<Colon> int => bit => int) (Numeral.Pls \<Colon> int) (bit.B1::bit))
   7.194 +              ((op BIT \<Colon> int => bit => int) (Int.Pls \<Colon> int) (bit.B1::bit))
   7.195                (bit.B0::bit))))
   7.196          ((size::bool list => nat) l)))"
   7.197    by (import prob ALG_TWINS_MEASURE)
     8.1 --- a/src/HOL/Import/HOL/HOL4Real.thy	Tue Jan 15 16:19:21 2008 +0100
     8.2 +++ b/src/HOL/Import/HOL/HOL4Real.thy	Tue Jan 15 16:19:23 2008 +0100
     8.3 @@ -527,7 +527,7 @@
     8.4          ((op ^::real => nat => real) x
     8.5            ((number_of \<Colon> int => nat)
     8.6              ((op BIT \<Colon> int => bit => int)
     8.7 -              ((op BIT \<Colon> int => bit => int) (Numeral.Pls \<Colon> int) (bit.B1::bit))
     8.8 +              ((op BIT \<Colon> int => bit => int) (Int.Pls \<Colon> int) (bit.B1::bit))
     8.9                (bit.B0::bit))))))"
    8.10    by (import real REAL_LE1_POW2)
    8.11  
    8.12 @@ -539,7 +539,7 @@
    8.13          ((op ^::real => nat => real) x
    8.14            ((number_of \<Colon> int => nat)
    8.15              ((op BIT \<Colon> int => bit => int)
    8.16 -              ((op BIT \<Colon> int => bit => int) (Numeral.Pls \<Colon> int) (bit.B1::bit))
    8.17 +              ((op BIT \<Colon> int => bit => int) (Int.Pls \<Colon> int) (bit.B1::bit))
    8.18                (bit.B0::bit))))))"
    8.19    by (import real REAL_LT1_POW2)
    8.20  
     9.1 --- a/src/HOL/Import/HOL/HOL4Vec.thy	Tue Jan 15 16:19:21 2008 +0100
     9.2 +++ b/src/HOL/Import/HOL/HOL4Vec.thy	Tue Jan 15 16:19:23 2008 +0100
     9.3 @@ -1284,7 +1284,7 @@
     9.4        ((op <::nat => nat => bool) x
     9.5          ((number_of \<Colon> int => nat)
     9.6            ((op BIT \<Colon> int => bit => int)
     9.7 -            ((op BIT \<Colon> int => bit => int) (Numeral.Pls \<Colon> int) (bit.B1::bit))
     9.8 +            ((op BIT \<Colon> int => bit => int) (Int.Pls \<Colon> int) (bit.B1::bit))
     9.9              (bit.B0::bit))))
    9.10        ((op =::nat => nat => bool) ((BV::bool => nat) ((VB::nat => bool) x))
    9.11          x))"
    9.12 @@ -1502,7 +1502,7 @@
    9.13                             ((number_of \<Colon> int => nat)
    9.14                               ((op BIT \<Colon> int => bit => int)
    9.15                                 ((op BIT \<Colon> int => bit => int)
    9.16 -                                 (Numeral.Pls \<Colon> int) (bit.B1::bit))
    9.17 +                                 (Int.Pls \<Colon> int) (bit.B1::bit))
    9.18                                 (bit.B0::bit)))
    9.19                             k)))))))"
    9.20    by (import bword_arith ACARRY_EQ_ADD_DIV)
    10.1 --- a/src/HOL/Import/HOL/HOL4Word32.thy	Tue Jan 15 16:19:21 2008 +0100
    10.2 +++ b/src/HOL/Import/HOL/HOL4Word32.thy	Tue Jan 15 16:19:23 2008 +0100
    10.3 @@ -118,7 +118,7 @@
    10.4        ((op ^::nat => nat => nat)
    10.5          ((number_of \<Colon> int => nat)
    10.6            ((op BIT \<Colon> int => bit => int)
    10.7 -            ((op BIT \<Colon> int => bit => int) (Numeral.Pls \<Colon> int) (bit.B1::bit))
    10.8 +            ((op BIT \<Colon> int => bit => int) (Int.Pls \<Colon> int) (bit.B1::bit))
    10.9              (bit.B0::bit)))
   10.10          n))"
   10.11    by (import bits ZERO_LT_TWOEXP)
   10.12 @@ -138,14 +138,14 @@
   10.13               ((op ^::nat => nat => nat)
   10.14                 ((number_of \<Colon> int => nat)
   10.15                   ((op BIT \<Colon> int => bit => int)
   10.16 -                   ((op BIT \<Colon> int => bit => int) (Numeral.Pls \<Colon> int)
   10.17 +                   ((op BIT \<Colon> int => bit => int) (Int.Pls \<Colon> int)
   10.18                       (bit.B1::bit))
   10.19                     (bit.B0::bit)))
   10.20                 a)
   10.21               ((op ^::nat => nat => nat)
   10.22                 ((number_of \<Colon> int => nat)
   10.23                   ((op BIT \<Colon> int => bit => int)
   10.24 -                   ((op BIT \<Colon> int => bit => int) (Numeral.Pls \<Colon> int)
   10.25 +                   ((op BIT \<Colon> int => bit => int) (Int.Pls \<Colon> int)
   10.26                       (bit.B1::bit))
   10.27                     (bit.B0::bit)))
   10.28                 b))))"
   10.29 @@ -160,14 +160,14 @@
   10.30               ((op ^::nat => nat => nat)
   10.31                 ((number_of \<Colon> int => nat)
   10.32                   ((op BIT \<Colon> int => bit => int)
   10.33 -                   ((op BIT \<Colon> int => bit => int) (Numeral.Pls \<Colon> int)
   10.34 +                   ((op BIT \<Colon> int => bit => int) (Int.Pls \<Colon> int)
   10.35                       (bit.B1::bit))
   10.36                     (bit.B0::bit)))
   10.37                 a)
   10.38               ((op ^::nat => nat => nat)
   10.39                 ((number_of \<Colon> int => nat)
   10.40                   ((op BIT \<Colon> int => bit => int)
   10.41 -                   ((op BIT \<Colon> int => bit => int) (Numeral.Pls \<Colon> int)
   10.42 +                   ((op BIT \<Colon> int => bit => int) (Int.Pls \<Colon> int)
   10.43                       (bit.B1::bit))
   10.44                     (bit.B0::bit)))
   10.45                 b))))"
   10.46 @@ -181,14 +181,14 @@
   10.47             ((op ^::nat => nat => nat)
   10.48               ((number_of \<Colon> int => nat)
   10.49                 ((op BIT \<Colon> int => bit => int)
   10.50 -                 ((op BIT \<Colon> int => bit => int) (Numeral.Pls \<Colon> int)
   10.51 +                 ((op BIT \<Colon> int => bit => int) (Int.Pls \<Colon> int)
   10.52                     (bit.B1::bit))
   10.53                   (bit.B0::bit)))
   10.54               ((op -::nat => nat => nat) a b))
   10.55             ((op ^::nat => nat => nat)
   10.56               ((number_of \<Colon> int => nat)
   10.57                 ((op BIT \<Colon> int => bit => int)
   10.58 -                 ((op BIT \<Colon> int => bit => int) (Numeral.Pls \<Colon> int)
   10.59 +                 ((op BIT \<Colon> int => bit => int) (Int.Pls \<Colon> int)
   10.60                     (bit.B1::bit))
   10.61                   (bit.B0::bit)))
   10.62               a)))"
   10.63 @@ -350,7 +350,7 @@
   10.64                    ((op ^::nat => nat => nat)
   10.65                      ((number_of \<Colon> int => nat)
   10.66                        ((op BIT \<Colon> int => bit => int)
   10.67 -                        ((op BIT \<Colon> int => bit => int) (Numeral.Pls \<Colon> int)
   10.68 +                        ((op BIT \<Colon> int => bit => int) (Int.Pls \<Colon> int)
   10.69                            (bit.B1::bit))
   10.70                          (bit.B0::bit)))
   10.71                      b)
   10.72 @@ -358,14 +358,14 @@
   10.73                      ((op ^::nat => nat => nat)
   10.74                        ((number_of \<Colon> int => nat)
   10.75                          ((op BIT \<Colon> int => bit => int)
   10.76 -                          ((op BIT \<Colon> int => bit => int) (Numeral.Pls \<Colon> int)
   10.77 +                          ((op BIT \<Colon> int => bit => int) (Int.Pls \<Colon> int)
   10.78                              (bit.B1::bit))
   10.79                            (bit.B0::bit)))
   10.80                        ((op +::nat => nat => nat) x (1::nat)))
   10.81                      ((op ^::nat => nat => nat)
   10.82                        ((number_of \<Colon> int => nat)
   10.83                          ((op BIT \<Colon> int => bit => int)
   10.84 -                          ((op BIT \<Colon> int => bit => int) (Numeral.Pls \<Colon> int)
   10.85 +                          ((op BIT \<Colon> int => bit => int) (Int.Pls \<Colon> int)
   10.86                              (bit.B1::bit))
   10.87                            (bit.B0::bit)))
   10.88                        a))))))"
    11.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2 +++ b/src/HOL/Int.thy	Tue Jan 15 16:19:23 2008 +0100
    11.3 @@ -0,0 +1,1897 @@
    11.4 +(*  Title:      Int.thy
    11.5 +    ID:         $Id$
    11.6 +    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
    11.7 +                Tobias Nipkow, Florian Haftmann, TU Muenchen
    11.8 +    Copyright   1994  University of Cambridge
    11.9 +
   11.10 +*)
   11.11 +
   11.12 +header {* The Integers as Equivalence Classes over Pairs of Natural Numbers *} 
   11.13 +
   11.14 +theory Int
   11.15 +imports Equiv_Relations Wellfounded_Relations Datatype Nat
   11.16 +uses
   11.17 +  ("Tools/numeral.ML")
   11.18 +  ("Tools/numeral_syntax.ML")
   11.19 +  ("~~/src/Provers/Arith/assoc_fold.ML")
   11.20 +  "~~/src/Provers/Arith/cancel_numerals.ML"
   11.21 +  "~~/src/Provers/Arith/combine_numerals.ML"
   11.22 +  ("int_arith1.ML")
   11.23 +begin
   11.24 +
   11.25 +subsection {* The equivalence relation underlying the integers *}
   11.26 +
   11.27 +definition
   11.28 +  intrel :: "((nat \<times> nat) \<times> (nat \<times> nat)) set"
   11.29 +where
   11.30 +  "intrel = {((x, y), (u, v)) | x y u v. x + v = u +y }"
   11.31 +
   11.32 +typedef (Integ)
   11.33 +  int = "UNIV//intrel"
   11.34 +  by (auto simp add: quotient_def)
   11.35 +
   11.36 +instantiation int :: "{zero, one, plus, minus, uminus, times, ord, abs, sgn}"
   11.37 +begin
   11.38 +
   11.39 +definition
   11.40 +  Zero_int_def [code func del]: "0 = Abs_Integ (intrel `` {(0, 0)})"
   11.41 +
   11.42 +definition
   11.43 +  One_int_def [code func del]: "1 = Abs_Integ (intrel `` {(1, 0)})"
   11.44 +
   11.45 +definition
   11.46 +  add_int_def [code func del]: "z + w = Abs_Integ
   11.47 +    (\<Union>(x, y) \<in> Rep_Integ z. \<Union>(u, v) \<in> Rep_Integ w.
   11.48 +      intrel `` {(x + u, y + v)})"
   11.49 +
   11.50 +definition
   11.51 +  minus_int_def [code func del]:
   11.52 +    "- z = Abs_Integ (\<Union>(x, y) \<in> Rep_Integ z. intrel `` {(y, x)})"
   11.53 +
   11.54 +definition
   11.55 +  diff_int_def [code func del]:  "z - w = z + (-w \<Colon> int)"
   11.56 +
   11.57 +definition
   11.58 +  mult_int_def [code func del]: "z * w = Abs_Integ
   11.59 +    (\<Union>(x, y) \<in> Rep_Integ z. \<Union>(u,v ) \<in> Rep_Integ w.
   11.60 +      intrel `` {(x*u + y*v, x*v + y*u)})"
   11.61 +
   11.62 +definition
   11.63 +  le_int_def [code func del]:
   11.64 +   "z \<le> w \<longleftrightarrow> (\<exists>x y u v. x+v \<le> u+y \<and> (x, y) \<in> Rep_Integ z \<and> (u, v) \<in> Rep_Integ w)"
   11.65 +
   11.66 +definition
   11.67 +  less_int_def [code func del]: "(z\<Colon>int) < w \<longleftrightarrow> z \<le> w \<and> z \<noteq> w"
   11.68 +
   11.69 +definition
   11.70 +  zabs_def: "\<bar>i\<Colon>int\<bar> = (if i < 0 then - i else i)"
   11.71 +
   11.72 +definition
   11.73 +  zsgn_def: "sgn (i\<Colon>int) = (if i=0 then 0 else if 0<i then 1 else - 1)"
   11.74 +
   11.75 +instance ..
   11.76 +
   11.77 +end
   11.78 +
   11.79 +
   11.80 +subsection{*Construction of the Integers*}
   11.81 +
   11.82 +lemma intrel_iff [simp]: "(((x,y),(u,v)) \<in> intrel) = (x+v = u+y)"
   11.83 +by (simp add: intrel_def)
   11.84 +
   11.85 +lemma equiv_intrel: "equiv UNIV intrel"
   11.86 +by (simp add: intrel_def equiv_def refl_def sym_def trans_def)
   11.87 +
   11.88 +text{*Reduces equality of equivalence classes to the @{term intrel} relation:
   11.89 +  @{term "(intrel `` {x} = intrel `` {y}) = ((x,y) \<in> intrel)"} *}
   11.90 +lemmas equiv_intrel_iff [simp] = eq_equiv_class_iff [OF equiv_intrel UNIV_I UNIV_I]
   11.91 +
   11.92 +text{*All equivalence classes belong to set of representatives*}
   11.93 +lemma [simp]: "intrel``{(x,y)} \<in> Integ"
   11.94 +by (auto simp add: Integ_def intrel_def quotient_def)
   11.95 +
   11.96 +text{*Reduces equality on abstractions to equality on representatives:
   11.97 +  @{prop "\<lbrakk>x \<in> Integ; y \<in> Integ\<rbrakk> \<Longrightarrow> (Abs_Integ x = Abs_Integ y) = (x=y)"} *}
   11.98 +declare Abs_Integ_inject [simp,noatp]  Abs_Integ_inverse [simp,noatp]
   11.99 +
  11.100 +text{*Case analysis on the representation of an integer as an equivalence
  11.101 +      class of pairs of naturals.*}
  11.102 +lemma eq_Abs_Integ [case_names Abs_Integ, cases type: int]:
  11.103 +     "(!!x y. z = Abs_Integ(intrel``{(x,y)}) ==> P) ==> P"
  11.104 +apply (rule Abs_Integ_cases [of z]) 
  11.105 +apply (auto simp add: Integ_def quotient_def) 
  11.106 +done
  11.107 +
  11.108 +
  11.109 +subsection {* Arithmetic Operations *}
  11.110 +
  11.111 +lemma minus: "- Abs_Integ(intrel``{(x,y)}) = Abs_Integ(intrel `` {(y,x)})"
  11.112 +proof -
  11.113 +  have "(\<lambda>(x,y). intrel``{(y,x)}) respects intrel"
  11.114 +    by (simp add: congruent_def) 
  11.115 +  thus ?thesis
  11.116 +    by (simp add: minus_int_def UN_equiv_class [OF equiv_intrel])
  11.117 +qed
  11.118 +
  11.119 +lemma add:
  11.120 +     "Abs_Integ (intrel``{(x,y)}) + Abs_Integ (intrel``{(u,v)}) =
  11.121 +      Abs_Integ (intrel``{(x+u, y+v)})"
  11.122 +proof -
  11.123 +  have "(\<lambda>z w. (\<lambda>(x,y). (\<lambda>(u,v). intrel `` {(x+u, y+v)}) w) z) 
  11.124 +        respects2 intrel"
  11.125 +    by (simp add: congruent2_def)
  11.126 +  thus ?thesis
  11.127 +    by (simp add: add_int_def UN_UN_split_split_eq
  11.128 +                  UN_equiv_class2 [OF equiv_intrel equiv_intrel])
  11.129 +qed
  11.130 +
  11.131 +text{*Congruence property for multiplication*}
  11.132 +lemma mult_congruent2:
  11.133 +     "(%p1 p2. (%(x,y). (%(u,v). intrel``{(x*u + y*v, x*v + y*u)}) p2) p1)
  11.134 +      respects2 intrel"
  11.135 +apply (rule equiv_intrel [THEN congruent2_commuteI])
  11.136 + apply (force simp add: mult_ac, clarify) 
  11.137 +apply (simp add: congruent_def mult_ac)  
  11.138 +apply (rename_tac u v w x y z)
  11.139 +apply (subgoal_tac "u*y + x*y = w*y + v*y  &  u*z + x*z = w*z + v*z")
  11.140 +apply (simp add: mult_ac)
  11.141 +apply (simp add: add_mult_distrib [symmetric])
  11.142 +done
  11.143 +
  11.144 +lemma mult:
  11.145 +     "Abs_Integ((intrel``{(x,y)})) * Abs_Integ((intrel``{(u,v)})) =
  11.146 +      Abs_Integ(intrel `` {(x*u + y*v, x*v + y*u)})"
  11.147 +by (simp add: mult_int_def UN_UN_split_split_eq mult_congruent2
  11.148 +              UN_equiv_class2 [OF equiv_intrel equiv_intrel])
  11.149 +
  11.150 +text{*The integers form a @{text comm_ring_1}*}
  11.151 +instance int :: comm_ring_1
  11.152 +proof
  11.153 +  fix i j k :: int
  11.154 +  show "(i + j) + k = i + (j + k)"
  11.155 +    by (cases i, cases j, cases k) (simp add: add add_assoc)
  11.156 +  show "i + j = j + i" 
  11.157 +    by (cases i, cases j) (simp add: add_ac add)
  11.158 +  show "0 + i = i"
  11.159 +    by (cases i) (simp add: Zero_int_def add)
  11.160 +  show "- i + i = 0"
  11.161 +    by (cases i) (simp add: Zero_int_def minus add)
  11.162 +  show "i - j = i + - j"
  11.163 +    by (simp add: diff_int_def)
  11.164 +  show "(i * j) * k = i * (j * k)"
  11.165 +    by (cases i, cases j, cases k) (simp add: mult ring_simps)
  11.166 +  show "i * j = j * i"
  11.167 +    by (cases i, cases j) (simp add: mult ring_simps)
  11.168 +  show "1 * i = i"
  11.169 +    by (cases i) (simp add: One_int_def mult)
  11.170 +  show "(i + j) * k = i * k + j * k"
  11.171 +    by (cases i, cases j, cases k) (simp add: add mult ring_simps)
  11.172 +  show "0 \<noteq> (1::int)"
  11.173 +    by (simp add: Zero_int_def One_int_def)
  11.174 +qed
  11.175 +
  11.176 +lemma int_def: "of_nat m = Abs_Integ (intrel `` {(m, 0)})"
  11.177 +by (induct m, simp_all add: Zero_int_def One_int_def add)
  11.178 +
  11.179 +
  11.180 +subsection {* The @{text "\<le>"} Ordering *}
  11.181 +
  11.182 +lemma le:
  11.183 +  "(Abs_Integ(intrel``{(x,y)}) \<le> Abs_Integ(intrel``{(u,v)})) = (x+v \<le> u+y)"
  11.184 +by (force simp add: le_int_def)
  11.185 +
  11.186 +lemma less:
  11.187 +  "(Abs_Integ(intrel``{(x,y)}) < Abs_Integ(intrel``{(u,v)})) = (x+v < u+y)"
  11.188 +by (simp add: less_int_def le order_less_le)
  11.189 +
  11.190 +instance int :: linorder
  11.191 +proof
  11.192 +  fix i j k :: int
  11.193 +  show "(i < j) = (i \<le> j \<and> i \<noteq> j)"
  11.194 +    by (simp add: less_int_def)
  11.195 +  show "i \<le> i"
  11.196 +    by (cases i) (simp add: le)
  11.197 +  show "i \<le> j \<Longrightarrow> j \<le> k \<Longrightarrow> i \<le> k"
  11.198 +    by (cases i, cases j, cases k) (simp add: le)
  11.199 +  show "i \<le> j \<Longrightarrow> j \<le> i \<Longrightarrow> i = j"
  11.200 +    by (cases i, cases j) (simp add: le)
  11.201 +  show "i \<le> j \<or> j \<le> i"
  11.202 +    by (cases i, cases j) (simp add: le linorder_linear)
  11.203 +qed
  11.204 +
  11.205 +instantiation int :: distrib_lattice
  11.206 +begin
  11.207 +
  11.208 +definition
  11.209 +  "(inf \<Colon> int \<Rightarrow> int \<Rightarrow> int) = min"
  11.210 +
  11.211 +definition
  11.212 +  "(sup \<Colon> int \<Rightarrow> int \<Rightarrow> int) = max"
  11.213 +
  11.214 +instance
  11.215 +  by intro_classes
  11.216 +    (auto simp add: inf_int_def sup_int_def min_max.sup_inf_distrib1)
  11.217 +
  11.218 +end
  11.219 +
  11.220 +instance int :: pordered_cancel_ab_semigroup_add
  11.221 +proof
  11.222 +  fix i j k :: int
  11.223 +  show "i \<le> j \<Longrightarrow> k + i \<le> k + j"
  11.224 +    by (cases i, cases j, cases k) (simp add: le add)
  11.225 +qed
  11.226 +
  11.227 +text{*Strict Monotonicity of Multiplication*}
  11.228 +
  11.229 +text{*strict, in 1st argument; proof is by induction on k>0*}
  11.230 +lemma zmult_zless_mono2_lemma:
  11.231 +     "(i::int)<j ==> 0<k ==> of_nat k * i < of_nat k * j"
  11.232 +apply (induct "k", simp)
  11.233 +apply (simp add: left_distrib)
  11.234 +apply (case_tac "k=0")
  11.235 +apply (simp_all add: add_strict_mono)
  11.236 +done
  11.237 +
  11.238 +lemma zero_le_imp_eq_int: "(0::int) \<le> k ==> \<exists>n. k = of_nat n"
  11.239 +apply (cases k)
  11.240 +apply (auto simp add: le add int_def Zero_int_def)
  11.241 +apply (rule_tac x="x-y" in exI, simp)
  11.242 +done
  11.243 +
  11.244 +lemma zero_less_imp_eq_int: "(0::int) < k ==> \<exists>n>0. k = of_nat n"
  11.245 +apply (cases k)
  11.246 +apply (simp add: less int_def Zero_int_def)
  11.247 +apply (rule_tac x="x-y" in exI, simp)
  11.248 +done
  11.249 +
  11.250 +lemma zmult_zless_mono2: "[| i<j;  (0::int) < k |] ==> k*i < k*j"
  11.251 +apply (drule zero_less_imp_eq_int)
  11.252 +apply (auto simp add: zmult_zless_mono2_lemma)
  11.253 +done
  11.254 +
  11.255 +text{*The integers form an ordered integral domain*}
  11.256 +instance int :: ordered_idom
  11.257 +proof
  11.258 +  fix i j k :: int
  11.259 +  show "i < j \<Longrightarrow> 0 < k \<Longrightarrow> k * i < k * j"
  11.260 +    by (rule zmult_zless_mono2)
  11.261 +  show "\<bar>i\<bar> = (if i < 0 then -i else i)"
  11.262 +    by (simp only: zabs_def)
  11.263 +  show "sgn (i\<Colon>int) = (if i=0 then 0 else if 0<i then 1 else - 1)"
  11.264 +    by (simp only: zsgn_def)
  11.265 +qed
  11.266 +
  11.267 +lemma zless_imp_add1_zle: "w < z \<Longrightarrow> w + (1\<Colon>int) \<le> z"
  11.268 +apply (cases w, cases z) 
  11.269 +apply (simp add: less le add One_int_def)
  11.270 +done
  11.271 +
  11.272 +lemma zless_iff_Suc_zadd:
  11.273 +  "(w \<Colon> int) < z \<longleftrightarrow> (\<exists>n. z = w + of_nat (Suc n))"
  11.274 +apply (cases z, cases w)
  11.275 +apply (auto simp add: less add int_def)
  11.276 +apply (rename_tac a b c d) 
  11.277 +apply (rule_tac x="a+d - Suc(c+b)" in exI) 
  11.278 +apply arith
  11.279 +done
  11.280 +
  11.281 +lemmas int_distrib =
  11.282 +  left_distrib [of "z1::int" "z2" "w", standard]
  11.283 +  right_distrib [of "w::int" "z1" "z2", standard]
  11.284 +  left_diff_distrib [of "z1::int" "z2" "w", standard]
  11.285 +  right_diff_distrib [of "w::int" "z1" "z2", standard]
  11.286 +
  11.287 +
  11.288 +subsection {* Embedding of the Integers into any @{text ring_1}: @{text of_int}*}
  11.289 +
  11.290 +context ring_1
  11.291 +begin
  11.292 +
  11.293 +definition
  11.294 +  of_int :: "int \<Rightarrow> 'a"
  11.295 +where
  11.296 +  [code func del]: "of_int z = contents (\<Union>(i, j) \<in> Rep_Integ z. { of_nat i - of_nat j })"
  11.297 +
  11.298 +lemma of_int: "of_int (Abs_Integ (intrel `` {(i,j)})) = of_nat i - of_nat j"
  11.299 +proof -
  11.300 +  have "(\<lambda>(i,j). { of_nat i - (of_nat j :: 'a) }) respects intrel"
  11.301 +    by (simp add: congruent_def compare_rls of_nat_add [symmetric]
  11.302 +            del: of_nat_add) 
  11.303 +  thus ?thesis
  11.304 +    by (simp add: of_int_def UN_equiv_class [OF equiv_intrel])
  11.305 +qed
  11.306 +
  11.307 +lemma of_int_0 [simp]: "of_int 0 = 0"
  11.308 +  by (simp add: of_int Zero_int_def)
  11.309 +
  11.310 +lemma of_int_1 [simp]: "of_int 1 = 1"
  11.311 +  by (simp add: of_int One_int_def)
  11.312 +
  11.313 +lemma of_int_add [simp]: "of_int (w+z) = of_int w + of_int z"
  11.314 +  by (cases w, cases z, simp add: compare_rls of_int OrderedGroup.compare_rls add)
  11.315 +
  11.316 +lemma of_int_minus [simp]: "of_int (-z) = - (of_int z)"
  11.317 +  by (cases z, simp add: compare_rls of_int minus)
  11.318 +
  11.319 +lemma of_int_diff [simp]: "of_int (w - z) = of_int w - of_int z"
  11.320 +  by (simp add: OrderedGroup.diff_minus diff_minus)
  11.321 +
  11.322 +lemma of_int_mult [simp]: "of_int (w*z) = of_int w * of_int z"
  11.323 +apply (cases w, cases z)
  11.324 +apply (simp add: compare_rls of_int left_diff_distrib right_diff_distrib
  11.325 +                 mult add_ac of_nat_mult)
  11.326 +done
  11.327 +
  11.328 +text{*Collapse nested embeddings*}
  11.329 +lemma of_int_of_nat_eq [simp]: "of_int (of_nat n) = of_nat n"
  11.330 +  by (induct n) auto
  11.331 +
  11.332 +end
  11.333 +
  11.334 +context ordered_idom
  11.335 +begin
  11.336 +
  11.337 +lemma of_int_le_iff [simp]:
  11.338 +  "of_int w \<le> of_int z \<longleftrightarrow> w \<le> z"
  11.339 +  by (cases w, cases z, simp add: of_int le minus compare_rls of_nat_add [symmetric] del: of_nat_add)
  11.340 +
  11.341 +text{*Special cases where either operand is zero*}
  11.342 +lemmas of_int_0_le_iff [simp] = of_int_le_iff [of 0, simplified]
  11.343 +lemmas of_int_le_0_iff [simp] = of_int_le_iff [of _ 0, simplified]
  11.344 +
  11.345 +lemma of_int_less_iff [simp]:
  11.346 +  "of_int w < of_int z \<longleftrightarrow> w < z"
  11.347 +  by (simp add: not_le [symmetric] linorder_not_le [symmetric])
  11.348 +
  11.349 +text{*Special cases where either operand is zero*}
  11.350 +lemmas of_int_0_less_iff [simp] = of_int_less_iff [of 0, simplified]
  11.351 +lemmas of_int_less_0_iff [simp] = of_int_less_iff [of _ 0, simplified]
  11.352 +
  11.353 +end
  11.354 +
  11.355 +text{*Class for unital rings with characteristic zero.
  11.356 + Includes non-ordered rings like the complex numbers.*}
  11.357 +class ring_char_0 = ring_1 + semiring_char_0
  11.358 +begin
  11.359 +
  11.360 +lemma of_int_eq_iff [simp]:
  11.361 +   "of_int w = of_int z \<longleftrightarrow> w = z"
  11.362 +apply (cases w, cases z, simp add: of_int)
  11.363 +apply (simp only: diff_eq_eq diff_add_eq eq_diff_eq)
  11.364 +apply (simp only: of_nat_add [symmetric] of_nat_eq_iff)
  11.365 +done
  11.366 +
  11.367 +text{*Special cases where either operand is zero*}
  11.368 +lemmas of_int_0_eq_iff [simp] = of_int_eq_iff [of 0, simplified]
  11.369 +lemmas of_int_eq_0_iff [simp] = of_int_eq_iff [of _ 0, simplified]
  11.370 +
  11.371 +end
  11.372 +
  11.373 +text{*Every @{text ordered_idom} has characteristic zero.*}
  11.374 +subclass (in ordered_idom) ring_char_0 by intro_locales
  11.375 +
  11.376 +lemma of_int_eq_id [simp]: "of_int = id"
  11.377 +proof
  11.378 +  fix z show "of_int z = id z"
  11.379 +    by (cases z) (simp add: of_int add minus int_def diff_minus)
  11.380 +qed
  11.381 +
  11.382 +
  11.383 +subsection {* Magnitude of an Integer, as a Natural Number: @{text nat} *}
  11.384 +
  11.385 +definition
  11.386 +  nat :: "int \<Rightarrow> nat"
  11.387 +where
  11.388 +  [code func del]: "nat z = contents (\<Union>(x, y) \<in> Rep_Integ z. {x-y})"
  11.389 +
  11.390 +lemma nat: "nat (Abs_Integ (intrel``{(x,y)})) = x-y"
  11.391 +proof -
  11.392 +  have "(\<lambda>(x,y). {x-y}) respects intrel"
  11.393 +    by (simp add: congruent_def) arith
  11.394 +  thus ?thesis
  11.395 +    by (simp add: nat_def UN_equiv_class [OF equiv_intrel])
  11.396 +qed
  11.397 +
  11.398 +lemma nat_int [simp]: "nat (of_nat n) = n"
  11.399 +by (simp add: nat int_def)
  11.400 +
  11.401 +lemma nat_zero [simp]: "nat 0 = 0"
  11.402 +by (simp add: Zero_int_def nat)
  11.403 +
  11.404 +lemma int_nat_eq [simp]: "of_nat (nat z) = (if 0 \<le> z then z else 0)"
  11.405 +by (cases z, simp add: nat le int_def Zero_int_def)
  11.406 +
  11.407 +corollary nat_0_le: "0 \<le> z ==> of_nat (nat z) = z"
  11.408 +by simp
  11.409 +
  11.410 +lemma nat_le_0 [simp]: "z \<le> 0 ==> nat z = 0"
  11.411 +by (cases z, simp add: nat le Zero_int_def)
  11.412 +
  11.413 +lemma nat_le_eq_zle: "0 < w | 0 \<le> z ==> (nat w \<le> nat z) = (w\<le>z)"
  11.414 +apply (cases w, cases z) 
  11.415 +apply (simp add: nat le linorder_not_le [symmetric] Zero_int_def, arith)
  11.416 +done
  11.417 +
  11.418 +text{*An alternative condition is @{term "0 \<le> w"} *}
  11.419 +corollary nat_mono_iff: "0 < z ==> (nat w < nat z) = (w < z)"
  11.420 +by (simp add: nat_le_eq_zle linorder_not_le [symmetric]) 
  11.421 +
  11.422 +corollary nat_less_eq_zless: "0 \<le> w ==> (nat w < nat z) = (w<z)"
  11.423 +by (simp add: nat_le_eq_zle linorder_not_le [symmetric]) 
  11.424 +
  11.425 +lemma zless_nat_conj [simp]: "(nat w < nat z) = (0 < z & w < z)"
  11.426 +apply (cases w, cases z) 
  11.427 +apply (simp add: nat le Zero_int_def linorder_not_le [symmetric], arith)
  11.428 +done
  11.429 +
  11.430 +lemma nonneg_eq_int:
  11.431 +  fixes z :: int
  11.432 +  assumes "0 \<le> z" and "\<And>m. z = of_nat m \<Longrightarrow> P"
  11.433 +  shows P
  11.434 +  using assms by (blast dest: nat_0_le sym)
  11.435 +
  11.436 +lemma nat_eq_iff: "(nat w = m) = (if 0 \<le> w then w = of_nat m else m=0)"
  11.437 +by (cases w, simp add: nat le int_def Zero_int_def, arith)
  11.438 +
  11.439 +corollary nat_eq_iff2: "(m = nat w) = (if 0 \<le> w then w = of_nat m else m=0)"
  11.440 +by (simp only: eq_commute [of m] nat_eq_iff)
  11.441 +
  11.442 +lemma nat_less_iff: "0 \<le> w ==> (nat w < m) = (w < of_nat m)"
  11.443 +apply (cases w)
  11.444 +apply (simp add: nat le int_def Zero_int_def linorder_not_le [symmetric], arith)
  11.445 +done
  11.446 +
  11.447 +lemma int_eq_iff: "(of_nat m = z) = (m = nat z & 0 \<le> z)"
  11.448 +by (auto simp add: nat_eq_iff2)
  11.449 +
  11.450 +lemma zero_less_nat_eq [simp]: "(0 < nat z) = (0 < z)"
  11.451 +by (insert zless_nat_conj [of 0], auto)
  11.452 +
  11.453 +lemma nat_add_distrib:
  11.454 +     "[| (0::int) \<le> z;  0 \<le> z' |] ==> nat (z+z') = nat z + nat z'"
  11.455 +by (cases z, cases z', simp add: nat add le Zero_int_def)
  11.456 +
  11.457 +lemma nat_diff_distrib:
  11.458 +     "[| (0::int) \<le> z';  z' \<le> z |] ==> nat (z-z') = nat z - nat z'"
  11.459 +by (cases z, cases z', 
  11.460 +    simp add: nat add minus diff_minus le Zero_int_def)
  11.461 +
  11.462 +lemma nat_zminus_int [simp]: "nat (- (of_nat n)) = 0"
  11.463 +by (simp add: int_def minus nat Zero_int_def) 
  11.464 +
  11.465 +lemma zless_nat_eq_int_zless: "(m < nat z) = (of_nat m < z)"
  11.466 +by (cases z, simp add: nat less int_def, arith)
  11.467 +
  11.468 +context ring_1
  11.469 +begin
  11.470 +
  11.471 +lemma of_nat_nat: "0 \<le> z \<Longrightarrow> of_nat (nat z) = of_int z"
  11.472 +  by (cases z rule: eq_Abs_Integ)
  11.473 +   (simp add: nat le of_int Zero_int_def of_nat_diff)
  11.474 +
  11.475 +end
  11.476 +
  11.477 +
  11.478 +subsection{*Lemmas about the Function @{term of_nat} and Orderings*}
  11.479 +
  11.480 +lemma negative_zless_0: "- (of_nat (Suc n)) < (0 \<Colon> int)"
  11.481 +by (simp add: order_less_le del: of_nat_Suc)
  11.482 +
  11.483 +lemma negative_zless [iff]: "- (of_nat (Suc n)) < (of_nat m \<Colon> int)"
  11.484 +by (rule negative_zless_0 [THEN order_less_le_trans], simp)
  11.485 +
  11.486 +lemma negative_zle_0: "- of_nat n \<le> (0 \<Colon> int)"
  11.487 +by (simp add: minus_le_iff)
  11.488 +
  11.489 +lemma negative_zle [iff]: "- of_nat n \<le> (of_nat m \<Colon> int)"
  11.490 +by (rule order_trans [OF negative_zle_0 of_nat_0_le_iff])
  11.491 +
  11.492 +lemma not_zle_0_negative [simp]: "~ (0 \<le> - (of_nat (Suc n) \<Colon> int))"
  11.493 +by (subst le_minus_iff, simp del: of_nat_Suc)
  11.494 +
  11.495 +lemma int_zle_neg: "((of_nat n \<Colon> int) \<le> - of_nat m) = (n = 0 & m = 0)"
  11.496 +by (simp add: int_def le minus Zero_int_def)
  11.497 +
  11.498 +lemma not_int_zless_negative [simp]: "~ ((of_nat n \<Colon> int) < - of_nat m)"
  11.499 +by (simp add: linorder_not_less)
  11.500 +
  11.501 +lemma negative_eq_positive [simp]: "((- of_nat n \<Colon> int) = of_nat m) = (n = 0 & m = 0)"
  11.502 +by (force simp add: order_eq_iff [of "- of_nat n"] int_zle_neg)
  11.503 +
  11.504 +lemma zle_iff_zadd: "(w\<Colon>int) \<le> z \<longleftrightarrow> (\<exists>n. z = w + of_nat n)"
  11.505 +proof -
  11.506 +  have "(w \<le> z) = (0 \<le> z - w)"
  11.507 +    by (simp only: le_diff_eq add_0_left)
  11.508 +  also have "\<dots> = (\<exists>n. z - w = of_nat n)"
  11.509 +    by (auto elim: zero_le_imp_eq_int)
  11.510 +  also have "\<dots> = (\<exists>n. z = w + of_nat n)"
  11.511 +    by (simp only: group_simps)
  11.512 +  finally show ?thesis .
  11.513 +qed
  11.514 +
  11.515 +lemma zadd_int_left: "of_nat m + (of_nat n + z) = of_nat (m + n) + (z\<Colon>int)"
  11.516 +by simp
  11.517 +
  11.518 +lemma int_Suc0_eq_1: "of_nat (Suc 0) = (1\<Colon>int)"
  11.519 +by simp
  11.520 +
  11.521 +text{*This version is proved for all ordered rings, not just integers!
  11.522 +      It is proved here because attribute @{text arith_split} is not available
  11.523 +      in theory @{text Ring_and_Field}.
  11.524 +      But is it really better than just rewriting with @{text abs_if}?*}
  11.525 +lemma abs_split [arith_split,noatp]:
  11.526 +     "P(abs(a::'a::ordered_idom)) = ((0 \<le> a --> P a) & (a < 0 --> P(-a)))"
  11.527 +by (force dest: order_less_le_trans simp add: abs_if linorder_not_less)
  11.528 +
  11.529 +lemma negD: "(x \<Colon> int) < 0 \<Longrightarrow> \<exists>n. x = - (of_nat (Suc n))"
  11.530 +apply (cases x)
  11.531 +apply (auto simp add: le minus Zero_int_def int_def order_less_le)
  11.532 +apply (rule_tac x="y - Suc x" in exI, arith)
  11.533 +done
  11.534 +
  11.535 +
  11.536 +subsection {* Cases and induction *}
  11.537 +
  11.538 +text{*Now we replace the case analysis rule by a more conventional one:
  11.539 +whether an integer is negative or not.*}
  11.540 +
  11.541 +theorem int_cases [cases type: int, case_names nonneg neg]:
  11.542 +  "[|!! n. (z \<Colon> int) = of_nat n ==> P;  !! n. z =  - (of_nat (Suc n)) ==> P |] ==> P"
  11.543 +apply (cases "z < 0", blast dest!: negD)
  11.544 +apply (simp add: linorder_not_less del: of_nat_Suc)
  11.545 +apply auto
  11.546 +apply (blast dest: nat_0_le [THEN sym])
  11.547 +done
  11.548 +
  11.549 +theorem int_induct [induct type: int, case_names nonneg neg]:
  11.550 +     "[|!! n. P (of_nat n \<Colon> int);  !!n. P (- (of_nat (Suc n))) |] ==> P z"
  11.551 +  by (cases z rule: int_cases) auto
  11.552 +
  11.553 +text{*Contributed by Brian Huffman*}
  11.554 +theorem int_diff_cases:
  11.555 +  obtains (diff) m n where "(z\<Colon>int) = of_nat m - of_nat n"
  11.556 +apply (cases z rule: eq_Abs_Integ)
  11.557 +apply (rule_tac m=x and n=y in diff)
  11.558 +apply (simp add: int_def diff_def minus add)
  11.559 +done
  11.560 +
  11.561 +
  11.562 +subsection {* Binary representation *}
  11.563 +
  11.564 +text {*
  11.565 +  This formalization defines binary arithmetic in terms of the integers
  11.566 +  rather than using a datatype. This avoids multiple representations (leading
  11.567 +  zeroes, etc.)  See @{text "ZF/Tools/twos-compl.ML"}, function @{text
  11.568 +  int_of_binary}, for the numerical interpretation.
  11.569 +
  11.570 +  The representation expects that @{text "(m mod 2)"} is 0 or 1,
  11.571 +  even if m is negative;
  11.572 +  For instance, @{text "-5 div 2 = -3"} and @{text "-5 mod 2 = 1"}; thus
  11.573 +  @{text "-5 = (-3)*2 + 1"}.
  11.574 +  
  11.575 +  This two's complement binary representation derives from the paper 
  11.576 +  "An Efficient Representation of Arithmetic for Term Rewriting" by
  11.577 +  Dave Cohen and Phil Watson, Rewriting Techniques and Applications,
  11.578 +  Springer LNCS 488 (240-251), 1991.
  11.579 +*}
  11.580 +
  11.581 +datatype bit = B0 | B1
  11.582 +
  11.583 +text{*
  11.584 +  Type @{typ bit} avoids the use of type @{typ bool}, which would make
  11.585 +  all of the rewrite rules higher-order.
  11.586 +*}
  11.587 +
  11.588 +definition
  11.589 +  Pls :: int where
  11.590 +  [code func del]: "Pls = 0"
  11.591 +
  11.592 +definition
  11.593 +  Min :: int where
  11.594 +  [code func del]: "Min = - 1"
  11.595 +
  11.596 +definition
  11.597 +  Bit :: "int \<Rightarrow> bit \<Rightarrow> int" (infixl "BIT" 90) where
  11.598 +  [code func del]: "k BIT b = (case b of B0 \<Rightarrow> 0 | B1 \<Rightarrow> 1) + k + k"
  11.599 +
  11.600 +class number = type + -- {* for numeric types: nat, int, real, \dots *}
  11.601 +  fixes number_of :: "int \<Rightarrow> 'a"
  11.602 +
  11.603 +use "Tools/numeral.ML"
  11.604 +
  11.605 +syntax
  11.606 +  "_Numeral" :: "num_const \<Rightarrow> 'a"    ("_")
  11.607 +
  11.608 +use "Tools/numeral_syntax.ML"
  11.609 +setup NumeralSyntax.setup
  11.610 +
  11.611 +abbreviation
  11.612 +  "Numeral0 \<equiv> number_of Pls"
  11.613 +
  11.614 +abbreviation
  11.615 +  "Numeral1 \<equiv> number_of (Pls BIT B1)"
  11.616 +
  11.617 +lemma Let_number_of [simp]: "Let (number_of v) f = f (number_of v)"
  11.618 +  -- {* Unfold all @{text let}s involving constants *}
  11.619 +  unfolding Let_def ..
  11.620 +
  11.621 +definition
  11.622 +  succ :: "int \<Rightarrow> int" where
  11.623 +  [code func del]: "succ k = k + 1"
  11.624 +
  11.625 +definition
  11.626 +  pred :: "int \<Rightarrow> int" where
  11.627 +  [code func del]: "pred k = k - 1"
  11.628 +
  11.629 +lemmas
  11.630 +  max_number_of [simp] = max_def
  11.631 +    [of "number_of u" "number_of v", standard, simp]
  11.632 +and
  11.633 +  min_number_of [simp] = min_def 
  11.634 +    [of "number_of u" "number_of v", standard, simp]
  11.635 +  -- {* unfolding @{text minx} and @{text max} on numerals *}
  11.636 +
  11.637 +lemmas numeral_simps = 
  11.638 +  succ_def pred_def Pls_def Min_def Bit_def
  11.639 +
  11.640 +text {* Removal of leading zeroes *}
  11.641 +
  11.642 +lemma Pls_0_eq [simp, code post]:
  11.643 +  "Pls BIT B0 = Pls"
  11.644 +  unfolding numeral_simps by simp
  11.645 +
  11.646 +lemma Min_1_eq [simp, code post]:
  11.647 +  "Min BIT B1 = Min"
  11.648 +  unfolding numeral_simps by simp
  11.649 +
  11.650 +
  11.651 +subsection {* The Functions @{term succ}, @{term pred} and @{term uminus} *}
  11.652 +
  11.653 +lemma succ_Pls [simp]:
  11.654 +  "succ Pls = Pls BIT B1"
  11.655 +  unfolding numeral_simps by simp
  11.656 +
  11.657 +lemma succ_Min [simp]:
  11.658 +  "succ Min = Pls"
  11.659 +  unfolding numeral_simps by simp
  11.660 +
  11.661 +lemma succ_1 [simp]:
  11.662 +  "succ (k BIT B1) = succ k BIT B0"
  11.663 +  unfolding numeral_simps by simp
  11.664 +
  11.665 +lemma succ_0 [simp]:
  11.666 +  "succ (k BIT B0) = k BIT B1"
  11.667 +  unfolding numeral_simps by simp
  11.668 +
  11.669 +lemma pred_Pls [simp]:
  11.670 +  "pred Pls = Min"
  11.671 +  unfolding numeral_simps by simp
  11.672 +
  11.673 +lemma pred_Min [simp]:
  11.674 +  "pred Min = Min BIT B0"
  11.675 +  unfolding numeral_simps by simp
  11.676 +
  11.677 +lemma pred_1 [simp]:
  11.678 +  "pred (k BIT B1) = k BIT B0"
  11.679 +  unfolding numeral_simps by simp
  11.680 +
  11.681 +lemma pred_0 [simp]:
  11.682 +  "pred (k BIT B0) = pred k BIT B1"
  11.683 +  unfolding numeral_simps by simp 
  11.684 +
  11.685 +lemma minus_Pls [simp]:
  11.686 +  "- Pls = Pls"
  11.687 +  unfolding numeral_simps by simp 
  11.688 +
  11.689 +lemma minus_Min [simp]:
  11.690 +  "- Min = Pls BIT B1"
  11.691 +  unfolding numeral_simps by simp 
  11.692 +
  11.693 +lemma minus_1 [simp]:
  11.694 +  "- (k BIT B1) = pred (- k) BIT B1"
  11.695 +  unfolding numeral_simps by simp 
  11.696 +
  11.697 +lemma minus_0 [simp]:
  11.698 +  "- (k BIT B0) = (- k) BIT B0"
  11.699 +  unfolding numeral_simps by simp 
  11.700 +
  11.701 +
  11.702 +subsection {*
  11.703 +  Binary Addition and Multiplication: @{term "op + \<Colon> int \<Rightarrow> int \<Rightarrow> int"}
  11.704 +    and @{term "op * \<Colon> int \<Rightarrow> int \<Rightarrow> int"}
  11.705 +*}
  11.706 +
  11.707 +lemma add_Pls [simp]:
  11.708 +  "Pls + k = k"
  11.709 +  unfolding numeral_simps by simp 
  11.710 +
  11.711 +lemma add_Min [simp]:
  11.712 +  "Min + k = pred k"
  11.713 +  unfolding numeral_simps by simp
  11.714 +
  11.715 +lemma add_BIT_11 [simp]:
  11.716 +  "(k BIT B1) + (l BIT B1) = (k + succ l) BIT B0"
  11.717 +  unfolding numeral_simps by simp
  11.718 +
  11.719 +lemma add_BIT_10 [simp]:
  11.720 +  "(k BIT B1) + (l BIT B0) = (k + l) BIT B1"
  11.721 +  unfolding numeral_simps by simp
  11.722 +
  11.723 +lemma add_BIT_0 [simp]:
  11.724 +  "(k BIT B0) + (l BIT b) = (k + l) BIT b"
  11.725 +  unfolding numeral_simps by simp 
  11.726 +
  11.727 +lemma add_Pls_right [simp]:
  11.728 +  "k + Pls = k"
  11.729 +  unfolding numeral_simps by simp 
  11.730 +
  11.731 +lemma add_Min_right [simp]:
  11.732 +  "k + Min = pred k"
  11.733 +  unfolding numeral_simps by simp 
  11.734 +
  11.735 +lemma mult_Pls [simp]:
  11.736 +  "Pls * w = Pls"
  11.737 +  unfolding numeral_simps by simp 
  11.738 +
  11.739 +lemma mult_Min [simp]:
  11.740 +  "Min * k = - k"
  11.741 +  unfolding numeral_simps by simp
  11.742 +
  11.743 +lemma mult_num1 [simp]:
  11.744 +  "(k BIT B1) * l = ((k * l) BIT B0) + l"
  11.745 +  unfolding numeral_simps int_distrib by simp 
  11.746 +
  11.747 +lemma mult_num0 [simp]:
  11.748 +  "(k BIT B0) * l = (k * l) BIT B0"
  11.749 +  unfolding numeral_simps int_distrib by simp 
  11.750 +
  11.751 +
  11.752 +subsection {* Converting Numerals to Rings: @{term number_of} *}
  11.753 +
  11.754 +class number_ring = number + comm_ring_1 +
  11.755 +  assumes number_of_eq: "number_of k = of_int k"
  11.756 +
  11.757 +text {* self-embedding of the integers *}
  11.758 +
  11.759 +instantiation int :: number_ring
  11.760 +begin
  11.761 +
  11.762 +definition
  11.763 +  int_number_of_def [code func del]: "number_of w = (of_int w \<Colon> int)"
  11.764 +
  11.765 +instance
  11.766 +  by intro_classes (simp only: int_number_of_def)
  11.767 +
  11.768 +end
  11.769 +
  11.770 +lemma number_of_is_id:
  11.771 +  "number_of (k::int) = k"
  11.772 +  unfolding int_number_of_def by simp
  11.773 +
  11.774 +lemma number_of_succ:
  11.775 +  "number_of (succ k) = (1 + number_of k ::'a::number_ring)"
  11.776 +  unfolding number_of_eq numeral_simps by simp
  11.777 +
  11.778 +lemma number_of_pred:
  11.779 +  "number_of (pred w) = (- 1 + number_of w ::'a::number_ring)"
  11.780 +  unfolding number_of_eq numeral_simps by simp
  11.781 +
  11.782 +lemma number_of_minus:
  11.783 +  "number_of (uminus w) = (- (number_of w)::'a::number_ring)"
  11.784 +  unfolding number_of_eq numeral_simps by simp
  11.785 +
  11.786 +lemma number_of_add:
  11.787 +  "number_of (v + w) = (number_of v + number_of w::'a::number_ring)"
  11.788 +  unfolding number_of_eq numeral_simps by simp
  11.789 +
  11.790 +lemma number_of_mult:
  11.791 +  "number_of (v * w) = (number_of v * number_of w::'a::number_ring)"
  11.792 +  unfolding number_of_eq numeral_simps by simp
  11.793 +
  11.794 +text {*
  11.795 +  The correctness of shifting.
  11.796 +  But it doesn't seem to give a measurable speed-up.
  11.797 +*}
  11.798 +
  11.799 +lemma double_number_of_BIT:
  11.800 +  "(1 + 1) * number_of w = (number_of (w BIT B0) ::'a::number_ring)"
  11.801 +  unfolding number_of_eq numeral_simps left_distrib by simp
  11.802 +
  11.803 +text {*
  11.804 +  Converting numerals 0 and 1 to their abstract versions.
  11.805 +*}
  11.806 +
  11.807 +lemma numeral_0_eq_0 [simp]:
  11.808 +  "Numeral0 = (0::'a::number_ring)"
  11.809 +  unfolding number_of_eq numeral_simps by simp
  11.810 +
  11.811 +lemma numeral_1_eq_1 [simp]:
  11.812 +  "Numeral1 = (1::'a::number_ring)"
  11.813 +  unfolding number_of_eq numeral_simps by simp
  11.814 +
  11.815 +text {*
  11.816 +  Special-case simplification for small constants.
  11.817 +*}
  11.818 +
  11.819 +text{*
  11.820 +  Unary minus for the abstract constant 1. Cannot be inserted
  11.821 +  as a simprule until later: it is @{text number_of_Min} re-oriented!
  11.822 +*}
  11.823 +
  11.824 +lemma numeral_m1_eq_minus_1:
  11.825 +  "(-1::'a::number_ring) = - 1"
  11.826 +  unfolding number_of_eq numeral_simps by simp
  11.827 +
  11.828 +lemma mult_minus1 [simp]:
  11.829 +  "-1 * z = -(z::'a::number_ring)"
  11.830 +  unfolding number_of_eq numeral_simps by simp
  11.831 +
  11.832 +lemma mult_minus1_right [simp]:
  11.833 +  "z * -1 = -(z::'a::number_ring)"
  11.834 +  unfolding number_of_eq numeral_simps by simp
  11.835 +
  11.836 +(*Negation of a coefficient*)
  11.837 +lemma minus_number_of_mult [simp]:
  11.838 +   "- (number_of w) * z = number_of (uminus w) * (z::'a::number_ring)"
  11.839 +   unfolding number_of_eq by simp
  11.840 +
  11.841 +text {* Subtraction *}
  11.842 +
  11.843 +lemma diff_number_of_eq:
  11.844 +  "number_of v - number_of w =
  11.845 +    (number_of (v + uminus w)::'a::number_ring)"
  11.846 +  unfolding number_of_eq by simp
  11.847 +
  11.848 +lemma number_of_Pls:
  11.849 +  "number_of Pls = (0::'a::number_ring)"
  11.850 +  unfolding number_of_eq numeral_simps by simp
  11.851 +
  11.852 +lemma number_of_Min:
  11.853 +  "number_of Min = (- 1::'a::number_ring)"
  11.854 +  unfolding number_of_eq numeral_simps by simp
  11.855 +
  11.856 +lemma number_of_BIT:
  11.857 +  "number_of(w BIT x) = (case x of B0 => 0 | B1 => (1::'a::number_ring))
  11.858 +    + (number_of w) + (number_of w)"
  11.859 +  unfolding number_of_eq numeral_simps by (simp split: bit.split)
  11.860 +
  11.861 +
  11.862 +subsection {* Equality of Binary Numbers *}
  11.863 +
  11.864 +text {* First version by Norbert Voelker *}
  11.865 +
  11.866 +definition
  11.867 +  neg  :: "'a\<Colon>ordered_idom \<Rightarrow> bool"
  11.868 +where
  11.869 +  "neg Z \<longleftrightarrow> Z < 0"
  11.870 +
  11.871 +definition (*for simplifying equalities*)
  11.872 +  iszero :: "'a\<Colon>semiring_1 \<Rightarrow> bool"
  11.873 +where
  11.874 +  "iszero z \<longleftrightarrow> z = 0"
  11.875 +
  11.876 +lemma not_neg_int [simp]: "~ neg (of_nat n)"
  11.877 +by (simp add: neg_def)
  11.878 +
  11.879 +lemma neg_zminus_int [simp]: "neg (- (of_nat (Suc n)))"
  11.880 +by (simp add: neg_def neg_less_0_iff_less del: of_nat_Suc)
  11.881 +
  11.882 +lemmas neg_eq_less_0 = neg_def
  11.883 +
  11.884 +lemma not_neg_eq_ge_0: "(~neg x) = (0 \<le> x)"
  11.885 +by (simp add: neg_def linorder_not_less)
  11.886 +
  11.887 +text{*To simplify inequalities when Numeral1 can get simplified to 1*}
  11.888 +
  11.889 +lemma not_neg_0: "~ neg 0"
  11.890 +by (simp add: One_int_def neg_def)
  11.891 +
  11.892 +lemma not_neg_1: "~ neg 1"
  11.893 +by (simp add: neg_def linorder_not_less zero_le_one)
  11.894 +
  11.895 +lemma iszero_0: "iszero 0"
  11.896 +by (simp add: iszero_def)
  11.897 +
  11.898 +lemma not_iszero_1: "~ iszero 1"
  11.899 +by (simp add: iszero_def eq_commute)
  11.900 +
  11.901 +lemma neg_nat: "neg z ==> nat z = 0"
  11.902 +by (simp add: neg_def order_less_imp_le) 
  11.903 +
  11.904 +lemma not_neg_nat: "~ neg z ==> of_nat (nat z) = z"
  11.905 +by (simp add: linorder_not_less neg_def)
  11.906 +
  11.907 +lemma eq_number_of_eq:
  11.908 +  "((number_of x::'a::number_ring) = number_of y) =
  11.909 +   iszero (number_of (x + uminus y) :: 'a)"
  11.910 +  unfolding iszero_def number_of_add number_of_minus
  11.911 +  by (simp add: compare_rls)
  11.912 +
  11.913 +lemma iszero_number_of_Pls:
  11.914 +  "iszero ((number_of Pls)::'a::number_ring)"
  11.915 +  unfolding iszero_def numeral_0_eq_0 ..
  11.916 +
  11.917 +lemma nonzero_number_of_Min:
  11.918 +  "~ iszero ((number_of Min)::'a::number_ring)"
  11.919 +  unfolding iszero_def numeral_m1_eq_minus_1 by simp
  11.920 +
  11.921 +
  11.922 +subsection {* Comparisons, for Ordered Rings *}
  11.923 +
  11.924 +lemmas double_eq_0_iff = double_zero
  11.925 +
  11.926 +lemma le_imp_0_less: 
  11.927 +  assumes le: "0 \<le> z"
  11.928 +  shows "(0::int) < 1 + z"
  11.929 +proof -
  11.930 +  have "0 \<le> z" by fact
  11.931 +  also have "... < z + 1" by (rule less_add_one) 
  11.932 +  also have "... = 1 + z" by (simp add: add_ac)
  11.933 +  finally show "0 < 1 + z" .
  11.934 +qed
  11.935 +
  11.936 +lemma odd_nonzero:
  11.937 +  "1 + z + z \<noteq> (0::int)";
  11.938 +proof (cases z rule: int_cases)
  11.939 +  case (nonneg n)
  11.940 +  have le: "0 \<le> z+z" by (simp add: nonneg add_increasing) 
  11.941 +  thus ?thesis using  le_imp_0_less [OF le]
  11.942 +    by (auto simp add: add_assoc) 
  11.943 +next
  11.944 +  case (neg n)
  11.945 +  show ?thesis
  11.946 +  proof
  11.947 +    assume eq: "1 + z + z = 0"
  11.948 +    have "(0::int) < 1 + (of_nat n + of_nat n)"
  11.949 +      by (simp add: le_imp_0_less add_increasing) 
  11.950 +    also have "... = - (1 + z + z)" 
  11.951 +      by (simp add: neg add_assoc [symmetric]) 
  11.952 +    also have "... = 0" by (simp add: eq) 
  11.953 +    finally have "0<0" ..
  11.954 +    thus False by blast
  11.955 +  qed
  11.956 +qed
  11.957 +
  11.958 +lemma iszero_number_of_BIT:
  11.959 +  "iszero (number_of (w BIT x)::'a) = 
  11.960 +   (x = B0 \<and> iszero (number_of w::'a::{ring_char_0,number_ring}))"
  11.961 +proof -
  11.962 +  have "(of_int w + of_int w = (0::'a)) \<Longrightarrow> (w = 0)"
  11.963 +  proof -
  11.964 +    assume eq: "of_int w + of_int w = (0::'a)"
  11.965 +    then have "of_int (w + w) = (of_int 0 :: 'a)" by simp
  11.966 +    then have "w + w = 0" by (simp only: of_int_eq_iff)
  11.967 +    then show "w = 0" by (simp only: double_eq_0_iff)
  11.968 +  qed
  11.969 +  moreover have "1 + of_int w + of_int w \<noteq> (0::'a)"
  11.970 +  proof
  11.971 +    assume eq: "1 + of_int w + of_int w = (0::'a)"
  11.972 +    hence "of_int (1 + w + w) = (of_int 0 :: 'a)" by simp 
  11.973 +    hence "1 + w + w = 0" by (simp only: of_int_eq_iff)
  11.974 +    with odd_nonzero show False by blast
  11.975 +  qed
  11.976 +  ultimately show ?thesis
  11.977 +    by (auto simp add: iszero_def number_of_eq numeral_simps 
  11.978 +     split: bit.split)
  11.979 +qed
  11.980 +
  11.981 +lemma iszero_number_of_0:
  11.982 +  "iszero (number_of (w BIT B0) :: 'a::{ring_char_0,number_ring}) = 
  11.983 +  iszero (number_of w :: 'a)"
  11.984 +  by (simp only: iszero_number_of_BIT simp_thms)
  11.985 +
  11.986 +lemma iszero_number_of_1:
  11.987 +  "~ iszero (number_of (w BIT B1)::'a::{ring_char_0,number_ring})"
  11.988 +  by (simp add: iszero_number_of_BIT) 
  11.989 +
  11.990 +
  11.991 +subsection {* The Less-Than Relation *}
  11.992 +
  11.993 +lemma less_number_of_eq_neg:
  11.994 +  "((number_of x::'a::{ordered_idom,number_ring}) < number_of y)
  11.995 +  = neg (number_of (x + uminus y) :: 'a)"
  11.996 +apply (subst less_iff_diff_less_0) 
  11.997 +apply (simp add: neg_def diff_minus number_of_add number_of_minus)
  11.998 +done
  11.999 +
 11.1000 +text {*
 11.1001 +  If @{term Numeral0} is rewritten to 0 then this rule can't be applied:
 11.1002 +  @{term Numeral0} IS @{term "number_of Pls"}
 11.1003 +*}
 11.1004 +
 11.1005 +lemma not_neg_number_of_Pls:
 11.1006 +  "~ neg (number_of Pls ::'a::{ordered_idom,number_ring})"
 11.1007 +  by (simp add: neg_def numeral_0_eq_0)
 11.1008 +
 11.1009 +lemma neg_number_of_Min:
 11.1010 +  "neg (number_of Min ::'a::{ordered_idom,number_ring})"
 11.1011 +  by (simp add: neg_def zero_less_one numeral_m1_eq_minus_1)
 11.1012 +
 11.1013 +lemma double_less_0_iff:
 11.1014 +  "(a + a < 0) = (a < (0::'a::ordered_idom))"
 11.1015 +proof -
 11.1016 +  have "(a + a < 0) = ((1+1)*a < 0)" by (simp add: left_distrib)
 11.1017 +  also have "... = (a < 0)"
 11.1018 +    by (simp add: mult_less_0_iff zero_less_two 
 11.1019 +                  order_less_not_sym [OF zero_less_two]) 
 11.1020 +  finally show ?thesis .
 11.1021 +qed
 11.1022 +
 11.1023 +lemma odd_less_0:
 11.1024 +  "(1 + z + z < 0) = (z < (0::int))";
 11.1025 +proof (cases z rule: int_cases)
 11.1026 +  case (nonneg n)
 11.1027 +  thus ?thesis by (simp add: linorder_not_less add_assoc add_increasing
 11.1028 +                             le_imp_0_less [THEN order_less_imp_le])  
 11.1029 +next
 11.1030 +  case (neg n)
 11.1031 +  thus ?thesis by (simp del: of_nat_Suc of_nat_add
 11.1032 +    add: compare_rls of_nat_1 [symmetric] of_nat_add [symmetric])
 11.1033 +qed
 11.1034 +
 11.1035 +lemma neg_number_of_BIT:
 11.1036 +  "neg (number_of (w BIT x)::'a) = 
 11.1037 +  neg (number_of w :: 'a::{ordered_idom,number_ring})"
 11.1038 +proof -
 11.1039 +  have "((1::'a) + of_int w + of_int w < 0) = (of_int (1 + w + w) < (of_int 0 :: 'a))"
 11.1040 +    by simp
 11.1041 +  also have "... = (w < 0)" by (simp only: of_int_less_iff odd_less_0)
 11.1042 +  finally show ?thesis
 11.1043 +  by ( simp add: neg_def number_of_eq numeral_simps double_less_0_iff
 11.1044 +    split: bit.split)
 11.1045 +qed
 11.1046 +
 11.1047 +
 11.1048 +text {* Less-Than or Equals *}
 11.1049 +
 11.1050 +text {* Reduces @{term "a\<le>b"} to @{term "~ (b<a)"} for ALL numerals. *}
 11.1051 +
 11.1052 +lemmas le_number_of_eq_not_less =
 11.1053 +  linorder_not_less [of "number_of w" "number_of v", symmetric, 
 11.1054 +  standard]
 11.1055 +
 11.1056 +lemma le_number_of_eq:
 11.1057 +    "((number_of x::'a::{ordered_idom,number_ring}) \<le> number_of y)
 11.1058 +     = (~ (neg (number_of (y + uminus x) :: 'a)))"
 11.1059 +by (simp add: le_number_of_eq_not_less less_number_of_eq_neg)
 11.1060 +
 11.1061 +
 11.1062 +text {* Absolute value (@{term abs}) *}
 11.1063 +
 11.1064 +lemma abs_number_of:
 11.1065 +  "abs(number_of x::'a::{ordered_idom,number_ring}) =
 11.1066 +   (if number_of x < (0::'a) then -number_of x else number_of x)"
 11.1067 +  by (simp add: abs_if)
 11.1068 +
 11.1069 +
 11.1070 +text {* Re-orientation of the equation nnn=x *}
 11.1071 +
 11.1072 +lemma number_of_reorient:
 11.1073 +  "(number_of w = x) = (x = number_of w)"
 11.1074 +  by auto
 11.1075 +
 11.1076 +
 11.1077 +subsection {* Simplification of arithmetic operations on integer constants. *}
 11.1078 +
 11.1079 +lemmas arith_extra_simps [standard, simp] =
 11.1080 +  number_of_add [symmetric]
 11.1081 +  number_of_minus [symmetric] numeral_m1_eq_minus_1 [symmetric]
 11.1082 +  number_of_mult [symmetric]
 11.1083 +  diff_number_of_eq abs_number_of 
 11.1084 +
 11.1085 +text {*
 11.1086 +  For making a minimal simpset, one must include these default simprules.
 11.1087 +  Also include @{text simp_thms}.
 11.1088 +*}
 11.1089 +
 11.1090 +lemmas arith_simps = 
 11.1091 +  bit.distinct
 11.1092 +  Pls_0_eq Min_1_eq
 11.1093 +  pred_Pls pred_Min pred_1 pred_0
 11.1094 +  succ_Pls succ_Min succ_1 succ_0
 11.1095 +  add_Pls add_Min add_BIT_0 add_BIT_10 add_BIT_11
 11.1096 +  minus_Pls minus_Min minus_1 minus_0
 11.1097 +  mult_Pls mult_Min mult_num1 mult_num0 
 11.1098 +  add_Pls_right add_Min_right
 11.1099 +  abs_zero abs_one arith_extra_simps
 11.1100 +
 11.1101 +text {* Simplification of relational operations *}
 11.1102 +
 11.1103 +lemmas rel_simps [simp] = 
 11.1104 +  eq_number_of_eq iszero_0 nonzero_number_of_Min
 11.1105 +  iszero_number_of_0 iszero_number_of_1
 11.1106 +  less_number_of_eq_neg
 11.1107 +  not_neg_number_of_Pls not_neg_0 not_neg_1 not_iszero_1
 11.1108 +  neg_number_of_Min neg_number_of_BIT
 11.1109 +  le_number_of_eq
 11.1110 +(* iszero_number_of_Pls would never be used
 11.1111 +   because its lhs simplifies to "iszero 0" *)
 11.1112 +
 11.1113 +
 11.1114 +subsection {* Simplification of arithmetic when nested to the right. *}
 11.1115 +
 11.1116 +lemma add_number_of_left [simp]:
 11.1117 +  "number_of v + (number_of w + z) =
 11.1118 +   (number_of(v + w) + z::'a::number_ring)"
 11.1119 +  by (simp add: add_assoc [symmetric])
 11.1120 +
 11.1121 +lemma mult_number_of_left [simp]:
 11.1122 +  "number_of v * (number_of w * z) =
 11.1123 +   (number_of(v * w) * z::'a::number_ring)"
 11.1124 +  by (simp add: mult_assoc [symmetric])
 11.1125 +
 11.1126 +lemma add_number_of_diff1:
 11.1127 +  "number_of v + (number_of w - c) = 
 11.1128 +  number_of(v + w) - (c::'a::number_ring)"
 11.1129 +  by (simp add: diff_minus add_number_of_left)
 11.1130 +
 11.1131 +lemma add_number_of_diff2 [simp]:
 11.1132 +  "number_of v + (c - number_of w) =
 11.1133 +   number_of (v + uminus w) + (c::'a::number_ring)"
 11.1134 +apply (subst diff_number_of_eq [symmetric])
 11.1135 +apply (simp only: compare_rls)
 11.1136 +done
 11.1137 +
 11.1138 +
 11.1139 +subsection {* The Set of Integers *}
 11.1140 +
 11.1141 +context ring_1
 11.1142 +begin
 11.1143 +
 11.1144 +definition
 11.1145 +  Ints  :: "'a set"
 11.1146 +where
 11.1147 +  "Ints = range of_int"
 11.1148 +
 11.1149 +end
 11.1150 +
 11.1151 +notation (xsymbols)
 11.1152 +  Ints  ("\<int>")
 11.1153 +
 11.1154 +context ring_1
 11.1155 +begin
 11.1156 +
 11.1157 +lemma Ints_0 [simp]: "0 \<in> \<int>"
 11.1158 +apply (simp add: Ints_def)
 11.1159 +apply (rule range_eqI)
 11.1160 +apply (rule of_int_0 [symmetric])
 11.1161 +done
 11.1162 +
 11.1163 +lemma Ints_1 [simp]: "1 \<in> \<int>"
 11.1164 +apply (simp add: Ints_def)
 11.1165 +apply (rule range_eqI)
 11.1166 +apply (rule of_int_1 [symmetric])
 11.1167 +done
 11.1168 +
 11.1169 +lemma Ints_add [simp]: "a \<in> \<int> \<Longrightarrow> b \<in> \<int> \<Longrightarrow> a + b \<in> \<int>"
 11.1170 +apply (auto simp add: Ints_def)
 11.1171 +apply (rule range_eqI)
 11.1172 +apply (rule of_int_add [symmetric])
 11.1173 +done
 11.1174 +
 11.1175 +lemma Ints_minus [simp]: "a \<in> \<int> \<Longrightarrow> -a \<in> \<int>"
 11.1176 +apply (auto simp add: Ints_def)
 11.1177 +apply (rule range_eqI)
 11.1178 +apply (rule of_int_minus [symmetric])
 11.1179 +done
 11.1180 +
 11.1181 +lemma Ints_mult [simp]: "a \<in> \<int> \<Longrightarrow> b \<in> \<int> \<Longrightarrow> a * b \<in> \<int>"
 11.1182 +apply (auto simp add: Ints_def)
 11.1183 +apply (rule range_eqI)
 11.1184 +apply (rule of_int_mult [symmetric])
 11.1185 +done
 11.1186 +
 11.1187 +lemma Ints_cases [cases set: Ints]:
 11.1188 +  assumes "q \<in> \<int>"
 11.1189 +  obtains (of_int) z where "q = of_int z"
 11.1190 +  unfolding Ints_def
 11.1191 +proof -
 11.1192 +  from `q \<in> \<int>` have "q \<in> range of_int" unfolding Ints_def .
 11.1193 +  then obtain z where "q = of_int z" ..
 11.1194 +  then show thesis ..
 11.1195 +qed
 11.1196 +
 11.1197 +lemma Ints_induct [case_names of_int, induct set: Ints]:
 11.1198 +  "q \<in> \<int> \<Longrightarrow> (\<And>z. P (of_int z)) \<Longrightarrow> P q"
 11.1199 +  by (rule Ints_cases) auto
 11.1200 +
 11.1201 +end
 11.1202 +
 11.1203 +lemma Ints_diff [simp]: "a \<in> \<int> \<Longrightarrow> b \<in> \<int> \<Longrightarrow> a-b \<in> \<int>"
 11.1204 +apply (auto simp add: Ints_def)
 11.1205 +apply (rule range_eqI)
 11.1206 +apply (rule of_int_diff [symmetric])
 11.1207 +done
 11.1208 +
 11.1209 +text {* The premise involving @{term Ints} prevents @{term "a = 1/2"}. *}
 11.1210 +
 11.1211 +lemma Ints_double_eq_0_iff:
 11.1212 +  assumes in_Ints: "a \<in> Ints"
 11.1213 +  shows "(a + a = 0) = (a = (0::'a::ring_char_0))"
 11.1214 +proof -
 11.1215 +  from in_Ints have "a \<in> range of_int" unfolding Ints_def [symmetric] .
 11.1216 +  then obtain z where a: "a = of_int z" ..
 11.1217 +  show ?thesis
 11.1218 +  proof
 11.1219 +    assume "a = 0"
 11.1220 +    thus "a + a = 0" by simp
 11.1221 +  next
 11.1222 +    assume eq: "a + a = 0"
 11.1223 +    hence "of_int (z + z) = (of_int 0 :: 'a)" by (simp add: a)
 11.1224 +    hence "z + z = 0" by (simp only: of_int_eq_iff)
 11.1225 +    hence "z = 0" by (simp only: double_eq_0_iff)
 11.1226 +    thus "a = 0" by (simp add: a)
 11.1227 +  qed
 11.1228 +qed
 11.1229 +
 11.1230 +lemma Ints_odd_nonzero:
 11.1231 +  assumes in_Ints: "a \<in> Ints"
 11.1232 +  shows "1 + a + a \<noteq> (0::'a::ring_char_0)"
 11.1233 +proof -
 11.1234 +  from in_Ints have "a \<in> range of_int" unfolding Ints_def [symmetric] .
 11.1235 +  then obtain z where a: "a = of_int z" ..
 11.1236 +  show ?thesis
 11.1237 +  proof
 11.1238 +    assume eq: "1 + a + a = 0"
 11.1239 +    hence "of_int (1 + z + z) = (of_int 0 :: 'a)" by (simp add: a)
 11.1240 +    hence "1 + z + z = 0" by (simp only: of_int_eq_iff)
 11.1241 +    with odd_nonzero show False by blast
 11.1242 +  qed
 11.1243 +qed 
 11.1244 +
 11.1245 +lemma Ints_number_of:
 11.1246 +  "(number_of w :: 'a::number_ring) \<in> Ints"
 11.1247 +  unfolding number_of_eq Ints_def by simp
 11.1248 +
 11.1249 +lemma Ints_odd_less_0: 
 11.1250 +  assumes in_Ints: "a \<in> Ints"
 11.1251 +  shows "(1 + a + a < 0) = (a < (0::'a::ordered_idom))";
 11.1252 +proof -
 11.1253 +  from in_Ints have "a \<in> range of_int" unfolding Ints_def [symmetric] .
 11.1254 +  then obtain z where a: "a = of_int z" ..
 11.1255 +  hence "((1::'a) + a + a < 0) = (of_int (1 + z + z) < (of_int 0 :: 'a))"
 11.1256 +    by (simp add: a)
 11.1257 +  also have "... = (z < 0)" by (simp only: of_int_less_iff odd_less_0)
 11.1258 +  also have "... = (a < 0)" by (simp add: a)
 11.1259 +  finally show ?thesis .
 11.1260 +qed
 11.1261 +
 11.1262 +
 11.1263 +subsection {* @{term setsum} and @{term setprod} *}
 11.1264 +
 11.1265 +text {*By Jeremy Avigad*}
 11.1266 +
 11.1267 +lemma of_nat_setsum: "of_nat (setsum f A) = (\<Sum>x\<in>A. of_nat(f x))"
 11.1268 +  apply (cases "finite A")
 11.1269 +  apply (erule finite_induct, auto)
 11.1270 +  done
 11.1271 +
 11.1272 +lemma of_int_setsum: "of_int (setsum f A) = (\<Sum>x\<in>A. of_int(f x))"
 11.1273 +  apply (cases "finite A")
 11.1274 +  apply (erule finite_induct, auto)
 11.1275 +  done
 11.1276 +
 11.1277 +lemma of_nat_setprod: "of_nat (setprod f A) = (\<Prod>x\<in>A. of_nat(f x))"
 11.1278 +  apply (cases "finite A")
 11.1279 +  apply (erule finite_induct, auto simp add: of_nat_mult)
 11.1280 +  done
 11.1281 +
 11.1282 +lemma of_int_setprod: "of_int (setprod f A) = (\<Prod>x\<in>A. of_int(f x))"
 11.1283 +  apply (cases "finite A")
 11.1284 +  apply (erule finite_induct, auto)
 11.1285 +  done
 11.1286 +
 11.1287 +lemma setprod_nonzero_nat:
 11.1288 +    "finite A ==> (\<forall>x \<in> A. f x \<noteq> (0::nat)) ==> setprod f A \<noteq> 0"
 11.1289 +  by (rule setprod_nonzero, auto)
 11.1290 +
 11.1291 +lemma setprod_zero_eq_nat:
 11.1292 +    "finite A ==> (setprod f A = (0::nat)) = (\<exists>x \<in> A. f x = 0)"
 11.1293 +  by (rule setprod_zero_eq, auto)
 11.1294 +
 11.1295 +lemma setprod_nonzero_int:
 11.1296 +    "finite A ==> (\<forall>x \<in> A. f x \<noteq> (0::int)) ==> setprod f A \<noteq> 0"
 11.1297 +  by (rule setprod_nonzero, auto)
 11.1298 +
 11.1299 +lemma setprod_zero_eq_int:
 11.1300 +    "finite A ==> (setprod f A = (0::int)) = (\<exists>x \<in> A. f x = 0)"
 11.1301 +  by (rule setprod_zero_eq, auto)
 11.1302 +
 11.1303 +lemmas int_setsum = of_nat_setsum [where 'a=int]
 11.1304 +lemmas int_setprod = of_nat_setprod [where 'a=int]
 11.1305 +
 11.1306 +
 11.1307 +subsection{*Inequality Reasoning for the Arithmetic Simproc*}
 11.1308 +
 11.1309 +lemma add_numeral_0: "Numeral0 + a = (a::'a::number_ring)"
 11.1310 +by simp 
 11.1311 +
 11.1312 +lemma add_numeral_0_right: "a + Numeral0 = (a::'a::number_ring)"
 11.1313 +by simp
 11.1314 +
 11.1315 +lemma mult_numeral_1: "Numeral1 * a = (a::'a::number_ring)"
 11.1316 +by simp 
 11.1317 +
 11.1318 +lemma mult_numeral_1_right: "a * Numeral1 = (a::'a::number_ring)"
 11.1319 +by simp
 11.1320 +
 11.1321 +lemma divide_numeral_1: "a / Numeral1 = (a::'a::{number_ring,field})"
 11.1322 +by simp
 11.1323 +
 11.1324 +lemma inverse_numeral_1:
 11.1325 +  "inverse Numeral1 = (Numeral1::'a::{number_ring,field})"
 11.1326 +by simp
 11.1327 +
 11.1328 +text{*Theorem lists for the cancellation simprocs. The use of binary numerals
 11.1329 +for 0 and 1 reduces the number of special cases.*}
 11.1330 +
 11.1331 +lemmas add_0s = add_numeral_0 add_numeral_0_right
 11.1332 +lemmas mult_1s = mult_numeral_1 mult_numeral_1_right 
 11.1333 +                 mult_minus1 mult_minus1_right
 11.1334 +
 11.1335 +
 11.1336 +subsection{*Special Arithmetic Rules for Abstract 0 and 1*}
 11.1337 +
 11.1338 +text{*Arithmetic computations are defined for binary literals, which leaves 0
 11.1339 +and 1 as special cases. Addition already has rules for 0, but not 1.
 11.1340 +Multiplication and unary minus already have rules for both 0 and 1.*}
 11.1341 +
 11.1342 +
 11.1343 +lemma binop_eq: "[|f x y = g x y; x = x'; y = y'|] ==> f x' y' = g x' y'"
 11.1344 +by simp
 11.1345 +
 11.1346 +
 11.1347 +lemmas add_number_of_eq = number_of_add [symmetric]
 11.1348 +
 11.1349 +text{*Allow 1 on either or both sides*}
 11.1350 +lemma one_add_one_is_two: "1 + 1 = (2::'a::number_ring)"
 11.1351 +by (simp del: numeral_1_eq_1 add: numeral_1_eq_1 [symmetric] add_number_of_eq)
 11.1352 +
 11.1353 +lemmas add_special =
 11.1354 +    one_add_one_is_two
 11.1355 +    binop_eq [of "op +", OF add_number_of_eq numeral_1_eq_1 refl, standard]
 11.1356 +    binop_eq [of "op +", OF add_number_of_eq refl numeral_1_eq_1, standard]
 11.1357 +
 11.1358 +text{*Allow 1 on either or both sides (1-1 already simplifies to 0)*}
 11.1359 +lemmas diff_special =
 11.1360 +    binop_eq [of "op -", OF diff_number_of_eq numeral_1_eq_1 refl, standard]
 11.1361 +    binop_eq [of "op -", OF diff_number_of_eq refl numeral_1_eq_1, standard]
 11.1362 +
 11.1363 +text{*Allow 0 or 1 on either side with a binary numeral on the other*}
 11.1364 +lemmas eq_special =
 11.1365 +    binop_eq [of "op =", OF eq_number_of_eq numeral_0_eq_0 refl, standard]
 11.1366 +    binop_eq [of "op =", OF eq_number_of_eq numeral_1_eq_1 refl, standard]
 11.1367 +    binop_eq [of "op =", OF eq_number_of_eq refl numeral_0_eq_0, standard]
 11.1368 +    binop_eq [of "op =", OF eq_number_of_eq refl numeral_1_eq_1, standard]
 11.1369 +
 11.1370 +text{*Allow 0 or 1 on either side with a binary numeral on the other*}
 11.1371 +lemmas less_special =
 11.1372 +  binop_eq [of "op <", OF less_number_of_eq_neg numeral_0_eq_0 refl, standard]
 11.1373 +  binop_eq [of "op <", OF less_number_of_eq_neg numeral_1_eq_1 refl, standard]
 11.1374 +  binop_eq [of "op <", OF less_number_of_eq_neg refl numeral_0_eq_0, standard]
 11.1375 +  binop_eq [of "op <", OF less_number_of_eq_neg refl numeral_1_eq_1, standard]
 11.1376 +
 11.1377 +text{*Allow 0 or 1 on either side with a binary numeral on the other*}
 11.1378 +lemmas le_special =
 11.1379 +    binop_eq [of "op \<le>", OF le_number_of_eq numeral_0_eq_0 refl, standard]
 11.1380 +    binop_eq [of "op \<le>", OF le_number_of_eq numeral_1_eq_1 refl, standard]
 11.1381 +    binop_eq [of "op \<le>", OF le_number_of_eq refl numeral_0_eq_0, standard]
 11.1382 +    binop_eq [of "op \<le>", OF le_number_of_eq refl numeral_1_eq_1, standard]
 11.1383 +
 11.1384 +lemmas arith_special[simp] = 
 11.1385 +       add_special diff_special eq_special less_special le_special
 11.1386 +
 11.1387 +
 11.1388 +lemma min_max_01: "min (0::int) 1 = 0 & min (1::int) 0 = 0 &
 11.1389 +                   max (0::int) 1 = 1 & max (1::int) 0 = 1"
 11.1390 +by(simp add:min_def max_def)
 11.1391 +
 11.1392 +lemmas min_max_special[simp] =
 11.1393 + min_max_01
 11.1394 + max_def[of "0::int" "number_of v", standard, simp]
 11.1395 + min_def[of "0::int" "number_of v", standard, simp]
 11.1396 + max_def[of "number_of u" "0::int", standard, simp]
 11.1397 + min_def[of "number_of u" "0::int", standard, simp]
 11.1398 + max_def[of "1::int" "number_of v", standard, simp]
 11.1399 + min_def[of "1::int" "number_of v", standard, simp]
 11.1400 + max_def[of "number_of u" "1::int", standard, simp]
 11.1401 + min_def[of "number_of u" "1::int", standard, simp]
 11.1402 +
 11.1403 +text {* Legacy theorems *}
 11.1404 +
 11.1405 +lemmas zle_int = of_nat_le_iff [where 'a=int]
 11.1406 +lemmas int_int_eq = of_nat_eq_iff [where 'a=int]
 11.1407 +
 11.1408 +use "~~/src/Provers/Arith/assoc_fold.ML"
 11.1409 +use "int_arith1.ML"
 11.1410 +declaration {* K int_arith_setup *}
 11.1411 +
 11.1412 +
 11.1413 +subsection{*Lemmas About Small Numerals*}
 11.1414 +
 11.1415 +lemma of_int_m1 [simp]: "of_int -1 = (-1 :: 'a :: number_ring)"
 11.1416 +proof -
 11.1417 +  have "(of_int -1 :: 'a) = of_int (- 1)" by simp
 11.1418 +  also have "... = - of_int 1" by (simp only: of_int_minus)
 11.1419 +  also have "... = -1" by simp
 11.1420 +  finally show ?thesis .
 11.1421 +qed
 11.1422 +
 11.1423 +lemma abs_minus_one [simp]: "abs (-1) = (1::'a::{ordered_idom,number_ring})"
 11.1424 +by (simp add: abs_if)
 11.1425 +
 11.1426 +lemma abs_power_minus_one [simp]:
 11.1427 +     "abs(-1 ^ n) = (1::'a::{ordered_idom,number_ring,recpower})"
 11.1428 +by (simp add: power_abs)
 11.1429 +
 11.1430 +lemma of_int_number_of_eq:
 11.1431 +     "of_int (number_of v) = (number_of v :: 'a :: number_ring)"
 11.1432 +by (simp add: number_of_eq) 
 11.1433 +
 11.1434 +text{*Lemmas for specialist use, NOT as default simprules*}
 11.1435 +lemma mult_2: "2 * z = (z+z::'a::number_ring)"
 11.1436 +proof -
 11.1437 +  have "2*z = (1 + 1)*z" by simp
 11.1438 +  also have "... = z+z" by (simp add: left_distrib)
 11.1439 +  finally show ?thesis .
 11.1440 +qed
 11.1441 +
 11.1442 +lemma mult_2_right: "z * 2 = (z+z::'a::number_ring)"
 11.1443 +by (subst mult_commute, rule mult_2)
 11.1444 +
 11.1445 +
 11.1446 +subsection{*More Inequality Reasoning*}
 11.1447 +
 11.1448 +lemma zless_add1_eq: "(w < z + (1::int)) = (w<z | w=z)"
 11.1449 +by arith
 11.1450 +
 11.1451 +lemma add1_zle_eq: "(w + (1::int) \<le> z) = (w<z)"
 11.1452 +by arith
 11.1453 +
 11.1454 +lemma zle_diff1_eq [simp]: "(w \<le> z - (1::int)) = (w<z)"
 11.1455 +by arith
 11.1456 +
 11.1457 +lemma zle_add1_eq_le [simp]: "(w < z + (1::int)) = (w\<le>z)"
 11.1458 +by arith
 11.1459 +
 11.1460 +lemma int_one_le_iff_zero_less: "((1::int) \<le> z) = (0 < z)"
 11.1461 +by arith
 11.1462 +
 11.1463 +
 11.1464 +subsection{*The Functions @{term nat} and @{term int}*}
 11.1465 +
 11.1466 +text{*Simplify the terms @{term "int 0"}, @{term "int(Suc 0)"} and
 11.1467 +  @{term "w + - z"}*}
 11.1468 +declare Zero_int_def [symmetric, simp]
 11.1469 +declare One_int_def [symmetric, simp]
 11.1470 +
 11.1471 +lemmas diff_int_def_symmetric = diff_int_def [symmetric, simp]
 11.1472 +
 11.1473 +lemma nat_0: "nat 0 = 0"
 11.1474 +by (simp add: nat_eq_iff)
 11.1475 +
 11.1476 +lemma nat_1: "nat 1 = Suc 0"
 11.1477 +by (subst nat_eq_iff, simp)
 11.1478 +
 11.1479 +lemma nat_2: "nat 2 = Suc (Suc 0)"
 11.1480 +by (subst nat_eq_iff, simp)
 11.1481 +
 11.1482 +lemma one_less_nat_eq [simp]: "(Suc 0 < nat z) = (1 < z)"
 11.1483 +apply (insert zless_nat_conj [of 1 z])
 11.1484 +apply (auto simp add: nat_1)
 11.1485 +done
 11.1486 +
 11.1487 +text{*This simplifies expressions of the form @{term "int n = z"} where
 11.1488 +      z is an integer literal.*}
 11.1489 +lemmas int_eq_iff_number_of [simp] = int_eq_iff [of _ "number_of v", standard]
 11.1490 +
 11.1491 +lemma split_nat [arith_split]:
 11.1492 +  "P(nat(i::int)) = ((\<forall>n. i = of_nat n \<longrightarrow> P n) & (i < 0 \<longrightarrow> P 0))"
 11.1493 +  (is "?P = (?L & ?R)")
 11.1494 +proof (cases "i < 0")
 11.1495 +  case True thus ?thesis by auto
 11.1496 +next
 11.1497 +  case False
 11.1498 +  have "?P = ?L"
 11.1499 +  proof
 11.1500 +    assume ?P thus ?L using False by clarsimp
 11.1501 +  next
 11.1502 +    assume ?L thus ?P using False by simp
 11.1503 +  qed
 11.1504 +  with False show ?thesis by simp
 11.1505 +qed
 11.1506 +
 11.1507 +context ring_1
 11.1508 +begin
 11.1509 +
 11.1510 +lemma of_int_of_nat:
 11.1511 +  "of_int k = (if k < 0 then - of_nat (nat (- k)) else of_nat (nat k))"
 11.1512 +proof (cases "k < 0")
 11.1513 +  case True then have "0 \<le> - k" by simp
 11.1514 +  then have "of_nat (nat (- k)) = of_int (- k)" by (rule of_nat_nat)
 11.1515 +  with True show ?thesis by simp
 11.1516 +next
 11.1517 +  case False then show ?thesis by (simp add: not_less of_nat_nat)
 11.1518 +qed
 11.1519 +
 11.1520 +end
 11.1521 +
 11.1522 +lemma nat_mult_distrib:
 11.1523 +  fixes z z' :: int
 11.1524 +  assumes "0 \<le> z"
 11.1525 +  shows "nat (z * z') = nat z * nat z'"
 11.1526 +proof (cases "0 \<le> z'")
 11.1527 +  case False with assms have "z * z' \<le> 0"
 11.1528 +    by (simp add: not_le mult_le_0_iff)
 11.1529 +  then have "nat (z * z') = 0" by simp
 11.1530 +  moreover from False have "nat z' = 0" by simp
 11.1531 +  ultimately show ?thesis by simp
 11.1532 +next
 11.1533 +  case True with assms have ge_0: "z * z' \<ge> 0" by (simp add: zero_le_mult_iff)
 11.1534 +  show ?thesis
 11.1535 +    by (rule injD [of "of_nat :: nat \<Rightarrow> int", OF inj_of_nat])
 11.1536 +      (simp only: of_nat_mult of_nat_nat [OF True]
 11.1537 +         of_nat_nat [OF assms] of_nat_nat [OF ge_0], simp)
 11.1538 +qed
 11.1539 +
 11.1540 +lemma nat_mult_distrib_neg: "z \<le> (0::int) ==> nat(z*z') = nat(-z) * nat(-z')"
 11.1541 +apply (rule trans)
 11.1542 +apply (rule_tac [2] nat_mult_distrib, auto)
 11.1543 +done
 11.1544 +
 11.1545 +lemma nat_abs_mult_distrib: "nat (abs (w * z)) = nat (abs w) * nat (abs z)"
 11.1546 +apply (cases "z=0 | w=0")
 11.1547 +apply (auto simp add: abs_if nat_mult_distrib [symmetric] 
 11.1548 +                      nat_mult_distrib_neg [symmetric] mult_less_0_iff)
 11.1549 +done
 11.1550 +
 11.1551 +
 11.1552 +subsection "Induction principles for int"
 11.1553 +
 11.1554 +text{*Well-founded segments of the integers*}
 11.1555 +
 11.1556 +definition
 11.1557 +  int_ge_less_than  ::  "int => (int * int) set"
 11.1558 +where
 11.1559 +  "int_ge_less_than d = {(z',z). d \<le> z' & z' < z}"
 11.1560 +
 11.1561 +theorem wf_int_ge_less_than: "wf (int_ge_less_than d)"
 11.1562 +proof -
 11.1563 +  have "int_ge_less_than d \<subseteq> measure (%z. nat (z-d))"
 11.1564 +    by (auto simp add: int_ge_less_than_def)
 11.1565 +  thus ?thesis 
 11.1566 +    by (rule wf_subset [OF wf_measure]) 
 11.1567 +qed
 11.1568 +
 11.1569 +text{*This variant looks odd, but is typical of the relations suggested
 11.1570 +by RankFinder.*}
 11.1571 +
 11.1572 +definition
 11.1573 +  int_ge_less_than2 ::  "int => (int * int) set"
 11.1574 +where
 11.1575 +  "int_ge_less_than2 d = {(z',z). d \<le> z & z' < z}"
 11.1576 +
 11.1577 +theorem wf_int_ge_less_than2: "wf (int_ge_less_than2 d)"
 11.1578 +proof -
 11.1579 +  have "int_ge_less_than2 d \<subseteq> measure (%z. nat (1+z-d))" 
 11.1580 +    by (auto simp add: int_ge_less_than2_def)
 11.1581 +  thus ?thesis 
 11.1582 +    by (rule wf_subset [OF wf_measure]) 
 11.1583 +qed
 11.1584 +
 11.1585 +abbreviation
 11.1586 +  int :: "nat \<Rightarrow> int"
 11.1587 +where
 11.1588 +  "int \<equiv> of_nat"
 11.1589 +
 11.1590 +(* `set:int': dummy construction *)
 11.1591 +theorem int_ge_induct [case_names base step, induct set: int]:
 11.1592 +  fixes i :: int
 11.1593 +  assumes ge: "k \<le> i" and
 11.1594 +    base: "P k" and
 11.1595 +    step: "\<And>i. k \<le> i \<Longrightarrow> P i \<Longrightarrow> P (i + 1)"
 11.1596 +  shows "P i"
 11.1597 +proof -
 11.1598 +  { fix n have "\<And>i::int. n = nat(i-k) \<Longrightarrow> k \<le> i \<Longrightarrow> P i"
 11.1599 +    proof (induct n)
 11.1600 +      case 0
 11.1601 +      hence "i = k" by arith
 11.1602 +      thus "P i" using base by simp
 11.1603 +    next
 11.1604 +      case (Suc n)
 11.1605 +      then have "n = nat((i - 1) - k)" by arith
 11.1606 +      moreover
 11.1607 +      have ki1: "k \<le> i - 1" using Suc.prems by arith
 11.1608 +      ultimately
 11.1609 +      have "P(i - 1)" by(rule Suc.hyps)
 11.1610 +      from step[OF ki1 this] show ?case by simp
 11.1611 +    qed
 11.1612 +  }
 11.1613 +  with ge show ?thesis by fast
 11.1614 +qed
 11.1615 +
 11.1616 +                     (* `set:int': dummy construction *)
 11.1617 +theorem int_gr_induct[case_names base step,induct set:int]:
 11.1618 +  assumes gr: "k < (i::int)" and
 11.1619 +        base: "P(k+1)" and
 11.1620 +        step: "\<And>i. \<lbrakk>k < i; P i\<rbrakk> \<Longrightarrow> P(i+1)"
 11.1621 +  shows "P i"
 11.1622 +apply(rule int_ge_induct[of "k + 1"])
 11.1623 +  using gr apply arith
 11.1624 + apply(rule base)
 11.1625 +apply (rule step, simp+)
 11.1626 +done
 11.1627 +
 11.1628 +theorem int_le_induct[consumes 1,case_names base step]:
 11.1629 +  assumes le: "i \<le> (k::int)" and
 11.1630 +        base: "P(k)" and
 11.1631 +        step: "\<And>i. \<lbrakk>i \<le> k; P i\<rbrakk> \<Longrightarrow> P(i - 1)"
 11.1632 +  shows "P i"
 11.1633 +proof -
 11.1634 +  { fix n have "\<And>i::int. n = nat(k-i) \<Longrightarrow> i \<le> k \<Longrightarrow> P i"
 11.1635 +    proof (induct n)
 11.1636 +      case 0
 11.1637 +      hence "i = k" by arith
 11.1638 +      thus "P i" using base by simp
 11.1639 +    next
 11.1640 +      case (Suc n)
 11.1641 +      hence "n = nat(k - (i+1))" by arith
 11.1642 +      moreover
 11.1643 +      have ki1: "i + 1 \<le> k" using Suc.prems by arith
 11.1644 +      ultimately
 11.1645 +      have "P(i+1)" by(rule Suc.hyps)
 11.1646 +      from step[OF ki1 this] show ?case by simp
 11.1647 +    qed
 11.1648 +  }
 11.1649 +  with le show ?thesis by fast
 11.1650 +qed
 11.1651 +
 11.1652 +theorem int_less_induct [consumes 1,case_names base step]:
 11.1653 +  assumes less: "(i::int) < k" and
 11.1654 +        base: "P(k - 1)" and
 11.1655 +        step: "\<And>i. \<lbrakk>i < k; P i\<rbrakk> \<Longrightarrow> P(i - 1)"
 11.1656 +  shows "P i"
 11.1657 +apply(rule int_le_induct[of _ "k - 1"])
 11.1658 +  using less apply arith
 11.1659 + apply(rule base)
 11.1660 +apply (rule step, simp+)
 11.1661 +done
 11.1662 +
 11.1663 +subsection{*Intermediate value theorems*}
 11.1664 +
 11.1665 +lemma int_val_lemma:
 11.1666 +     "(\<forall>i<n::nat. abs(f(i+1) - f i) \<le> 1) -->  
 11.1667 +      f 0 \<le> k --> k \<le> f n --> (\<exists>i \<le> n. f i = (k::int))"
 11.1668 +apply (induct_tac "n", simp)
 11.1669 +apply (intro strip)
 11.1670 +apply (erule impE, simp)
 11.1671 +apply (erule_tac x = n in allE, simp)
 11.1672 +apply (case_tac "k = f (n+1) ")
 11.1673 + apply force
 11.1674 +apply (erule impE)
 11.1675 + apply (simp add: abs_if split add: split_if_asm)
 11.1676 +apply (blast intro: le_SucI)
 11.1677 +done
 11.1678 +
 11.1679 +lemmas nat0_intermed_int_val = int_val_lemma [rule_format (no_asm)]
 11.1680 +
 11.1681 +lemma nat_intermed_int_val:
 11.1682 +     "[| \<forall>i. m \<le> i & i < n --> abs(f(i + 1::nat) - f i) \<le> 1; m < n;  
 11.1683 +         f m \<le> k; k \<le> f n |] ==> ? i. m \<le> i & i \<le> n & f i = (k::int)"
 11.1684 +apply (cut_tac n = "n-m" and f = "%i. f (i+m) " and k = k 
 11.1685 +       in int_val_lemma)
 11.1686 +apply simp
 11.1687 +apply (erule exE)
 11.1688 +apply (rule_tac x = "i+m" in exI, arith)
 11.1689 +done
 11.1690 +
 11.1691 +
 11.1692 +subsection{*Products and 1, by T. M. Rasmussen*}
 11.1693 +
 11.1694 +lemma zabs_less_one_iff [simp]: "(\<bar>z\<bar> < 1) = (z = (0::int))"
 11.1695 +by arith
 11.1696 +
 11.1697 +lemma abs_zmult_eq_1: "(\<bar>m * n\<bar> = 1) ==> \<bar>m\<bar> = (1::int)"
 11.1698 +apply (cases "\<bar>n\<bar>=1") 
 11.1699 +apply (simp add: abs_mult) 
 11.1700 +apply (rule ccontr) 
 11.1701 +apply (auto simp add: linorder_neq_iff abs_mult) 
 11.1702 +apply (subgoal_tac "2 \<le> \<bar>m\<bar> & 2 \<le> \<bar>n\<bar>")
 11.1703 + prefer 2 apply arith 
 11.1704 +apply (subgoal_tac "2*2 \<le> \<bar>m\<bar> * \<bar>n\<bar>", simp) 
 11.1705 +apply (rule mult_mono, auto) 
 11.1706 +done
 11.1707 +
 11.1708 +lemma pos_zmult_eq_1_iff_lemma: "(m * n = 1) ==> m = (1::int) | m = -1"
 11.1709 +by (insert abs_zmult_eq_1 [of m n], arith)
 11.1710 +
 11.1711 +lemma pos_zmult_eq_1_iff: "0 < (m::int) ==> (m * n = 1) = (m = 1 & n = 1)"
 11.1712 +apply (auto dest: pos_zmult_eq_1_iff_lemma) 
 11.1713 +apply (simp add: mult_commute [of m]) 
 11.1714 +apply (frule pos_zmult_eq_1_iff_lemma, auto) 
 11.1715 +done
 11.1716 +
 11.1717 +lemma zmult_eq_1_iff: "(m*n = (1::int)) = ((m = 1 & n = 1) | (m = -1 & n = -1))"
 11.1718 +apply (rule iffI) 
 11.1719 + apply (frule pos_zmult_eq_1_iff_lemma)
 11.1720 + apply (simp add: mult_commute [of m]) 
 11.1721 + apply (frule pos_zmult_eq_1_iff_lemma, auto) 
 11.1722 +done
 11.1723 +
 11.1724 +(* Could be simplified but Presburger only becomes available too late *)
 11.1725 +lemma infinite_UNIV_int: "~finite(UNIV::int set)"
 11.1726 +proof
 11.1727 +  assume "finite(UNIV::int set)"
 11.1728 +  moreover have "~(EX i::int. 2*i = 1)"
 11.1729 +    by (auto simp: pos_zmult_eq_1_iff)
 11.1730 +  ultimately show False using finite_UNIV_inj_surj[of "%n::int. n+n"]
 11.1731 +    by (simp add:inj_on_def surj_def) (blast intro:sym)
 11.1732 +qed
 11.1733 +
 11.1734 +
 11.1735 +subsection {* Configuration of the code generator *}
 11.1736 +
 11.1737 +instance int :: eq ..
 11.1738 +
 11.1739 +code_datatype Pls Min Bit "number_of \<Colon> int \<Rightarrow> int"
 11.1740 +
 11.1741 +definition
 11.1742 +  int_aux :: "nat \<Rightarrow> int \<Rightarrow> int" where
 11.1743 +  "int_aux n i = int n + i"
 11.1744 +
 11.1745 +lemma [code]:
 11.1746 +  "int_aux 0 i  = i"
 11.1747 +  "int_aux (Suc n) i = int_aux n (i + 1)" -- {* tail recursive *}
 11.1748 +  by (simp add: int_aux_def)+
 11.1749 +
 11.1750 +lemma [code, code unfold, code inline del]:
 11.1751 +  "int n = int_aux n 0"
 11.1752 +  by (simp add: int_aux_def)
 11.1753 +
 11.1754 +definition
 11.1755 +  nat_aux :: "int \<Rightarrow> nat \<Rightarrow> nat" where
 11.1756 +  "nat_aux i n = nat i + n"
 11.1757 +
 11.1758 +lemma [code]:
 11.1759 +  "nat_aux i n = (if i \<le> 0 then n else nat_aux (i - 1) (Suc n))"  -- {* tail recursive *}
 11.1760 +  by (auto simp add: nat_aux_def nat_eq_iff linorder_not_le order_less_imp_le
 11.1761 +    dest: zless_imp_add1_zle)
 11.1762 +
 11.1763 +lemma [code]: "nat i = nat_aux i 0"
 11.1764 +  by (simp add: nat_aux_def)
 11.1765 +
 11.1766 +lemma zero_is_num_zero [code func, code inline, symmetric, code post]:
 11.1767 +  "(0\<Colon>int) = Numeral0" 
 11.1768 +  by simp
 11.1769 +
 11.1770 +lemma one_is_num_one [code func, code inline, symmetric, code post]:
 11.1771 +  "(1\<Colon>int) = Numeral1" 
 11.1772 +  by simp 
 11.1773 +
 11.1774 +code_modulename SML
 11.1775 +  IntDef Integer
 11.1776 +
 11.1777 +code_modulename OCaml
 11.1778 +  IntDef Integer
 11.1779 +
 11.1780 +code_modulename Haskell
 11.1781 +  IntDef Integer
 11.1782 +
 11.1783 +code_modulename SML
 11.1784 +  Numeral Integer
 11.1785 +
 11.1786 +code_modulename OCaml
 11.1787 +  Numeral Integer
 11.1788 +
 11.1789 +code_modulename Haskell
 11.1790 +  Numeral Integer
 11.1791 +
 11.1792 +types_code
 11.1793 +  "int" ("int")
 11.1794 +attach (term_of) {*
 11.1795 +val term_of_int = HOLogic.mk_number HOLogic.intT;
 11.1796 +*}
 11.1797 +attach (test) {*
 11.1798 +fun gen_int i =
 11.1799 +  let val j = one_of [~1, 1] * random_range 0 i
 11.1800 +  in (j, fn () => term_of_int j) end;
 11.1801 +*}
 11.1802 +
 11.1803 +setup {*
 11.1804 +let
 11.1805 +
 11.1806 +fun strip_number_of (@{term "Int.number_of :: int => int"} $ t) = t
 11.1807 +  | strip_number_of t = t;
 11.1808 +
 11.1809 +fun numeral_codegen thy defs gr dep module b t =
 11.1810 +  let val i = HOLogic.dest_numeral (strip_number_of t)
 11.1811 +  in
 11.1812 +    SOME (fst (Codegen.invoke_tycodegen thy defs dep module false (gr, HOLogic.intT)),
 11.1813 +      Pretty.str (string_of_int i))
 11.1814 +  end handle TERM _ => NONE;
 11.1815 +
 11.1816 +in
 11.1817 +
 11.1818 +Codegen.add_codegen "numeral_codegen" numeral_codegen
 11.1819 +
 11.1820 +end
 11.1821 +*}
 11.1822 +
 11.1823 +consts_code
 11.1824 +  "number_of :: int \<Rightarrow> int"    ("(_)")
 11.1825 +  "0 :: int"                   ("0")
 11.1826 +  "1 :: int"                   ("1")
 11.1827 +  "uminus :: int => int"       ("~")
 11.1828 +  "op + :: int => int => int"  ("(_ +/ _)")
 11.1829 +  "op * :: int => int => int"  ("(_ */ _)")
 11.1830 +  "op \<le> :: int => int => bool" ("(_ <=/ _)")
 11.1831 +  "op < :: int => int => bool" ("(_ </ _)")
 11.1832 +
 11.1833 +quickcheck_params [default_type = int]
 11.1834 +
 11.1835 +(*setup continues in theory Presburger*)
 11.1836 +
 11.1837 +hide (open) const Pls Min B0 B1 succ pred
 11.1838 +
 11.1839 +
 11.1840 +subsection {* Legacy theorems *}
 11.1841 +
 11.1842 +lemmas zminus_zminus = minus_minus [of "z::int", standard]
 11.1843 +lemmas zminus_0 = minus_zero [where 'a=int]
 11.1844 +lemmas zminus_zadd_distrib = minus_add_distrib [of "z::int" "w", standard]
 11.1845 +lemmas zadd_commute = add_commute [of "z::int" "w", standard]
 11.1846 +lemmas zadd_assoc = add_assoc [of "z1::int" "z2" "z3", standard]
 11.1847 +lemmas zadd_left_commute = add_left_commute [of "x::int" "y" "z", standard]
 11.1848 +lemmas zadd_ac = zadd_assoc zadd_commute zadd_left_commute
 11.1849 +lemmas zmult_ac = OrderedGroup.mult_ac
 11.1850 +lemmas zadd_0 = OrderedGroup.add_0_left [of "z::int", standard]
 11.1851 +lemmas zadd_0_right = OrderedGroup.add_0_left [of "z::int", standard]
 11.1852 +lemmas zadd_zminus_inverse2 = left_minus [of "z::int", standard]
 11.1853 +lemmas zmult_zminus = mult_minus_left [of "z::int" "w", standard]
 11.1854 +lemmas zmult_commute = mult_commute [of "z::int" "w", standard]
 11.1855 +lemmas zmult_assoc = mult_assoc [of "z1::int" "z2" "z3", standard]
 11.1856 +lemmas zadd_zmult_distrib = left_distrib [of "z1::int" "z2" "w", standard]
 11.1857 +lemmas zadd_zmult_distrib2 = right_distrib [of "w::int" "z1" "z2", standard]
 11.1858 +lemmas zdiff_zmult_distrib = left_diff_distrib [of "z1::int" "z2" "w", standard]
 11.1859 +lemmas zdiff_zmult_distrib2 = right_diff_distrib [of "w::int" "z1" "z2", standard]
 11.1860 +
 11.1861 +lemmas int_distrib =
 11.1862 +  zadd_zmult_distrib zadd_zmult_distrib2
 11.1863 +  zdiff_zmult_distrib zdiff_zmult_distrib2
 11.1864 +
 11.1865 +lemmas zmult_1 = mult_1_left [of "z::int", standard]
 11.1866 +lemmas zmult_1_right = mult_1_right [of "z::int", standard]
 11.1867 +
 11.1868 +lemmas zle_refl = order_refl [of "w::int", standard]
 11.1869 +lemmas zle_trans = order_trans [where 'a=int and x="i" and y="j" and z="k", standard]
 11.1870 +lemmas zle_anti_sym = order_antisym [of "z::int" "w", standard]
 11.1871 +lemmas zle_linear = linorder_linear [of "z::int" "w", standard]
 11.1872 +lemmas zless_linear = linorder_less_linear [where 'a = int]
 11.1873 +
 11.1874 +lemmas zadd_left_mono = add_left_mono [of "i::int" "j" "k", standard]
 11.1875 +lemmas zadd_strict_right_mono = add_strict_right_mono [of "i::int" "j" "k", standard]
 11.1876 +lemmas zadd_zless_mono = add_less_le_mono [of "w'::int" "w" "z'" "z", standard]
 11.1877 +
 11.1878 +lemmas int_0_less_1 = zero_less_one [where 'a=int]
 11.1879 +lemmas int_0_neq_1 = zero_neq_one [where 'a=int]
 11.1880 +
 11.1881 +lemmas inj_int = inj_of_nat [where 'a=int]
 11.1882 +lemmas zadd_int = of_nat_add [where 'a=int, symmetric]
 11.1883 +lemmas int_mult = of_nat_mult [where 'a=int]
 11.1884 +lemmas zmult_int = of_nat_mult [where 'a=int, symmetric]
 11.1885 +lemmas int_eq_0_conv = of_nat_eq_0_iff [where 'a=int and m="n", standard]
 11.1886 +lemmas zless_int = of_nat_less_iff [where 'a=int]
 11.1887 +lemmas int_less_0_conv = of_nat_less_0_iff [where 'a=int and m="k", standard]
 11.1888 +lemmas zero_less_int_conv = of_nat_0_less_iff [where 'a=int]
 11.1889 +lemmas zero_zle_int = of_nat_0_le_iff [where 'a=int]
 11.1890 +lemmas int_le_0_conv = of_nat_le_0_iff [where 'a=int and m="n", standard]
 11.1891 +lemmas int_0 = of_nat_0 [where 'a=int]
 11.1892 +lemmas int_1 = of_nat_1 [where 'a=int]
 11.1893 +lemmas int_Suc = of_nat_Suc [where 'a=int]
 11.1894 +lemmas abs_int_eq = abs_of_nat [where 'a=int and n="m", standard]
 11.1895 +lemmas of_int_int_eq = of_int_of_nat_eq [where 'a=int]
 11.1896 +lemmas zdiff_int = of_nat_diff [where 'a=int, symmetric]
 11.1897 +lemmas zless_le = less_int_def
 11.1898 +lemmas int_eq_of_nat = TrueI
 11.1899 +
 11.1900 +end
    12.1 --- a/src/HOL/IntArith.thy	Tue Jan 15 16:19:21 2008 +0100
    12.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.3 @@ -1,422 +0,0 @@
    12.4 -(*  Title:      HOL/IntArith.thy
    12.5 -    ID:         $Id$
    12.6 -    Authors:    Larry Paulson and Tobias Nipkow
    12.7 -*)
    12.8 -
    12.9 -header {* Integer arithmetic *}
   12.10 -
   12.11 -theory IntArith
   12.12 -imports Numeral Wellfounded_Relations
   12.13 -uses
   12.14 -  "~~/src/Provers/Arith/assoc_fold.ML"
   12.15 -  "~~/src/Provers/Arith/cancel_numerals.ML"
   12.16 -  "~~/src/Provers/Arith/combine_numerals.ML"
   12.17 -  ("int_arith1.ML")
   12.18 -begin
   12.19 -
   12.20 -subsection{*Inequality Reasoning for the Arithmetic Simproc*}
   12.21 -
   12.22 -lemma add_numeral_0: "Numeral0 + a = (a::'a::number_ring)"
   12.23 -by simp 
   12.24 -
   12.25 -lemma add_numeral_0_right: "a + Numeral0 = (a::'a::number_ring)"
   12.26 -by simp
   12.27 -
   12.28 -lemma mult_numeral_1: "Numeral1 * a = (a::'a::number_ring)"
   12.29 -by simp 
   12.30 -
   12.31 -lemma mult_numeral_1_right: "a * Numeral1 = (a::'a::number_ring)"
   12.32 -by simp
   12.33 -
   12.34 -lemma divide_numeral_1: "a / Numeral1 = (a::'a::{number_ring,field})"
   12.35 -by simp
   12.36 -
   12.37 -lemma inverse_numeral_1:
   12.38 -  "inverse Numeral1 = (Numeral1::'a::{number_ring,field})"
   12.39 -by simp
   12.40 -
   12.41 -text{*Theorem lists for the cancellation simprocs. The use of binary numerals
   12.42 -for 0 and 1 reduces the number of special cases.*}
   12.43 -
   12.44 -lemmas add_0s = add_numeral_0 add_numeral_0_right
   12.45 -lemmas mult_1s = mult_numeral_1 mult_numeral_1_right 
   12.46 -                 mult_minus1 mult_minus1_right
   12.47 -
   12.48 -
   12.49 -subsection{*Special Arithmetic Rules for Abstract 0 and 1*}
   12.50 -
   12.51 -text{*Arithmetic computations are defined for binary literals, which leaves 0
   12.52 -and 1 as special cases. Addition already has rules for 0, but not 1.
   12.53 -Multiplication and unary minus already have rules for both 0 and 1.*}
   12.54 -
   12.55 -
   12.56 -lemma binop_eq: "[|f x y = g x y; x = x'; y = y'|] ==> f x' y' = g x' y'"
   12.57 -by simp
   12.58 -
   12.59 -
   12.60 -lemmas add_number_of_eq = number_of_add [symmetric]
   12.61 -
   12.62 -text{*Allow 1 on either or both sides*}
   12.63 -lemma one_add_one_is_two: "1 + 1 = (2::'a::number_ring)"
   12.64 -by (simp del: numeral_1_eq_1 add: numeral_1_eq_1 [symmetric] add_number_of_eq)
   12.65 -
   12.66 -lemmas add_special =
   12.67 -    one_add_one_is_two
   12.68 -    binop_eq [of "op +", OF add_number_of_eq numeral_1_eq_1 refl, standard]
   12.69 -    binop_eq [of "op +", OF add_number_of_eq refl numeral_1_eq_1, standard]
   12.70 -
   12.71 -text{*Allow 1 on either or both sides (1-1 already simplifies to 0)*}
   12.72 -lemmas diff_special =
   12.73 -    binop_eq [of "op -", OF diff_number_of_eq numeral_1_eq_1 refl, standard]
   12.74 -    binop_eq [of "op -", OF diff_number_of_eq refl numeral_1_eq_1, standard]
   12.75 -
   12.76 -text{*Allow 0 or 1 on either side with a binary numeral on the other*}
   12.77 -lemmas eq_special =
   12.78 -    binop_eq [of "op =", OF eq_number_of_eq numeral_0_eq_0 refl, standard]
   12.79 -    binop_eq [of "op =", OF eq_number_of_eq numeral_1_eq_1 refl, standard]
   12.80 -    binop_eq [of "op =", OF eq_number_of_eq refl numeral_0_eq_0, standard]
   12.81 -    binop_eq [of "op =", OF eq_number_of_eq refl numeral_1_eq_1, standard]
   12.82 -
   12.83 -text{*Allow 0 or 1 on either side with a binary numeral on the other*}
   12.84 -lemmas less_special =
   12.85 -  binop_eq [of "op <", OF less_number_of_eq_neg numeral_0_eq_0 refl, standard]
   12.86 -  binop_eq [of "op <", OF less_number_of_eq_neg numeral_1_eq_1 refl, standard]
   12.87 -  binop_eq [of "op <", OF less_number_of_eq_neg refl numeral_0_eq_0, standard]
   12.88 -  binop_eq [of "op <", OF less_number_of_eq_neg refl numeral_1_eq_1, standard]
   12.89 -
   12.90 -text{*Allow 0 or 1 on either side with a binary numeral on the other*}
   12.91 -lemmas le_special =
   12.92 -    binop_eq [of "op \<le>", OF le_number_of_eq numeral_0_eq_0 refl, standard]
   12.93 -    binop_eq [of "op \<le>", OF le_number_of_eq numeral_1_eq_1 refl, standard]
   12.94 -    binop_eq [of "op \<le>", OF le_number_of_eq refl numeral_0_eq_0, standard]
   12.95 -    binop_eq [of "op \<le>", OF le_number_of_eq refl numeral_1_eq_1, standard]
   12.96 -
   12.97 -lemmas arith_special[simp] = 
   12.98 -       add_special diff_special eq_special less_special le_special
   12.99 -
  12.100 -
  12.101 -lemma min_max_01: "min (0::int) 1 = 0 & min (1::int) 0 = 0 &
  12.102 -                   max (0::int) 1 = 1 & max (1::int) 0 = 1"
  12.103 -by(simp add:min_def max_def)
  12.104 -
  12.105 -lemmas min_max_special[simp] =
  12.106 - min_max_01
  12.107 - max_def[of "0::int" "number_of v", standard, simp]
  12.108 - min_def[of "0::int" "number_of v", standard, simp]
  12.109 - max_def[of "number_of u" "0::int", standard, simp]
  12.110 - min_def[of "number_of u" "0::int", standard, simp]
  12.111 - max_def[of "1::int" "number_of v", standard, simp]
  12.112 - min_def[of "1::int" "number_of v", standard, simp]
  12.113 - max_def[of "number_of u" "1::int", standard, simp]
  12.114 - min_def[of "number_of u" "1::int", standard, simp]
  12.115 -
  12.116 -use "int_arith1.ML"
  12.117 -declaration {* K int_arith_setup *}
  12.118 -
  12.119 -
  12.120 -subsection{*Lemmas About Small Numerals*}
  12.121 -
  12.122 -lemma of_int_m1 [simp]: "of_int -1 = (-1 :: 'a :: number_ring)"
  12.123 -proof -
  12.124 -  have "(of_int -1 :: 'a) = of_int (- 1)" by simp
  12.125 -  also have "... = - of_int 1" by (simp only: of_int_minus)
  12.126 -  also have "... = -1" by simp
  12.127 -  finally show ?thesis .
  12.128 -qed
  12.129 -
  12.130 -lemma abs_minus_one [simp]: "abs (-1) = (1::'a::{ordered_idom,number_ring})"
  12.131 -by (simp add: abs_if)
  12.132 -
  12.133 -lemma abs_power_minus_one [simp]:
  12.134 -     "abs(-1 ^ n) = (1::'a::{ordered_idom,number_ring,recpower})"
  12.135 -by (simp add: power_abs)
  12.136 -
  12.137 -lemma of_int_number_of_eq:
  12.138 -     "of_int (number_of v) = (number_of v :: 'a :: number_ring)"
  12.139 -by (simp add: number_of_eq) 
  12.140 -
  12.141 -text{*Lemmas for specialist use, NOT as default simprules*}
  12.142 -lemma mult_2: "2 * z = (z+z::'a::number_ring)"
  12.143 -proof -
  12.144 -  have "2*z = (1 + 1)*z" by simp
  12.145 -  also have "... = z+z" by (simp add: left_distrib)
  12.146 -  finally show ?thesis .
  12.147 -qed
  12.148 -
  12.149 -lemma mult_2_right: "z * 2 = (z+z::'a::number_ring)"
  12.150 -by (subst mult_commute, rule mult_2)
  12.151 -
  12.152 -
  12.153 -subsection{*More Inequality Reasoning*}
  12.154 -
  12.155 -lemma zless_add1_eq: "(w < z + (1::int)) = (w<z | w=z)"
  12.156 -by arith
  12.157 -
  12.158 -lemma add1_zle_eq: "(w + (1::int) \<le> z) = (w<z)"
  12.159 -by arith
  12.160 -
  12.161 -lemma zle_diff1_eq [simp]: "(w \<le> z - (1::int)) = (w<z)"
  12.162 -by arith
  12.163 -
  12.164 -lemma zle_add1_eq_le [simp]: "(w < z + (1::int)) = (w\<le>z)"
  12.165 -by arith
  12.166 -
  12.167 -lemma int_one_le_iff_zero_less: "((1::int) \<le> z) = (0 < z)"
  12.168 -by arith
  12.169 -
  12.170 -
  12.171 -subsection{*The Functions @{term nat} and @{term int}*}
  12.172 -
  12.173 -text{*Simplify the terms @{term "int 0"}, @{term "int(Suc 0)"} and
  12.174 -  @{term "w + - z"}*}
  12.175 -declare Zero_int_def [symmetric, simp]
  12.176 -declare One_int_def [symmetric, simp]
  12.177 -
  12.178 -lemmas diff_int_def_symmetric = diff_int_def [symmetric, simp]
  12.179 -
  12.180 -lemma nat_0: "nat 0 = 0"
  12.181 -by (simp add: nat_eq_iff)
  12.182 -
  12.183 -lemma nat_1: "nat 1 = Suc 0"
  12.184 -by (subst nat_eq_iff, simp)
  12.185 -
  12.186 -lemma nat_2: "nat 2 = Suc (Suc 0)"
  12.187 -by (subst nat_eq_iff, simp)
  12.188 -
  12.189 -lemma one_less_nat_eq [simp]: "(Suc 0 < nat z) = (1 < z)"
  12.190 -apply (insert zless_nat_conj [of 1 z])
  12.191 -apply (auto simp add: nat_1)
  12.192 -done
  12.193 -
  12.194 -text{*This simplifies expressions of the form @{term "int n = z"} where
  12.195 -      z is an integer literal.*}
  12.196 -lemmas int_eq_iff_number_of [simp] = int_eq_iff [of _ "number_of v", standard]
  12.197 -
  12.198 -lemma split_nat [arith_split]:
  12.199 -  "P(nat(i::int)) = ((\<forall>n. i = int n \<longrightarrow> P n) & (i < 0 \<longrightarrow> P 0))"
  12.200 -  (is "?P = (?L & ?R)")
  12.201 -proof (cases "i < 0")
  12.202 -  case True thus ?thesis by auto
  12.203 -next
  12.204 -  case False
  12.205 -  have "?P = ?L"
  12.206 -  proof
  12.207 -    assume ?P thus ?L using False by clarsimp
  12.208 -  next
  12.209 -    assume ?L thus ?P using False by simp
  12.210 -  qed
  12.211 -  with False show ?thesis by simp
  12.212 -qed
  12.213 -
  12.214 -context ring_1
  12.215 -begin
  12.216 -
  12.217 -lemma of_int_of_nat:
  12.218 -  "of_int k = (if k < 0 then - of_nat (nat (- k)) else of_nat (nat k))"
  12.219 -proof (cases "k < 0")
  12.220 -  case True then have "0 \<le> - k" by simp
  12.221 -  then have "of_nat (nat (- k)) = of_int (- k)" by (rule of_nat_nat)
  12.222 -  with True show ?thesis by simp
  12.223 -next
  12.224 -  case False then show ?thesis by (simp add: not_less of_nat_nat)
  12.225 -qed
  12.226 -
  12.227 -end
  12.228 -
  12.229 -lemma nat_mult_distrib: "(0::int) \<le> z ==> nat (z*z') = nat z * nat z'"
  12.230 -apply (cases "0 \<le> z'")
  12.231 -apply (rule inj_int [THEN injD])
  12.232 -apply (simp add: int_mult zero_le_mult_iff)
  12.233 -apply (simp add: mult_le_0_iff)
  12.234 -done
  12.235 -
  12.236 -lemma nat_mult_distrib_neg: "z \<le> (0::int) ==> nat(z*z') = nat(-z) * nat(-z')"
  12.237 -apply (rule trans)
  12.238 -apply (rule_tac [2] nat_mult_distrib, auto)
  12.239 -done
  12.240 -
  12.241 -lemma nat_abs_mult_distrib: "nat (abs (w * z)) = nat (abs w) * nat (abs z)"
  12.242 -apply (cases "z=0 | w=0")
  12.243 -apply (auto simp add: abs_if nat_mult_distrib [symmetric] 
  12.244 -                      nat_mult_distrib_neg [symmetric] mult_less_0_iff)
  12.245 -done
  12.246 -
  12.247 -
  12.248 -subsection "Induction principles for int"
  12.249 -
  12.250 -text{*Well-founded segments of the integers*}
  12.251 -
  12.252 -definition
  12.253 -  int_ge_less_than  ::  "int => (int * int) set"
  12.254 -where
  12.255 -  "int_ge_less_than d = {(z',z). d \<le> z' & z' < z}"
  12.256 -
  12.257 -theorem wf_int_ge_less_than: "wf (int_ge_less_than d)"
  12.258 -proof -
  12.259 -  have "int_ge_less_than d \<subseteq> measure (%z. nat (z-d))"
  12.260 -    by (auto simp add: int_ge_less_than_def)
  12.261 -  thus ?thesis 
  12.262 -    by (rule wf_subset [OF wf_measure]) 
  12.263 -qed
  12.264 -
  12.265 -text{*This variant looks odd, but is typical of the relations suggested
  12.266 -by RankFinder.*}
  12.267 -
  12.268 -definition
  12.269 -  int_ge_less_than2 ::  "int => (int * int) set"
  12.270 -where
  12.271 -  "int_ge_less_than2 d = {(z',z). d \<le> z & z' < z}"
  12.272 -
  12.273 -theorem wf_int_ge_less_than2: "wf (int_ge_less_than2 d)"
  12.274 -proof -
  12.275 -  have "int_ge_less_than2 d \<subseteq> measure (%z. nat (1+z-d))" 
  12.276 -    by (auto simp add: int_ge_less_than2_def)
  12.277 -  thus ?thesis 
  12.278 -    by (rule wf_subset [OF wf_measure]) 
  12.279 -qed
  12.280 -
  12.281 -(* `set:int': dummy construction *)
  12.282 -theorem int_ge_induct [case_names base step, induct set:int]:
  12.283 -  fixes i :: int
  12.284 -  assumes ge: "k \<le> i" and
  12.285 -    base: "P k" and
  12.286 -    step: "\<And>i. k \<le> i \<Longrightarrow> P i \<Longrightarrow> P (i + 1)"
  12.287 -  shows "P i"
  12.288 -proof -
  12.289 -  { fix n have "\<And>i::int. n = nat(i-k) \<Longrightarrow> k \<le> i \<Longrightarrow> P i"
  12.290 -    proof (induct n)
  12.291 -      case 0
  12.292 -      hence "i = k" by arith
  12.293 -      thus "P i" using base by simp
  12.294 -    next
  12.295 -      case (Suc n)
  12.296 -      then have "n = nat((i - 1) - k)" by arith
  12.297 -      moreover
  12.298 -      have ki1: "k \<le> i - 1" using Suc.prems by arith
  12.299 -      ultimately
  12.300 -      have "P(i - 1)" by(rule Suc.hyps)
  12.301 -      from step[OF ki1 this] show ?case by simp
  12.302 -    qed
  12.303 -  }
  12.304 -  with ge show ?thesis by fast
  12.305 -qed
  12.306 -
  12.307 -                     (* `set:int': dummy construction *)
  12.308 -theorem int_gr_induct[case_names base step,induct set:int]:
  12.309 -  assumes gr: "k < (i::int)" and
  12.310 -        base: "P(k+1)" and
  12.311 -        step: "\<And>i. \<lbrakk>k < i; P i\<rbrakk> \<Longrightarrow> P(i+1)"
  12.312 -  shows "P i"
  12.313 -apply(rule int_ge_induct[of "k + 1"])
  12.314 -  using gr apply arith
  12.315 - apply(rule base)
  12.316 -apply (rule step, simp+)
  12.317 -done
  12.318 -
  12.319 -theorem int_le_induct[consumes 1,case_names base step]:
  12.320 -  assumes le: "i \<le> (k::int)" and
  12.321 -        base: "P(k)" and
  12.322 -        step: "\<And>i. \<lbrakk>i \<le> k; P i\<rbrakk> \<Longrightarrow> P(i - 1)"
  12.323 -  shows "P i"
  12.324 -proof -
  12.325 -  { fix n have "\<And>i::int. n = nat(k-i) \<Longrightarrow> i \<le> k \<Longrightarrow> P i"
  12.326 -    proof (induct n)
  12.327 -      case 0
  12.328 -      hence "i = k" by arith
  12.329 -      thus "P i" using base by simp
  12.330 -    next
  12.331 -      case (Suc n)
  12.332 -      hence "n = nat(k - (i+1))" by arith
  12.333 -      moreover
  12.334 -      have ki1: "i + 1 \<le> k" using Suc.prems by arith
  12.335 -      ultimately
  12.336 -      have "P(i+1)" by(rule Suc.hyps)
  12.337 -      from step[OF ki1 this] show ?case by simp
  12.338 -    qed
  12.339 -  }
  12.340 -  with le show ?thesis by fast
  12.341 -qed
  12.342 -
  12.343 -theorem int_less_induct [consumes 1,case_names base step]:
  12.344 -  assumes less: "(i::int) < k" and
  12.345 -        base: "P(k - 1)" and
  12.346 -        step: "\<And>i. \<lbrakk>i < k; P i\<rbrakk> \<Longrightarrow> P(i - 1)"
  12.347 -  shows "P i"
  12.348 -apply(rule int_le_induct[of _ "k - 1"])
  12.349 -  using less apply arith
  12.350 - apply(rule base)
  12.351 -apply (rule step, simp+)
  12.352 -done
  12.353 -
  12.354 -subsection{*Intermediate value theorems*}
  12.355 -
  12.356 -lemma int_val_lemma:
  12.357 -     "(\<forall>i<n::nat. abs(f(i+1) - f i) \<le> 1) -->  
  12.358 -      f 0 \<le> k --> k \<le> f n --> (\<exists>i \<le> n. f i = (k::int))"
  12.359 -apply (induct_tac "n", simp)
  12.360 -apply (intro strip)
  12.361 -apply (erule impE, simp)
  12.362 -apply (erule_tac x = n in allE, simp)
  12.363 -apply (case_tac "k = f (n+1) ")
  12.364 - apply force
  12.365 -apply (erule impE)
  12.366 - apply (simp add: abs_if split add: split_if_asm)
  12.367 -apply (blast intro: le_SucI)
  12.368 -done
  12.369 -
  12.370 -lemmas nat0_intermed_int_val = int_val_lemma [rule_format (no_asm)]
  12.371 -
  12.372 -lemma nat_intermed_int_val:
  12.373 -     "[| \<forall>i. m \<le> i & i < n --> abs(f(i + 1::nat) - f i) \<le> 1; m < n;  
  12.374 -         f m \<le> k; k \<le> f n |] ==> ? i. m \<le> i & i \<le> n & f i = (k::int)"
  12.375 -apply (cut_tac n = "n-m" and f = "%i. f (i+m) " and k = k 
  12.376 -       in int_val_lemma)
  12.377 -apply simp
  12.378 -apply (erule exE)
  12.379 -apply (rule_tac x = "i+m" in exI, arith)
  12.380 -done
  12.381 -
  12.382 -
  12.383 -subsection{*Products and 1, by T. M. Rasmussen*}
  12.384 -
  12.385 -lemma zabs_less_one_iff [simp]: "(\<bar>z\<bar> < 1) = (z = (0::int))"
  12.386 -by arith
  12.387 -
  12.388 -lemma abs_zmult_eq_1: "(\<bar>m * n\<bar> = 1) ==> \<bar>m\<bar> = (1::int)"
  12.389 -apply (cases "\<bar>n\<bar>=1") 
  12.390 -apply (simp add: abs_mult) 
  12.391 -apply (rule ccontr) 
  12.392 -apply (auto simp add: linorder_neq_iff abs_mult) 
  12.393 -apply (subgoal_tac "2 \<le> \<bar>m\<bar> & 2 \<le> \<bar>n\<bar>")
  12.394 - prefer 2 apply arith 
  12.395 -apply (subgoal_tac "2*2 \<le> \<bar>m\<bar> * \<bar>n\<bar>", simp) 
  12.396 -apply (rule mult_mono, auto) 
  12.397 -done
  12.398 -
  12.399 -lemma pos_zmult_eq_1_iff_lemma: "(m * n = 1) ==> m = (1::int) | m = -1"
  12.400 -by (insert abs_zmult_eq_1 [of m n], arith)
  12.401 -
  12.402 -lemma pos_zmult_eq_1_iff: "0 < (m::int) ==> (m * n = 1) = (m = 1 & n = 1)"
  12.403 -apply (auto dest: pos_zmult_eq_1_iff_lemma) 
  12.404 -apply (simp add: mult_commute [of m]) 
  12.405 -apply (frule pos_zmult_eq_1_iff_lemma, auto) 
  12.406 -done
  12.407 -
  12.408 -lemma zmult_eq_1_iff: "(m*n = (1::int)) = ((m = 1 & n = 1) | (m = -1 & n = -1))"
  12.409 -apply (rule iffI) 
  12.410 - apply (frule pos_zmult_eq_1_iff_lemma)
  12.411 - apply (simp add: mult_commute [of m]) 
  12.412 - apply (frule pos_zmult_eq_1_iff_lemma, auto) 
  12.413 -done
  12.414 -
  12.415 -(* Could be simplified but Presburger only becomes available too late *)
  12.416 -lemma infinite_UNIV_int: "~finite(UNIV::int set)"
  12.417 -proof
  12.418 -  assume "finite(UNIV::int set)"
  12.419 -  moreover have "~(EX i::int. 2*i = 1)"
  12.420 -    by (auto simp: pos_zmult_eq_1_iff)
  12.421 -  ultimately show False using finite_UNIV_inj_surj[of "%n::int. n+n"]
  12.422 -    by (simp add:inj_on_def surj_def) (blast intro:sym)
  12.423 -qed
  12.424 -
  12.425 -end
    13.1 --- a/src/HOL/IntDef.thy	Tue Jan 15 16:19:21 2008 +0100
    13.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.3 @@ -1,773 +0,0 @@
    13.4 -(*  Title:      IntDef.thy
    13.5 -    ID:         $Id$
    13.6 -    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
    13.7 -    Copyright   1996  University of Cambridge
    13.8 -
    13.9 -*)
   13.10 -
   13.11 -header{*The Integers as Equivalence Classes over Pairs of Natural Numbers*} 
   13.12 -
   13.13 -theory IntDef
   13.14 -imports Equiv_Relations Nat
   13.15 -begin
   13.16 -
   13.17 -text {* the equivalence relation underlying the integers *}
   13.18 -
   13.19 -definition
   13.20 -  intrel :: "((nat \<times> nat) \<times> (nat \<times> nat)) set"
   13.21 -where
   13.22 -  "intrel = {((x, y), (u, v)) | x y u v. x + v = u +y }"
   13.23 -
   13.24 -typedef (Integ)
   13.25 -  int = "UNIV//intrel"
   13.26 -  by (auto simp add: quotient_def)
   13.27 -
   13.28 -instantiation int :: "{zero, one, plus, minus, uminus, times, ord, abs, sgn}"
   13.29 -begin
   13.30 -
   13.31 -definition
   13.32 -  Zero_int_def [code func del]: "0 = Abs_Integ (intrel `` {(0, 0)})"
   13.33 -
   13.34 -definition
   13.35 -  One_int_def [code func del]: "1 = Abs_Integ (intrel `` {(1, 0)})"
   13.36 -
   13.37 -definition
   13.38 -  add_int_def [code func del]: "z + w = Abs_Integ
   13.39 -    (\<Union>(x, y) \<in> Rep_Integ z. \<Union>(u, v) \<in> Rep_Integ w.
   13.40 -      intrel `` {(x + u, y + v)})"
   13.41 -
   13.42 -definition
   13.43 -  minus_int_def [code func del]:
   13.44 -    "- z = Abs_Integ (\<Union>(x, y) \<in> Rep_Integ z. intrel `` {(y, x)})"
   13.45 -
   13.46 -definition
   13.47 -  diff_int_def [code func del]:  "z - w = z + (-w \<Colon> int)"
   13.48 -
   13.49 -definition
   13.50 -  mult_int_def [code func del]: "z * w = Abs_Integ
   13.51 -    (\<Union>(x, y) \<in> Rep_Integ z. \<Union>(u,v ) \<in> Rep_Integ w.
   13.52 -      intrel `` {(x*u + y*v, x*v + y*u)})"
   13.53 -
   13.54 -definition
   13.55 -  le_int_def [code func del]:
   13.56 -   "z \<le> w \<longleftrightarrow> (\<exists>x y u v. x+v \<le> u+y \<and> (x, y) \<in> Rep_Integ z \<and> (u, v) \<in> Rep_Integ w)"
   13.57 -
   13.58 -definition
   13.59 -  less_int_def [code func del]: "(z\<Colon>int) < w \<longleftrightarrow> z \<le> w \<and> z \<noteq> w"
   13.60 -
   13.61 -definition
   13.62 -  zabs_def: "\<bar>i\<Colon>int\<bar> = (if i < 0 then - i else i)"
   13.63 -
   13.64 -definition
   13.65 -  zsgn_def: "sgn (i\<Colon>int) = (if i=0 then 0 else if 0<i then 1 else - 1)"
   13.66 -
   13.67 -instance ..
   13.68 -
   13.69 -end
   13.70 -
   13.71 -
   13.72 -subsection{*Construction of the Integers*}
   13.73 -
   13.74 -lemma intrel_iff [simp]: "(((x,y),(u,v)) \<in> intrel) = (x+v = u+y)"
   13.75 -by (simp add: intrel_def)
   13.76 -
   13.77 -lemma equiv_intrel: "equiv UNIV intrel"
   13.78 -by (simp add: intrel_def equiv_def refl_def sym_def trans_def)
   13.79 -
   13.80 -text{*Reduces equality of equivalence classes to the @{term intrel} relation:
   13.81 -  @{term "(intrel `` {x} = intrel `` {y}) = ((x,y) \<in> intrel)"} *}
   13.82 -lemmas equiv_intrel_iff [simp] = eq_equiv_class_iff [OF equiv_intrel UNIV_I UNIV_I]
   13.83 -
   13.84 -text{*All equivalence classes belong to set of representatives*}
   13.85 -lemma [simp]: "intrel``{(x,y)} \<in> Integ"
   13.86 -by (auto simp add: Integ_def intrel_def quotient_def)
   13.87 -
   13.88 -text{*Reduces equality on abstractions to equality on representatives:
   13.89 -  @{prop "\<lbrakk>x \<in> Integ; y \<in> Integ\<rbrakk> \<Longrightarrow> (Abs_Integ x = Abs_Integ y) = (x=y)"} *}
   13.90 -declare Abs_Integ_inject [simp,noatp]  Abs_Integ_inverse [simp,noatp]
   13.91 -
   13.92 -text{*Case analysis on the representation of an integer as an equivalence
   13.93 -      class of pairs of naturals.*}
   13.94 -lemma eq_Abs_Integ [case_names Abs_Integ, cases type: int]:
   13.95 -     "(!!x y. z = Abs_Integ(intrel``{(x,y)}) ==> P) ==> P"
   13.96 -apply (rule Abs_Integ_cases [of z]) 
   13.97 -apply (auto simp add: Integ_def quotient_def) 
   13.98 -done
   13.99 -
  13.100 -
  13.101 -subsection{*Arithmetic Operations*}
  13.102 -
  13.103 -lemma minus: "- Abs_Integ(intrel``{(x,y)}) = Abs_Integ(intrel `` {(y,x)})"
  13.104 -proof -
  13.105 -  have "(\<lambda>(x,y). intrel``{(y,x)}) respects intrel"
  13.106 -    by (simp add: congruent_def) 
  13.107 -  thus ?thesis
  13.108 -    by (simp add: minus_int_def UN_equiv_class [OF equiv_intrel])
  13.109 -qed
  13.110 -
  13.111 -lemma add:
  13.112 -     "Abs_Integ (intrel``{(x,y)}) + Abs_Integ (intrel``{(u,v)}) =
  13.113 -      Abs_Integ (intrel``{(x+u, y+v)})"
  13.114 -proof -
  13.115 -  have "(\<lambda>z w. (\<lambda>(x,y). (\<lambda>(u,v). intrel `` {(x+u, y+v)}) w) z) 
  13.116 -        respects2 intrel"
  13.117 -    by (simp add: congruent2_def)
  13.118 -  thus ?thesis
  13.119 -    by (simp add: add_int_def UN_UN_split_split_eq
  13.120 -                  UN_equiv_class2 [OF equiv_intrel equiv_intrel])
  13.121 -qed
  13.122 -
  13.123 -text{*Congruence property for multiplication*}
  13.124 -lemma mult_congruent2:
  13.125 -     "(%p1 p2. (%(x,y). (%(u,v). intrel``{(x*u + y*v, x*v + y*u)}) p2) p1)
  13.126 -      respects2 intrel"
  13.127 -apply (rule equiv_intrel [THEN congruent2_commuteI])
  13.128 - apply (force simp add: mult_ac, clarify) 
  13.129 -apply (simp add: congruent_def mult_ac)  
  13.130 -apply (rename_tac u v w x y z)
  13.131 -apply (subgoal_tac "u*y + x*y = w*y + v*y  &  u*z + x*z = w*z + v*z")
  13.132 -apply (simp add: mult_ac)
  13.133 -apply (simp add: add_mult_distrib [symmetric])
  13.134 -done
  13.135 -
  13.136 -lemma mult:
  13.137 -     "Abs_Integ((intrel``{(x,y)})) * Abs_Integ((intrel``{(u,v)})) =
  13.138 -      Abs_Integ(intrel `` {(x*u + y*v, x*v + y*u)})"
  13.139 -by (simp add: mult_int_def UN_UN_split_split_eq mult_congruent2
  13.140 -              UN_equiv_class2 [OF equiv_intrel equiv_intrel])
  13.141 -
  13.142 -text{*The integers form a @{text comm_ring_1}*}
  13.143 -instance int :: comm_ring_1
  13.144 -proof
  13.145 -  fix i j k :: int
  13.146 -  show "(i + j) + k = i + (j + k)"
  13.147 -    by (cases i, cases j, cases k) (simp add: add add_assoc)
  13.148 -  show "i + j = j + i" 
  13.149 -    by (cases i, cases j) (simp add: add_ac add)
  13.150 -  show "0 + i = i"
  13.151 -    by (cases i) (simp add: Zero_int_def add)
  13.152 -  show "- i + i = 0"
  13.153 -    by (cases i) (simp add: Zero_int_def minus add)
  13.154 -  show "i - j = i + - j"
  13.155 -    by (simp add: diff_int_def)
  13.156 -  show "(i * j) * k = i * (j * k)"
  13.157 -    by (cases i, cases j, cases k) (simp add: mult ring_simps)
  13.158 -  show "i * j = j * i"
  13.159 -    by (cases i, cases j) (simp add: mult ring_simps)
  13.160 -  show "1 * i = i"
  13.161 -    by (cases i) (simp add: One_int_def mult)
  13.162 -  show "(i + j) * k = i * k + j * k"
  13.163 -    by (cases i, cases j, cases k) (simp add: add mult ring_simps)
  13.164 -  show "0 \<noteq> (1::int)"
  13.165 -    by (simp add: Zero_int_def One_int_def)
  13.166 -qed
  13.167 -
  13.168 -lemma int_def: "of_nat m = Abs_Integ (intrel `` {(m, 0)})"
  13.169 -by (induct m, simp_all add: Zero_int_def One_int_def add)
  13.170 -
  13.171 -
  13.172 -subsection{*The @{text "\<le>"} Ordering*}
  13.173 -
  13.174 -lemma le:
  13.175 -  "(Abs_Integ(intrel``{(x,y)}) \<le> Abs_Integ(intrel``{(u,v)})) = (x+v \<le> u+y)"
  13.176 -by (force simp add: le_int_def)
  13.177 -
  13.178 -lemma less:
  13.179 -  "(Abs_Integ(intrel``{(x,y)}) < Abs_Integ(intrel``{(u,v)})) = (x+v < u+y)"
  13.180 -by (simp add: less_int_def le order_less_le)
  13.181 -
  13.182 -instance int :: linorder
  13.183 -proof
  13.184 -  fix i j k :: int
  13.185 -  show "(i < j) = (i \<le> j \<and> i \<noteq> j)"
  13.186 -    by (simp add: less_int_def)
  13.187 -  show "i \<le> i"
  13.188 -    by (cases i) (simp add: le)
  13.189 -  show "i \<le> j \<Longrightarrow> j \<le> k \<Longrightarrow> i \<le> k"
  13.190 -    by (cases i, cases j, cases k) (simp add: le)
  13.191 -  show "i \<le> j \<Longrightarrow> j \<le> i \<Longrightarrow> i = j"
  13.192 -    by (cases i, cases j) (simp add: le)
  13.193 -  show "i \<le> j \<or> j \<le> i"
  13.194 -    by (cases i, cases j) (simp add: le linorder_linear)
  13.195 -qed
  13.196 -
  13.197 -instance int :: pordered_cancel_ab_semigroup_add
  13.198 -proof
  13.199 -  fix i j k :: int
  13.200 -  show "i \<le> j \<Longrightarrow> k + i \<le> k + j"
  13.201 -    by (cases i, cases j, cases k) (simp add: le add)
  13.202 -qed
  13.203 -
  13.204 -text{*Strict Monotonicity of Multiplication*}
  13.205 -
  13.206 -text{*strict, in 1st argument; proof is by induction on k>0*}
  13.207 -lemma zmult_zless_mono2_lemma:
  13.208 -     "(i::int)<j ==> 0<k ==> of_nat k * i < of_nat k * j"
  13.209 -apply (induct "k", simp)
  13.210 -apply (simp add: left_distrib)
  13.211 -apply (case_tac "k=0")
  13.212 -apply (simp_all add: add_strict_mono)
  13.213 -done
  13.214 -
  13.215 -lemma zero_le_imp_eq_int: "(0::int) \<le> k ==> \<exists>n. k = of_nat n"
  13.216 -apply (cases k)
  13.217 -apply (auto simp add: le add int_def Zero_int_def)
  13.218 -apply (rule_tac x="x-y" in exI, simp)
  13.219 -done
  13.220 -
  13.221 -lemma zero_less_imp_eq_int: "(0::int) < k ==> \<exists>n>0. k = of_nat n"
  13.222 -apply (cases k)
  13.223 -apply (simp add: less int_def Zero_int_def)
  13.224 -apply (rule_tac x="x-y" in exI, simp)
  13.225 -done
  13.226 -
  13.227 -lemma zmult_zless_mono2: "[| i<j;  (0::int) < k |] ==> k*i < k*j"
  13.228 -apply (drule zero_less_imp_eq_int)
  13.229 -apply (auto simp add: zmult_zless_mono2_lemma)
  13.230 -done
  13.231 -
  13.232 -instantiation int :: distrib_lattice
  13.233 -begin
  13.234 -
  13.235 -definition
  13.236 -  "(inf \<Colon> int \<Rightarrow> int \<Rightarrow> int) = min"
  13.237 -
  13.238 -definition
  13.239 -  "(sup \<Colon> int \<Rightarrow> int \<Rightarrow> int) = max"
  13.240 -
  13.241 -instance
  13.242 -  by intro_classes
  13.243 -    (auto simp add: inf_int_def sup_int_def min_max.sup_inf_distrib1)
  13.244 -
  13.245 -end
  13.246 -
  13.247 -text{*The integers form an ordered integral domain*}
  13.248 -instance int :: ordered_idom
  13.249 -proof
  13.250 -  fix i j k :: int
  13.251 -  show "i < j \<Longrightarrow> 0 < k \<Longrightarrow> k * i < k * j"
  13.252 -    by (rule zmult_zless_mono2)
  13.253 -  show "\<bar>i\<bar> = (if i < 0 then -i else i)"
  13.254 -    by (simp only: zabs_def)
  13.255 -  show "sgn(i\<Colon>int) = (if i=0 then 0 else if 0<i then 1 else - 1)"
  13.256 -    by (simp only: zsgn_def)
  13.257 -qed
  13.258 -
  13.259 -lemma zless_imp_add1_zle: "w<z ==> w + (1::int) \<le> z"
  13.260 -apply (cases w, cases z) 
  13.261 -apply (simp add: less le add One_int_def)
  13.262 -done
  13.263 -
  13.264 -
  13.265 -subsection{*Magnitude of an Integer, as a Natural Number: @{term nat}*}
  13.266 -
  13.267 -definition
  13.268 -  nat :: "int \<Rightarrow> nat"
  13.269 -where
  13.270 -  [code func del]: "nat z = contents (\<Union>(x, y) \<in> Rep_Integ z. {x-y})"
  13.271 -
  13.272 -lemma nat: "nat (Abs_Integ (intrel``{(x,y)})) = x-y"
  13.273 -proof -
  13.274 -  have "(\<lambda>(x,y). {x-y}) respects intrel"
  13.275 -    by (simp add: congruent_def) arith
  13.276 -  thus ?thesis
  13.277 -    by (simp add: nat_def UN_equiv_class [OF equiv_intrel])
  13.278 -qed
  13.279 -
  13.280 -lemma nat_int [simp]: "nat (of_nat n) = n"
  13.281 -by (simp add: nat int_def)
  13.282 -
  13.283 -lemma nat_zero [simp]: "nat 0 = 0"
  13.284 -by (simp add: Zero_int_def nat)
  13.285 -
  13.286 -lemma int_nat_eq [simp]: "of_nat (nat z) = (if 0 \<le> z then z else 0)"
  13.287 -by (cases z, simp add: nat le int_def Zero_int_def)
  13.288 -
  13.289 -corollary nat_0_le: "0 \<le> z ==> of_nat (nat z) = z"
  13.290 -by simp
  13.291 -
  13.292 -lemma nat_le_0 [simp]: "z \<le> 0 ==> nat z = 0"
  13.293 -by (cases z, simp add: nat le Zero_int_def)
  13.294 -
  13.295 -lemma nat_le_eq_zle: "0 < w | 0 \<le> z ==> (nat w \<le> nat z) = (w\<le>z)"
  13.296 -apply (cases w, cases z) 
  13.297 -apply (simp add: nat le linorder_not_le [symmetric] Zero_int_def, arith)
  13.298 -done
  13.299 -
  13.300 -text{*An alternative condition is @{term "0 \<le> w"} *}
  13.301 -corollary nat_mono_iff: "0 < z ==> (nat w < nat z) = (w < z)"
  13.302 -by (simp add: nat_le_eq_zle linorder_not_le [symmetric]) 
  13.303 -
  13.304 -corollary nat_less_eq_zless: "0 \<le> w ==> (nat w < nat z) = (w<z)"
  13.305 -by (simp add: nat_le_eq_zle linorder_not_le [symmetric]) 
  13.306 -
  13.307 -lemma zless_nat_conj [simp]: "(nat w < nat z) = (0 < z & w < z)"
  13.308 -apply (cases w, cases z) 
  13.309 -apply (simp add: nat le Zero_int_def linorder_not_le [symmetric], arith)
  13.310 -done
  13.311 -
  13.312 -lemma nonneg_eq_int:
  13.313 -  fixes z :: int
  13.314 -  assumes "0 \<le> z" and "\<And>m. z = of_nat m \<Longrightarrow> P"
  13.315 -  shows P
  13.316 -  using assms by (blast dest: nat_0_le sym)
  13.317 -
  13.318 -lemma nat_eq_iff: "(nat w = m) = (if 0 \<le> w then w = of_nat m else m=0)"
  13.319 -by (cases w, simp add: nat le int_def Zero_int_def, arith)
  13.320 -
  13.321 -corollary nat_eq_iff2: "(m = nat w) = (if 0 \<le> w then w = of_nat m else m=0)"
  13.322 -by (simp only: eq_commute [of m] nat_eq_iff)
  13.323 -
  13.324 -lemma nat_less_iff: "0 \<le> w ==> (nat w < m) = (w < of_nat m)"
  13.325 -apply (cases w)
  13.326 -apply (simp add: nat le int_def Zero_int_def linorder_not_le [symmetric], arith)
  13.327 -done
  13.328 -
  13.329 -lemma int_eq_iff: "(of_nat m = z) = (m = nat z & 0 \<le> z)"
  13.330 -by (auto simp add: nat_eq_iff2)
  13.331 -
  13.332 -lemma zero_less_nat_eq [simp]: "(0 < nat z) = (0 < z)"
  13.333 -by (insert zless_nat_conj [of 0], auto)
  13.334 -
  13.335 -lemma nat_add_distrib:
  13.336 -     "[| (0::int) \<le> z;  0 \<le> z' |] ==> nat (z+z') = nat z + nat z'"
  13.337 -by (cases z, cases z', simp add: nat add le Zero_int_def)
  13.338 -
  13.339 -lemma nat_diff_distrib:
  13.340 -     "[| (0::int) \<le> z';  z' \<le> z |] ==> nat (z-z') = nat z - nat z'"
  13.341 -by (cases z, cases z', 
  13.342 -    simp add: nat add minus diff_minus le Zero_int_def)
  13.343 -
  13.344 -lemma nat_zminus_int [simp]: "nat (- (of_nat n)) = 0"
  13.345 -by (simp add: int_def minus nat Zero_int_def) 
  13.346 -
  13.347 -lemma zless_nat_eq_int_zless: "(m < nat z) = (of_nat m < z)"
  13.348 -by (cases z, simp add: nat less int_def, arith)
  13.349 -
  13.350 -
  13.351 -subsection{*Lemmas about the Function @{term of_nat} and Orderings*}
  13.352 -
  13.353 -lemma negative_zless_0: "- (of_nat (Suc n)) < (0 \<Colon> int)"
  13.354 -by (simp add: order_less_le del: of_nat_Suc)
  13.355 -
  13.356 -lemma negative_zless [iff]: "- (of_nat (Suc n)) < (of_nat m \<Colon> int)"
  13.357 -by (rule negative_zless_0 [THEN order_less_le_trans], simp)
  13.358 -
  13.359 -lemma negative_zle_0: "- of_nat n \<le> (0 \<Colon> int)"
  13.360 -by (simp add: minus_le_iff)
  13.361 -
  13.362 -lemma negative_zle [iff]: "- of_nat n \<le> (of_nat m \<Colon> int)"
  13.363 -by (rule order_trans [OF negative_zle_0 of_nat_0_le_iff])
  13.364 -
  13.365 -lemma not_zle_0_negative [simp]: "~ (0 \<le> - (of_nat (Suc n) \<Colon> int))"
  13.366 -by (subst le_minus_iff, simp del: of_nat_Suc)
  13.367 -
  13.368 -lemma int_zle_neg: "((of_nat n \<Colon> int) \<le> - of_nat m) = (n = 0 & m = 0)"
  13.369 -by (simp add: int_def le minus Zero_int_def)
  13.370 -
  13.371 -lemma not_int_zless_negative [simp]: "~ ((of_nat n \<Colon> int) < - of_nat m)"
  13.372 -by (simp add: linorder_not_less)
  13.373 -
  13.374 -lemma negative_eq_positive [simp]: "((- of_nat n \<Colon> int) = of_nat m) = (n = 0 & m = 0)"
  13.375 -by (force simp add: order_eq_iff [of "- of_nat n"] int_zle_neg)
  13.376 -
  13.377 -lemma zle_iff_zadd: "(w\<Colon>int) \<le> z \<longleftrightarrow> (\<exists>n. z = w + of_nat n)"
  13.378 -proof -
  13.379 -  have "(w \<le> z) = (0 \<le> z - w)"
  13.380 -    by (simp only: le_diff_eq add_0_left)
  13.381 -  also have "\<dots> = (\<exists>n. z - w = of_nat n)"
  13.382 -    by (auto elim: zero_le_imp_eq_int)
  13.383 -  also have "\<dots> = (\<exists>n. z = w + of_nat n)"
  13.384 -    by (simp only: group_simps)
  13.385 -  finally show ?thesis .
  13.386 -qed
  13.387 -
  13.388 -lemma zadd_int_left: "of_nat m + (of_nat n + z) = of_nat (m + n) + (z\<Colon>int)"
  13.389 -by simp
  13.390 -
  13.391 -lemma int_Suc0_eq_1: "of_nat (Suc 0) = (1\<Colon>int)"
  13.392 -by simp
  13.393 -
  13.394 -text{*This version is proved for all ordered rings, not just integers!
  13.395 -      It is proved here because attribute @{text arith_split} is not available
  13.396 -      in theory @{text Ring_and_Field}.
  13.397 -      But is it really better than just rewriting with @{text abs_if}?*}
  13.398 -lemma abs_split [arith_split,noatp]:
  13.399 -     "P(abs(a::'a::ordered_idom)) = ((0 \<le> a --> P a) & (a < 0 --> P(-a)))"
  13.400 -by (force dest: order_less_le_trans simp add: abs_if linorder_not_less)
  13.401 -
  13.402 -
  13.403 -subsection {* Constants @{term neg} and @{term iszero} *}
  13.404 -
  13.405 -definition
  13.406 -  neg  :: "'a\<Colon>ordered_idom \<Rightarrow> bool"
  13.407 -where
  13.408 -  "neg Z \<longleftrightarrow> Z < 0"
  13.409 -
  13.410 -definition (*for simplifying equalities*)
  13.411 -  iszero :: "'a\<Colon>semiring_1 \<Rightarrow> bool"
  13.412 -where
  13.413 -  "iszero z \<longleftrightarrow> z = 0"
  13.414 -
  13.415 -lemma not_neg_int [simp]: "~ neg (of_nat n)"
  13.416 -by (simp add: neg_def)
  13.417 -
  13.418 -lemma neg_zminus_int [simp]: "neg (- (of_nat (Suc n)))"
  13.419 -by (simp add: neg_def neg_less_0_iff_less del: of_nat_Suc)
  13.420 -
  13.421 -lemmas neg_eq_less_0 = neg_def
  13.422 -
  13.423 -lemma not_neg_eq_ge_0: "(~neg x) = (0 \<le> x)"
  13.424 -by (simp add: neg_def linorder_not_less)
  13.425 -
  13.426 -
  13.427 -text{*To simplify inequalities when Numeral1 can get simplified to 1*}
  13.428 -
  13.429 -lemma not_neg_0: "~ neg 0"
  13.430 -by (simp add: One_int_def neg_def)
  13.431 -
  13.432 -lemma not_neg_1: "~ neg 1"
  13.433 -by (simp add: neg_def linorder_not_less zero_le_one)
  13.434 -
  13.435 -lemma iszero_0: "iszero 0"
  13.436 -by (simp add: iszero_def)
  13.437 -
  13.438 -lemma not_iszero_1: "~ iszero 1"
  13.439 -by (simp add: iszero_def eq_commute)
  13.440 -
  13.441 -lemma neg_nat: "neg z ==> nat z = 0"
  13.442 -by (simp add: neg_def order_less_imp_le) 
  13.443 -
  13.444 -lemma not_neg_nat: "~ neg z ==> of_nat (nat z) = z"
  13.445 -by (simp add: linorder_not_less neg_def)
  13.446 -
  13.447 -
  13.448 -subsection{*Embedding of the Integers into any @{text ring_1}: @{term of_int}*}
  13.449 -
  13.450 -context ring_1
  13.451 -begin
  13.452 -
  13.453 -term of_nat
  13.454 -
  13.455 -definition
  13.456 -  of_int :: "int \<Rightarrow> 'a"
  13.457 -where
  13.458 -  "of_int z = contents (\<Union>(i, j) \<in> Rep_Integ z. { of_nat i - of_nat j })"
  13.459 -lemmas [code func del] = of_int_def
  13.460 -
  13.461 -lemma of_int: "of_int (Abs_Integ (intrel `` {(i,j)})) = of_nat i - of_nat j"
  13.462 -proof -
  13.463 -  have "(\<lambda>(i,j). { of_nat i - (of_nat j :: 'a) }) respects intrel"
  13.464 -    by (simp add: congruent_def compare_rls of_nat_add [symmetric]
  13.465 -            del: of_nat_add) 
  13.466 -  thus ?thesis
  13.467 -    by (simp add: of_int_def UN_equiv_class [OF equiv_intrel])
  13.468 -qed
  13.469 -
  13.470 -lemma of_int_0 [simp]: "of_int 0 = 0"
  13.471 -by (simp add: of_int Zero_int_def)
  13.472 -
  13.473 -lemma of_int_1 [simp]: "of_int 1 = 1"
  13.474 -by (simp add: of_int One_int_def)
  13.475 -
  13.476 -lemma of_int_add [simp]: "of_int (w+z) = of_int w + of_int z"
  13.477 -by (cases w, cases z, simp add: compare_rls of_int add)
  13.478 -
  13.479 -lemma of_int_minus [simp]: "of_int (-z) = - (of_int z)"
  13.480 -by (cases z, simp add: compare_rls of_int minus)
  13.481 -
  13.482 -lemma of_int_mult [simp]: "of_int (w*z) = of_int w * of_int z"
  13.483 -apply (cases w, cases z)
  13.484 -apply (simp add: compare_rls of_int left_diff_distrib right_diff_distrib
  13.485 -                 mult add_ac of_nat_mult)
  13.486 -done
  13.487 -
  13.488 -text{*Collapse nested embeddings*}
  13.489 -lemma of_int_of_nat_eq [simp]: "of_int (Nat.of_nat n) = of_nat n"
  13.490 -  by (induct n, auto)
  13.491 -
  13.492 -end
  13.493 -
  13.494 -lemma of_int_diff [simp]: "of_int (w-z) = of_int w - of_int z"
  13.495 -by (simp add: diff_minus)
  13.496 -
  13.497 -lemma of_int_le_iff [simp]:
  13.498 -     "(of_int w \<le> (of_int z::'a::ordered_idom)) = (w \<le> z)"
  13.499 -apply (cases w)
  13.500 -apply (cases z)
  13.501 -apply (simp add: compare_rls of_int le diff_int_def add minus
  13.502 -                 of_nat_add [symmetric]   del: of_nat_add)
  13.503 -done
  13.504 -
  13.505 -text{*Special cases where either operand is zero*}
  13.506 -lemmas of_int_0_le_iff [simp] = of_int_le_iff [of 0, simplified]
  13.507 -lemmas of_int_le_0_iff [simp] = of_int_le_iff [of _ 0, simplified]
  13.508 -
  13.509 -lemma of_int_less_iff [simp]:
  13.510 -     "(of_int w < (of_int z::'a::ordered_idom)) = (w < z)"
  13.511 -by (simp add: linorder_not_le [symmetric])
  13.512 -
  13.513 -text{*Special cases where either operand is zero*}
  13.514 -lemmas of_int_0_less_iff [simp] = of_int_less_iff [of 0, simplified]
  13.515 -lemmas of_int_less_0_iff [simp] = of_int_less_iff [of _ 0, simplified]
  13.516 -
  13.517 -text{*Class for unital rings with characteristic zero.
  13.518 - Includes non-ordered rings like the complex numbers.*}
  13.519 -class ring_char_0 = ring_1 + semiring_char_0
  13.520 -begin
  13.521 -
  13.522 -lemma of_int_eq_iff [simp]:
  13.523 -   "of_int w = of_int z \<longleftrightarrow> w = z"
  13.524 -apply (cases w, cases z, simp add: of_int)
  13.525 -apply (simp only: diff_eq_eq diff_add_eq eq_diff_eq)
  13.526 -apply (simp only: of_nat_add [symmetric] of_nat_eq_iff)
  13.527 -done
  13.528 -
  13.529 -text{*Special cases where either operand is zero*}
  13.530 -lemmas of_int_0_eq_iff [simp] = of_int_eq_iff [of 0, simplified]
  13.531 -lemmas of_int_eq_0_iff [simp] = of_int_eq_iff [of _ 0, simplified]
  13.532 -
  13.533 -end
  13.534 -
  13.535 -text{*Every @{text ordered_idom} has characteristic zero.*}
  13.536 -instance ordered_idom \<subseteq> ring_char_0 ..
  13.537 -
  13.538 -lemma of_int_eq_id [simp]: "of_int = id"
  13.539 -proof
  13.540 -  fix z show "of_int z = id z"
  13.541 -    by (cases z) (simp add: of_int add minus int_def diff_minus)
  13.542 -qed
  13.543 -
  13.544 -context ring_1
  13.545 -begin
  13.546 -
  13.547 -lemma of_nat_nat: "0 \<le> z \<Longrightarrow> of_nat (nat z) = of_int z"
  13.548 -  by (cases z rule: eq_Abs_Integ)
  13.549 -   (simp add: nat le of_int Zero_int_def of_nat_diff)
  13.550 -
  13.551 -end
  13.552 -
  13.553 -
  13.554 -subsection{*The Set of Integers*}
  13.555 -
  13.556 -context ring_1
  13.557 -begin
  13.558 -
  13.559 -definition
  13.560 -  Ints  :: "'a set"
  13.561 -where
  13.562 -  "Ints = range of_int"
  13.563 -
  13.564 -end
  13.565 -
  13.566 -notation (xsymbols)
  13.567 -  Ints  ("\<int>")
  13.568 -
  13.569 -context ring_1
  13.570 -begin
  13.571 -
  13.572 -lemma Ints_0 [simp]: "0 \<in> \<int>"
  13.573 -apply (simp add: Ints_def)
  13.574 -apply (rule range_eqI)
  13.575 -apply (rule of_int_0 [symmetric])
  13.576 -done
  13.577 -
  13.578 -lemma Ints_1 [simp]: "1 \<in> \<int>"
  13.579 -apply (simp add: Ints_def)
  13.580 -apply (rule range_eqI)
  13.581 -apply (rule of_int_1 [symmetric])
  13.582 -done
  13.583 -
  13.584 -lemma Ints_add [simp]: "a \<in> \<int> \<Longrightarrow> b \<in> \<int> \<Longrightarrow> a + b \<in> \<int>"
  13.585 -apply (auto simp add: Ints_def)
  13.586 -apply (rule range_eqI)
  13.587 -apply (rule of_int_add [symmetric])
  13.588 -done
  13.589 -
  13.590 -lemma Ints_minus [simp]: "a \<in> \<int> \<Longrightarrow> -a \<in> \<int>"
  13.591 -apply (auto simp add: Ints_def)
  13.592 -apply (rule range_eqI)
  13.593 -apply (rule of_int_minus [symmetric])
  13.594 -done
  13.595 -
  13.596 -lemma Ints_mult [simp]: "a \<in> \<int> \<Longrightarrow> b \<in> \<int> \<Longrightarrow> a * b \<in> \<int>"
  13.597 -apply (auto simp add: Ints_def)
  13.598 -apply (rule range_eqI)
  13.599 -apply (rule of_int_mult [symmetric])
  13.600 -done
  13.601 -
  13.602 -lemma Ints_cases [cases set: Ints]:
  13.603 -  assumes "q \<in> \<int>"
  13.604 -  obtains (of_int) z where "q = of_int z"
  13.605 -  unfolding Ints_def
  13.606 -proof -
  13.607 -  from `q \<in> \<int>` have "q \<in> range of_int" unfolding Ints_def .
  13.608 -  then obtain z where "q = of_int z" ..
  13.609 -  then show thesis ..
  13.610 -qed
  13.611 -
  13.612 -lemma Ints_induct [case_names of_int, induct set: Ints]:
  13.613 -  "q \<in> \<int> \<Longrightarrow> (\<And>z. P (of_int z)) \<Longrightarrow> P q"
  13.614 -  by (rule Ints_cases) auto
  13.615 -
  13.616 -end
  13.617 -
  13.618 -lemma Ints_diff [simp]: "a \<in> \<int> \<Longrightarrow> b \<in> \<int> \<Longrightarrow> a-b \<in> \<int>"
  13.619 -apply (auto simp add: Ints_def)
  13.620 -apply (rule range_eqI)
  13.621 -apply (rule of_int_diff [symmetric])
  13.622 -done
  13.623 -
  13.624 -
  13.625 -subsection {* @{term setsum} and @{term setprod} *}
  13.626 -
  13.627 -text {*By Jeremy Avigad*}
  13.628 -
  13.629 -lemma of_nat_setsum: "of_nat (setsum f A) = (\<Sum>x\<in>A. of_nat(f x))"
  13.630 -  apply (cases "finite A")
  13.631 -  apply (erule finite_induct, auto)
  13.632 -  done
  13.633 -
  13.634 -lemma of_int_setsum: "of_int (setsum f A) = (\<Sum>x\<in>A. of_int(f x))"
  13.635 -  apply (cases "finite A")
  13.636 -  apply (erule finite_induct, auto)
  13.637 -  done
  13.638 -
  13.639 -lemma of_nat_setprod: "of_nat (setprod f A) = (\<Prod>x\<in>A. of_nat(f x))"
  13.640 -  apply (cases "finite A")
  13.641 -  apply (erule finite_induct, auto simp add: of_nat_mult)
  13.642 -  done
  13.643 -
  13.644 -lemma of_int_setprod: "of_int (setprod f A) = (\<Prod>x\<in>A. of_int(f x))"
  13.645 -  apply (cases "finite A")
  13.646 -  apply (erule finite_induct, auto)
  13.647 -  done
  13.648 -
  13.649 -lemma setprod_nonzero_nat:
  13.650 -    "finite A ==> (\<forall>x \<in> A. f x \<noteq> (0::nat)) ==> setprod f A \<noteq> 0"
  13.651 -  by (rule setprod_nonzero, auto)
  13.652 -
  13.653 -lemma setprod_zero_eq_nat:
  13.654 -    "finite A ==> (setprod f A = (0::nat)) = (\<exists>x \<in> A. f x = 0)"
  13.655 -  by (rule setprod_zero_eq, auto)
  13.656 -
  13.657 -lemma setprod_nonzero_int:
  13.658 -    "finite A ==> (\<forall>x \<in> A. f x \<noteq> (0::int)) ==> setprod f A \<noteq> 0"
  13.659 -  by (rule setprod_nonzero, auto)
  13.660 -
  13.661 -lemma setprod_zero_eq_int:
  13.662 -    "finite A ==> (setprod f A = (0::int)) = (\<exists>x \<in> A. f x = 0)"
  13.663 -  by (rule setprod_zero_eq, auto)
  13.664 -
  13.665 -lemmas int_setsum = of_nat_setsum [where 'a=int]
  13.666 -lemmas int_setprod = of_nat_setprod [where 'a=int]
  13.667 -
  13.668 -
  13.669 -subsection {* Further properties *}
  13.670 -
  13.671 -text{*Now we replace the case analysis rule by a more conventional one:
  13.672 -whether an integer is negative or not.*}
  13.673 -
  13.674 -lemma zless_iff_Suc_zadd:
  13.675 -  "(w \<Colon> int) < z \<longleftrightarrow> (\<exists>n. z = w + of_nat (Suc n))"
  13.676 -apply (cases z, cases w)
  13.677 -apply (auto simp add: less add int_def)
  13.678 -apply (rename_tac a b c d) 
  13.679 -apply (rule_tac x="a+d - Suc(c+b)" in exI) 
  13.680 -apply arith
  13.681 -done
  13.682 -
  13.683 -lemma negD: "(x \<Colon> int) < 0 \<Longrightarrow> \<exists>n. x = - (of_nat (Suc n))"
  13.684 -apply (cases x)
  13.685 -apply (auto simp add: le minus Zero_int_def int_def order_less_le)
  13.686 -apply (rule_tac x="y - Suc x" in exI, arith)
  13.687 -done
  13.688 -
  13.689 -theorem int_cases [cases type: int, case_names nonneg neg]:
  13.690 -  "[|!! n. (z \<Colon> int) = of_nat n ==> P;  !! n. z =  - (of_nat (Suc n)) ==> P |] ==> P"
  13.691 -apply (cases "z < 0", blast dest!: negD)
  13.692 -apply (simp add: linorder_not_less del: of_nat_Suc)
  13.693 -apply (blast dest: nat_0_le [THEN sym])
  13.694 -done
  13.695 -
  13.696 -theorem int_induct [induct type: int, case_names nonneg neg]:
  13.697 -     "[|!! n. P (of_nat n \<Colon> int);  !!n. P (- (of_nat (Suc n))) |] ==> P z"
  13.698 -  by (cases z rule: int_cases) auto
  13.699 -
  13.700 -text{*Contributed by Brian Huffman*}
  13.701 -theorem int_diff_cases:
  13.702 -  obtains (diff) m n where "(z\<Colon>int) = of_nat m - of_nat n"
  13.703 -apply (cases z rule: eq_Abs_Integ)
  13.704 -apply (rule_tac m=x and n=y in diff)
  13.705 -apply (simp add: int_def diff_def minus add)
  13.706 -done
  13.707 -
  13.708 -
  13.709 -subsection {* Legacy theorems *}
  13.710 -
  13.711 -lemmas zminus_zminus = minus_minus [of "z::int", standard]
  13.712 -lemmas zminus_0 = minus_zero [where 'a=int]
  13.713 -lemmas zminus_zadd_distrib = minus_add_distrib [of "z::int" "w", standard]
  13.714 -lemmas zadd_commute = add_commute [of "z::int" "w", standard]
  13.715 -lemmas zadd_assoc = add_assoc [of "z1::int" "z2" "z3", standard]
  13.716 -lemmas zadd_left_commute = add_left_commute [of "x::int" "y" "z", standard]
  13.717 -lemmas zadd_ac = zadd_assoc zadd_commute zadd_left_commute
  13.718 -lemmas zmult_ac = OrderedGroup.mult_ac
  13.719 -lemmas zadd_0 = OrderedGroup.add_0_left [of "z::int", standard]
  13.720 -lemmas zadd_0_right = OrderedGroup.add_0_left [of "z::int", standard]
  13.721 -lemmas zadd_zminus_inverse2 = left_minus [of "z::int", standard]
  13.722 -lemmas zmult_zminus = mult_minus_left [of "z::int" "w", standard]
  13.723 -lemmas zmult_commute = mult_commute [of "z::int" "w", standard]
  13.724 -lemmas zmult_assoc = mult_assoc [of "z1::int" "z2" "z3", standard]
  13.725 -lemmas zadd_zmult_distrib = left_distrib [of "z1::int" "z2" "w", standard]
  13.726 -lemmas zadd_zmult_distrib2 = right_distrib [of "w::int" "z1" "z2", standard]
  13.727 -lemmas zdiff_zmult_distrib = left_diff_distrib [of "z1::int" "z2" "w", standard]
  13.728 -lemmas zdiff_zmult_distrib2 = right_diff_distrib [of "w::int" "z1" "z2", standard]
  13.729 -
  13.730 -lemmas int_distrib =
  13.731 -  zadd_zmult_distrib zadd_zmult_distrib2
  13.732 -  zdiff_zmult_distrib zdiff_zmult_distrib2
  13.733 -
  13.734 -lemmas zmult_1 = mult_1_left [of "z::int", standard]
  13.735 -lemmas zmult_1_right = mult_1_right [of "z::int", standard]
  13.736 -
  13.737 -lemmas zle_refl = order_refl [of "w::int", standard]
  13.738 -lemmas zle_trans = order_trans [where 'a=int and x="i" and y="j" and z="k", standard]
  13.739 -lemmas zle_anti_sym = order_antisym [of "z::int" "w", standard]
  13.740 -lemmas zle_linear = linorder_linear [of "z::int" "w", standard]
  13.741 -lemmas zless_linear = linorder_less_linear [where 'a = int]
  13.742 -
  13.743 -lemmas zadd_left_mono = add_left_mono [of "i::int" "j" "k", standard]
  13.744 -lemmas zadd_strict_right_mono = add_strict_right_mono [of "i::int" "j" "k", standard]
  13.745 -lemmas zadd_zless_mono = add_less_le_mono [of "w'::int" "w" "z'" "z", standard]
  13.746 -
  13.747 -lemmas int_0_less_1 = zero_less_one [where 'a=int]
  13.748 -lemmas int_0_neq_1 = zero_neq_one [where 'a=int]
  13.749 -
  13.750 -lemmas inj_int = inj_of_nat [where 'a=int]
  13.751 -lemmas int_int_eq = of_nat_eq_iff [where 'a=int]
  13.752 -lemmas zadd_int = of_nat_add [where 'a=int, symmetric]
  13.753 -lemmas int_mult = of_nat_mult [where 'a=int]
  13.754 -lemmas zmult_int = of_nat_mult [where 'a=int, symmetric]
  13.755 -lemmas int_eq_0_conv = of_nat_eq_0_iff [where 'a=int and m="n", standard]
  13.756 -lemmas zless_int = of_nat_less_iff [where 'a=int]
  13.757 -lemmas int_less_0_conv = of_nat_less_0_iff [where 'a=int and m="k", standard]
  13.758 -lemmas zero_less_int_conv = of_nat_0_less_iff [where 'a=int]
  13.759 -lemmas zle_int = of_nat_le_iff [where 'a=int]
  13.760 -lemmas zero_zle_int = of_nat_0_le_iff [where 'a=int]
  13.761 -lemmas int_le_0_conv = of_nat_le_0_iff [where 'a=int and m="n", standard]
  13.762 -lemmas int_0 = of_nat_0 [where 'a=int]
  13.763 -lemmas int_1 = of_nat_1 [where 'a=int]
  13.764 -lemmas int_Suc = of_nat_Suc [where 'a=int]
  13.765 -lemmas abs_int_eq = abs_of_nat [where 'a=int and n="m", standard]
  13.766 -lemmas of_int_int_eq = of_int_of_nat_eq [where 'a=int]
  13.767 -lemmas zdiff_int = of_nat_diff [where 'a=int, symmetric]
  13.768 -lemmas zless_le = less_int_def
  13.769 -lemmas int_eq_of_nat = TrueI
  13.770 -
  13.771 -abbreviation
  13.772 -  int :: "nat \<Rightarrow> int"
  13.773 -where
  13.774 -  "int \<equiv> of_nat"
  13.775 -
  13.776 -end
    14.1 --- a/src/HOL/IntDiv.thy	Tue Jan 15 16:19:21 2008 +0100
    14.2 +++ b/src/HOL/IntDiv.thy	Tue Jan 15 16:19:23 2008 +0100
    14.3 @@ -8,7 +8,7 @@
    14.4  header{*The Division Operators div and mod; the Divides Relation dvd*}
    14.5  
    14.6  theory IntDiv
    14.7 -imports IntArith Divides FunDef
    14.8 +imports Int Divides FunDef
    14.9  begin
   14.10  
   14.11  constdefs
    15.1 --- a/src/HOL/IsaMakefile	Tue Jan 15 16:19:21 2008 +0100
    15.2 +++ b/src/HOL/IsaMakefile	Tue Jan 15 16:19:23 2008 +0100
    15.3 @@ -95,9 +95,9 @@
    15.4    Accessible_Part.thy Arith_Tools.thy Code_Setup.thy Datatype.thy 			\
    15.5    Dense_Linear_Order.thy Divides.thy Equiv_Relations.thy Extraction.thy	\
    15.6    Finite_Set.thy Fun.thy FunDef.thy HOL.thy		\
    15.7 -  Hilbert_Choice.thy Inductive.thy IntArith.thy IntDef.thy IntDiv.thy	\
    15.8 +  Hilbert_Choice.thy Inductive.thy Int.thy IntDiv.thy	\
    15.9    Lattices.thy List.thy Main.thy Map.thy Nat.thy NatBin.thy	\
   15.10 -  Numeral.thy OrderedGroup.thy Orderings.thy Power.thy PreList.thy	\
   15.11 +  OrderedGroup.thy Orderings.thy Power.thy PreList.thy	\
   15.12    Predicate.thy Product_Type.thy ROOT.ML Recdef.thy			\
   15.13    Record.thy Refute.thy Relation.thy Relation_Power.thy			\
   15.14    Ring_and_Field.thy SAT.thy Set.thy SetInterval.thy Sum_Type.thy	\
    16.1 --- a/src/HOL/Library/Code_Integer.thy	Tue Jan 15 16:19:21 2008 +0100
    16.2 +++ b/src/HOL/Library/Code_Integer.thy	Tue Jan 15 16:19:23 2008 +0100
    16.3 @@ -6,7 +6,7 @@
    16.4  header {* Pretty integer literals for code generation *}
    16.5  
    16.6  theory Code_Integer
    16.7 -imports IntArith Code_Index
    16.8 +imports Int
    16.9  begin
   16.10  
   16.11  text {*
   16.12 @@ -26,13 +26,13 @@
   16.13  setup {*
   16.14    fold (fn target => CodeTarget.add_pretty_numeral target true
   16.15      @{const_name number_int_inst.number_of_int}
   16.16 -    @{const_name Numeral.B0} @{const_name Numeral.B1}
   16.17 -    @{const_name Numeral.Pls} @{const_name Numeral.Min}
   16.18 -    @{const_name Numeral.Bit}
   16.19 +    @{const_name Int.B0} @{const_name Int.B1}
   16.20 +    @{const_name Int.Pls} @{const_name Int.Min}
   16.21 +    @{const_name Int.Bit}
   16.22    ) ["SML", "OCaml", "Haskell"]
   16.23  *}
   16.24  
   16.25 -code_const "Numeral.Pls" and "Numeral.Min" and "Numeral.Bit"
   16.26 +code_const "Int.Pls" and "Int.Min" and "Int.Bit"
   16.27    (SML "raise/ Fail/ \"Pls\""
   16.28       and "raise/ Fail/ \"Min\""
   16.29       and "!((_);/ (_);/ raise/ Fail/ \"Bit\")")
   16.30 @@ -43,12 +43,12 @@
   16.31       and "error/ \"Min\""
   16.32       and "error/ \"Bit\"")
   16.33  
   16.34 -code_const Numeral.pred
   16.35 +code_const Int.pred
   16.36    (SML "IntInf.- ((_), 1)")
   16.37    (OCaml "Big'_int.pred'_big'_int")
   16.38    (Haskell "!(_/ -/ 1)")
   16.39  
   16.40 -code_const Numeral.succ
   16.41 +code_const Int.succ
   16.42    (SML "IntInf.+ ((_), 1)")
   16.43    (OCaml "Big'_int.succ'_big'_int")
   16.44    (Haskell "!(_/ +/ 1)")
   16.45 @@ -88,11 +88,6 @@
   16.46    (OCaml "Big'_int.lt'_big'_int")
   16.47    (Haskell infix 4 "<")
   16.48  
   16.49 -(*code_const index_of_int and int_of_index
   16.50 -  (SML "IntInf.toInt" and "IntInf.fromInt")
   16.51 -  (OCaml "Big'_int.int'_of'_big'_int" and "Big'_int.big'_int'_of'_int")
   16.52 -  (Haskell "_" and "_") FIXME perhaps recover this if neccessary *)
   16.53 -
   16.54  code_reserved SML IntInf
   16.55  code_reserved OCaml Big_int
   16.56  
    17.1 --- a/src/HOL/Library/Efficient_Nat.thy	Tue Jan 15 16:19:21 2008 +0100
    17.2 +++ b/src/HOL/Library/Efficient_Nat.thy	Tue Jan 15 16:19:23 2008 +0100
    17.3 @@ -6,7 +6,7 @@
    17.4  header {* Implementation of natural numbers by integers *}
    17.5  
    17.6  theory Efficient_Nat
    17.7 -imports Main Code_Integer
    17.8 +imports Main Code_Integer Code_Index
    17.9  begin
   17.10  
   17.11  text {*
   17.12 @@ -55,7 +55,7 @@
   17.13  
   17.14  lemma nat_of_int_of_number_of_aux:
   17.15    fixes k
   17.16 -  assumes "Numeral.Pls \<le> k \<equiv> True"
   17.17 +  assumes "Int.Pls \<le> k \<equiv> True"
   17.18    shows "k \<ge> 0"
   17.19    using assms unfolding Pls_def by simp
   17.20  
   17.21 @@ -259,7 +259,7 @@
   17.22        (HOL_basic_ss addsimps (@{thms less_numeral_code} @ @{thms less_eq_numeral_code}));
   17.23      fun mk_rew (t, ty) =
   17.24        if ty = HOLogic.natT andalso 0 <= HOLogic.dest_numeral t then
   17.25 -        Thm.capply @{cterm "(op \<le>) Numeral.Pls"} (Thm.cterm_of thy t)
   17.26 +        Thm.capply @{cterm "(op \<le>) Int.Pls"} (Thm.cterm_of thy t)
   17.27          |> simplify_less
   17.28          |> (fn thm => @{thm nat_of_int_of_number_of_aux} OF [thm])
   17.29          |> (fn thm => @{thm nat_of_int_of_number_of} OF [thm])
   17.30 @@ -415,16 +415,19 @@
   17.31  subsection {* Module names *}
   17.32  
   17.33  code_modulename SML
   17.34 +  Int Integer
   17.35    Nat Integer
   17.36    Divides Integer
   17.37    Efficient_Nat Integer
   17.38  
   17.39  code_modulename OCaml
   17.40 +  Int Integer
   17.41    Nat Integer
   17.42    Divides Integer
   17.43    Efficient_Nat Integer
   17.44  
   17.45  code_modulename Haskell
   17.46 +  Int Integer
   17.47    Nat Integer
   17.48    Divides Integer
   17.49    Efficient_Nat Integer
    18.1 --- a/src/HOL/Library/Eval.thy	Tue Jan 15 16:19:21 2008 +0100
    18.2 +++ b/src/HOL/Library/Eval.thy	Tue Jan 15 16:19:23 2008 +0100
    18.3 @@ -295,21 +295,21 @@
    18.4  abbreviation (in pure_term_syntax) (input)
    18.5    intT :: "typ"
    18.6  where
    18.7 -  "intT \<equiv> Type (STR ''IntDef.int'') []"
    18.8 +  "intT \<equiv> Type (STR ''Int.int'') []"
    18.9  
   18.10  abbreviation (in pure_term_syntax) (input)
   18.11    bitT :: "typ"
   18.12  where
   18.13 -  "bitT \<equiv> Type (STR ''Numeral.bit'') []"
   18.14 +  "bitT \<equiv> Type (STR ''Int.bit'') []"
   18.15  
   18.16  function (in pure_term_syntax)
   18.17    mk_int :: "int \<Rightarrow> term"
   18.18  where
   18.19 -  "mk_int k = (if k = 0 then STR ''Numeral.Pls'' \<Colon>\<subseteq> intT
   18.20 -    else if k = -1 then STR ''Numeral.Min'' \<Colon>\<subseteq> intT
   18.21 +  "mk_int k = (if k = 0 then STR ''Int.Pls'' \<Colon>\<subseteq> intT
   18.22 +    else if k = -1 then STR ''Int.Min'' \<Colon>\<subseteq> intT
   18.23      else let (l, m) = divAlg (k, 2)
   18.24 -  in STR ''Numeral.Bit'' \<Colon>\<subseteq> intT \<rightarrow> bitT \<rightarrow> intT \<bullet> mk_int l \<bullet>
   18.25 -    (if m = 0 then STR ''Numeral.bit.B0'' \<Colon>\<subseteq> bitT else STR ''Numeral.bit.B1'' \<Colon>\<subseteq> bitT))"
   18.26 +  in STR ''Int.Bit'' \<Colon>\<subseteq> intT \<rightarrow> bitT \<rightarrow> intT \<bullet> mk_int l \<bullet>
   18.27 +    (if m = 0 then STR ''Int.bit.B0'' \<Colon>\<subseteq> bitT else STR ''Int.bit.B1'' \<Colon>\<subseteq> bitT))"
   18.28  by pat_completeness auto
   18.29  termination (in pure_term_syntax)
   18.30  by (relation "measure (nat o abs)") (auto simp add: divAlg_mod_div)
   18.31 @@ -317,7 +317,7 @@
   18.32  declare pure_term_syntax.mk_int.simps [code func]
   18.33  
   18.34  definition (in pure_term_syntax)
   18.35 -  "term_of_int_aux k = STR ''Numeral.number_class.number_of'' \<Colon>\<subseteq> intT \<rightarrow> intT \<bullet> mk_int k"
   18.36 +  "term_of_int_aux k = STR ''Int.number_class.number_of'' \<Colon>\<subseteq> intT \<rightarrow> intT \<bullet> mk_int k"
   18.37  
   18.38  declare pure_term_syntax.term_of_int_aux_def [code func]
   18.39  
    19.1 --- a/src/HOL/Library/Word.thy	Tue Jan 15 16:19:21 2008 +0100
    19.2 +++ b/src/HOL/Library/Word.thy	Tue Jan 15 16:19:23 2008 +0100
    19.3 @@ -2257,7 +2257,7 @@
    19.4  
    19.5  lemmas [simp] = length_nat_non0
    19.6  
    19.7 -lemma "nat_to_bv (number_of Numeral.Pls) = []"
    19.8 +lemma "nat_to_bv (number_of Int.Pls) = []"
    19.9    by simp
   19.10  
   19.11  consts
   19.12 @@ -2276,13 +2276,13 @@
   19.13    by simp
   19.14  
   19.15  lemma fast_bv_to_nat_def:
   19.16 -  "bv_to_nat bs == number_of (fast_bv_to_nat_helper bs Numeral.Pls)"
   19.17 +  "bv_to_nat bs == number_of (fast_bv_to_nat_helper bs Int.Pls)"
   19.18  proof (simp add: bv_to_nat_def)
   19.19    have "\<forall> bin. \<not> (neg (number_of bin :: int)) \<longrightarrow> (foldl (%bn b. 2 * bn + bitval b) (number_of bin) bs) = number_of (fast_bv_to_nat_helper bs bin)"
   19.20      apply (induct bs,simp)
   19.21      apply (case_tac a,simp_all)
   19.22      done
   19.23 -  thus "foldl (\<lambda>bn b. 2 * bn + bitval b) 0 bs \<equiv> number_of (fast_bv_to_nat_helper bs Numeral.Pls)"
   19.24 +  thus "foldl (\<lambda>bn b. 2 * bn + bitval b) 0 bs \<equiv> number_of (fast_bv_to_nat_helper bs Int.Pls)"
   19.25      by (simp del: nat_numeral_0_eq_0 add: nat_numeral_0_eq_0 [symmetric])
   19.26  qed
   19.27  
   19.28 @@ -2299,9 +2299,9 @@
   19.29    fun is_const_bit (Const("Word.bit.Zero",_)) = true
   19.30      | is_const_bit (Const("Word.bit.One",_)) = true
   19.31      | is_const_bit _ = false
   19.32 -  fun num_is_usable (Const("Numeral.Pls",_)) = true
   19.33 -    | num_is_usable (Const("Numeral.Min",_)) = false
   19.34 -    | num_is_usable (Const("Numeral.Bit",_) $ w $ b) =
   19.35 +  fun num_is_usable (Const(@{const_name Int.Pls},_)) = true
   19.36 +    | num_is_usable (Const(@{const_name Int.Min},_)) = false
   19.37 +    | num_is_usable (Const(@{const_name Int.Bit},_) $ w $ b) =
   19.38          num_is_usable w andalso is_const_bool b
   19.39      | num_is_usable _ = false
   19.40    fun vec_is_usable (Const("List.list.Nil",_)) = true
   19.41 @@ -2310,9 +2310,9 @@
   19.42      | vec_is_usable _ = false
   19.43    (*lcp** val fast1_th = PureThy.get_thm thy "Word.fast_nat_to_bv_def"*)
   19.44    val fast2_th = @{thm "Word.fast_bv_to_nat_def"};
   19.45 -  (*lcp** fun f sg thms (Const("Word.nat_to_bv",_) $ (Const(@{const_name Numeral.number_of},_) $ t)) =
   19.46 +  (*lcp** fun f sg thms (Const("Word.nat_to_bv",_) $ (Const(@{const_name Int.number_of},_) $ t)) =
   19.47      if num_is_usable t
   19.48 -      then SOME (Drule.cterm_instantiate [(cterm_of sg (Var(("w",0),Type("IntDef.int",[]))),cterm_of sg t)] fast1_th)
   19.49 +      then SOME (Drule.cterm_instantiate [(cterm_of sg (Var (("w", 0), @{typ int})), cterm_of sg t)] fast1_th)
   19.50        else NONE
   19.51      | f _ _ _ = NONE *)
   19.52    fun g sg thms (Const("Word.bv_to_nat",_) $ (t as (Const("List.list.Cons",_) $ _ $ _))) =
    20.1 --- a/src/HOL/NatBin.thy	Tue Jan 15 16:19:21 2008 +0100
    20.2 +++ b/src/HOL/NatBin.thy	Tue Jan 15 16:19:23 2008 +0100
    20.3 @@ -120,14 +120,14 @@
    20.4  
    20.5  lemma Suc_nat_number_of_add:
    20.6       "Suc (number_of v + n) =  
    20.7 -        (if neg (number_of v :: int) then 1+n else number_of (Numeral.succ v) + n)" 
    20.8 +        (if neg (number_of v :: int) then 1+n else number_of (Int.succ v) + n)" 
    20.9  by (simp del: nat_number_of 
   20.10           add: nat_number_of_def neg_nat
   20.11                Suc_nat_eq_nat_zadd1 number_of_succ) 
   20.12  
   20.13  lemma Suc_nat_number_of [simp]:
   20.14       "Suc (number_of v) =  
   20.15 -        (if neg (number_of v :: int) then 1 else number_of (Numeral.succ v))"
   20.16 +        (if neg (number_of v :: int) then 1 else number_of (Int.succ v))"
   20.17  apply (cut_tac n = 0 in Suc_nat_number_of_add)
   20.18  apply (simp cong del: if_weak_cong)
   20.19  done
   20.20 @@ -470,7 +470,7 @@
   20.21  
   20.22  lemma eq_number_of_Suc [simp]:
   20.23       "(number_of v = Suc n) =  
   20.24 -        (let pv = number_of (Numeral.pred v) in  
   20.25 +        (let pv = number_of (Int.pred v) in  
   20.26           if neg pv then False else nat pv = n)"
   20.27  apply (simp only: simp_thms Let_def neg_eq_less_0 linorder_not_less 
   20.28                    number_of_pred nat_number_of_def 
   20.29 @@ -481,13 +481,13 @@
   20.30  
   20.31  lemma Suc_eq_number_of [simp]:
   20.32       "(Suc n = number_of v) =  
   20.33 -        (let pv = number_of (Numeral.pred v) in  
   20.34 +        (let pv = number_of (Int.pred v) in  
   20.35           if neg pv then False else nat pv = n)"
   20.36  by (rule trans [OF eq_sym_conv eq_number_of_Suc])
   20.37  
   20.38  lemma less_number_of_Suc [simp]:
   20.39       "(number_of v < Suc n) =  
   20.40 -        (let pv = number_of (Numeral.pred v) in  
   20.41 +        (let pv = number_of (Int.pred v) in  
   20.42           if neg pv then True else nat pv < n)"
   20.43  apply (simp only: simp_thms Let_def neg_eq_less_0 linorder_not_less 
   20.44                    number_of_pred nat_number_of_def  
   20.45 @@ -498,7 +498,7 @@
   20.46  
   20.47  lemma less_Suc_number_of [simp]:
   20.48       "(Suc n < number_of v) =  
   20.49 -        (let pv = number_of (Numeral.pred v) in  
   20.50 +        (let pv = number_of (Int.pred v) in  
   20.51           if neg pv then False else n < nat pv)"
   20.52  apply (simp only: simp_thms Let_def neg_eq_less_0 linorder_not_less 
   20.53                    number_of_pred nat_number_of_def
   20.54 @@ -509,13 +509,13 @@
   20.55  
   20.56  lemma le_number_of_Suc [simp]:
   20.57       "(number_of v <= Suc n) =  
   20.58 -        (let pv = number_of (Numeral.pred v) in  
   20.59 +        (let pv = number_of (Int.pred v) in  
   20.60           if neg pv then True else nat pv <= n)"
   20.61  by (simp add: Let_def less_Suc_number_of linorder_not_less [symmetric])
   20.62  
   20.63  lemma le_Suc_number_of [simp]:
   20.64       "(Suc n <= number_of v) =  
   20.65 -        (let pv = number_of (Numeral.pred v) in  
   20.66 +        (let pv = number_of (Int.pred v) in  
   20.67           if neg pv then False else n <= nat pv)"
   20.68  by (simp add: Let_def less_number_of_Suc linorder_not_less [symmetric])
   20.69  
   20.70 @@ -550,15 +550,15 @@
   20.71  done
   20.72  
   20.73  lemma eq_number_of_BIT_Min:
   20.74 -     "((number_of (v BIT x) ::int) = number_of Numeral.Min) =  
   20.75 -      (x=bit.B1 & (((number_of v) ::int) = number_of Numeral.Min))"
   20.76 +     "((number_of (v BIT x) ::int) = number_of Int.Min) =  
   20.77 +      (x=bit.B1 & (((number_of v) ::int) = number_of Int.Min))"
   20.78  apply (simp only: simp_thms  add: number_of_BIT number_of_Min eq_commute
   20.79              split add: bit.split cong: imp_cong)
   20.80  apply (rule_tac x = "number_of v" in spec, auto)
   20.81  apply (drule_tac f = "%x. x mod 2" in arg_cong, auto)
   20.82  done
   20.83  
   20.84 -lemma eq_number_of_Pls_Min: "(Numeral0 ::int) ~= number_of Numeral.Min"
   20.85 +lemma eq_number_of_Pls_Min: "(Numeral0 ::int) ~= number_of Int.Min"
   20.86  by auto
   20.87  
   20.88  
   20.89 @@ -567,7 +567,7 @@
   20.90  
   20.91  lemma max_number_of_Suc [simp]:
   20.92       "max (Suc n) (number_of v) =  
   20.93 -        (let pv = number_of (Numeral.pred v) in  
   20.94 +        (let pv = number_of (Int.pred v) in  
   20.95           if neg pv then Suc n else Suc(max n (nat pv)))"
   20.96  apply (simp only: Let_def neg_eq_less_0 number_of_pred nat_number_of_def 
   20.97              split add: split_if nat.split)
   20.98 @@ -577,7 +577,7 @@
   20.99   
  20.100  lemma max_Suc_number_of [simp]:
  20.101       "max (number_of v) (Suc n) =  
  20.102 -        (let pv = number_of (Numeral.pred v) in  
  20.103 +        (let pv = number_of (Int.pred v) in  
  20.104           if neg pv then Suc n else Suc(max (nat pv) n))"
  20.105  apply (simp only: Let_def neg_eq_less_0 number_of_pred nat_number_of_def 
  20.106              split add: split_if nat.split)
  20.107 @@ -587,7 +587,7 @@
  20.108   
  20.109  lemma min_number_of_Suc [simp]:
  20.110       "min (Suc n) (number_of v) =  
  20.111 -        (let pv = number_of (Numeral.pred v) in  
  20.112 +        (let pv = number_of (Int.pred v) in  
  20.113           if neg pv then 0 else Suc(min n (nat pv)))"
  20.114  apply (simp only: Let_def neg_eq_less_0 number_of_pred nat_number_of_def 
  20.115              split add: split_if nat.split)
  20.116 @@ -597,7 +597,7 @@
  20.117   
  20.118  lemma min_Suc_number_of [simp]:
  20.119       "min (number_of v) (Suc n) =  
  20.120 -        (let pv = number_of (Numeral.pred v) in  
  20.121 +        (let pv = number_of (Int.pred v) in  
  20.122           if neg pv then 0 else Suc(min (nat pv) n))"
  20.123  apply (simp only: Let_def neg_eq_less_0 number_of_pred nat_number_of_def 
  20.124              split add: split_if nat.split)
  20.125 @@ -681,7 +681,7 @@
  20.126  lemma nat_number_of_Pls: "Numeral0 = (0::nat)"
  20.127    by (simp add: number_of_Pls nat_number_of_def)
  20.128  
  20.129 -lemma nat_number_of_Min: "number_of Numeral.Min = (0::nat)"
  20.130 +lemma nat_number_of_Min: "number_of Int.Min = (0::nat)"
  20.131    apply (simp only: number_of_Min nat_number_of_def nat_zminus_int)
  20.132    done
  20.133  
    21.1 --- a/src/HOL/Nominal/nominal_atoms.ML	Tue Jan 15 16:19:21 2008 +0100
    21.2 +++ b/src/HOL/Nominal/nominal_atoms.ML	Tue Jan 15 16:19:23 2008 +0100
    21.3 @@ -717,9 +717,9 @@
    21.4           |> discrete_pt_inst "bool" @{thm "perm_bool"}
    21.5           |> discrete_fs_inst "bool" @{thm "perm_bool"}
    21.6           |> discrete_cp_inst "bool" @{thm "perm_bool"}
    21.7 -         |> discrete_pt_inst "IntDef.int" @{thm "perm_int_def"}
    21.8 -         |> discrete_fs_inst "IntDef.int" @{thm "perm_int_def"}
    21.9 -         |> discrete_cp_inst "IntDef.int" @{thm "perm_int_def"}
   21.10 +         |> discrete_pt_inst @{type_name "Int.int"} @{thm "perm_int_def"}
   21.11 +         |> discrete_fs_inst @{type_name "Int.int"} @{thm "perm_int_def"}
   21.12 +         |> discrete_cp_inst @{type_name "Int.int"} @{thm "perm_int_def"}
   21.13           |> discrete_pt_inst "List.char" @{thm "perm_char_def"}
   21.14           |> discrete_fs_inst "List.char" @{thm "perm_char_def"}
   21.15           |> discrete_cp_inst "List.char" @{thm "perm_char_def"}
    22.1 --- a/src/HOL/Numeral.thy	Tue Jan 15 16:19:21 2008 +0100
    22.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    22.3 @@ -1,688 +0,0 @@
    22.4 -(*  Title:      HOL/Numeral.thy
    22.5 -    ID:         $Id$
    22.6 -    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
    22.7 -    Copyright   1994  University of Cambridge
    22.8 -*)
    22.9 -
   22.10 -header {* Arithmetic on Binary Integers *}
   22.11 -
   22.12 -theory Numeral
   22.13 -imports Datatype IntDef
   22.14 -uses
   22.15 -  ("Tools/numeral.ML")
   22.16 -  ("Tools/numeral_syntax.ML")
   22.17 -begin
   22.18 -
   22.19 -subsection {* Binary representation *}
   22.20 -
   22.21 -text {*
   22.22 -  This formalization defines binary arithmetic in terms of the integers
   22.23 -  rather than using a datatype. This avoids multiple representations (leading
   22.24 -  zeroes, etc.)  See @{text "ZF/Tools/twos-compl.ML"}, function @{text
   22.25 -  int_of_binary}, for the numerical interpretation.
   22.26 -
   22.27 -  The representation expects that @{text "(m mod 2)"} is 0 or 1,
   22.28 -  even if m is negative;
   22.29 -  For instance, @{text "-5 div 2 = -3"} and @{text "-5 mod 2 = 1"}; thus
   22.30 -  @{text "-5 = (-3)*2 + 1"}.
   22.31 -  
   22.32 -  This two's complement binary representation derives from the paper 
   22.33 -  "An Efficient Representation of Arithmetic for Term Rewriting" by
   22.34 -  Dave Cohen and Phil Watson, Rewriting Techniques and Applications,
   22.35 -  Springer LNCS 488 (240-251), 1991.
   22.36 -*}
   22.37 -
   22.38 -datatype bit = B0 | B1
   22.39 -
   22.40 -text{*
   22.41 -  Type @{typ bit} avoids the use of type @{typ bool}, which would make
   22.42 -  all of the rewrite rules higher-order.
   22.43 -*}
   22.44 -
   22.45 -definition
   22.46 -  Pls :: int where
   22.47 -  [code func del]: "Pls = 0"
   22.48 -
   22.49 -definition
   22.50 -  Min :: int where
   22.51 -  [code func del]: "Min = - 1"
   22.52 -
   22.53 -definition
   22.54 -  Bit :: "int \<Rightarrow> bit \<Rightarrow> int" (infixl "BIT" 90) where
   22.55 -  [code func del]: "k BIT b = (case b of B0 \<Rightarrow> 0 | B1 \<Rightarrow> 1) + k + k"
   22.56 -
   22.57 -class number = type + -- {* for numeric types: nat, int, real, \dots *}
   22.58 -  fixes number_of :: "int \<Rightarrow> 'a"
   22.59 -
   22.60 -use "Tools/numeral.ML"
   22.61 -
   22.62 -syntax
   22.63 -  "_Numeral" :: "num_const \<Rightarrow> 'a"    ("_")
   22.64 -
   22.65 -use "Tools/numeral_syntax.ML"
   22.66 -setup NumeralSyntax.setup
   22.67 -
   22.68 -abbreviation
   22.69 -  "Numeral0 \<equiv> number_of Pls"
   22.70 -
   22.71 -abbreviation
   22.72 -  "Numeral1 \<equiv> number_of (Pls BIT B1)"
   22.73 -
   22.74 -lemma Let_number_of [simp]: "Let (number_of v) f = f (number_of v)"
   22.75 -  -- {* Unfold all @{text let}s involving constants *}
   22.76 -  unfolding Let_def ..
   22.77 -
   22.78 -definition
   22.79 -  succ :: "int \<Rightarrow> int" where
   22.80 -  [code func del]: "succ k = k + 1"
   22.81 -
   22.82 -definition
   22.83 -  pred :: "int \<Rightarrow> int" where
   22.84 -  [code func del]: "pred k = k - 1"
   22.85 -
   22.86 -lemmas
   22.87 -  max_number_of [simp] = max_def
   22.88 -    [of "number_of u" "number_of v", standard, simp]
   22.89 -and
   22.90 -  min_number_of [simp] = min_def 
   22.91 -    [of "number_of u" "number_of v", standard, simp]
   22.92 -  -- {* unfolding @{text minx} and @{text max} on numerals *}
   22.93 -
   22.94 -lemmas numeral_simps = 
   22.95 -  succ_def pred_def Pls_def Min_def Bit_def
   22.96 -
   22.97 -text {* Removal of leading zeroes *}
   22.98 -
   22.99 -lemma Pls_0_eq [simp, code post]:
  22.100 -  "Pls BIT B0 = Pls"
  22.101 -  unfolding numeral_simps by simp
  22.102 -
  22.103 -lemma Min_1_eq [simp, code post]:
  22.104 -  "Min BIT B1 = Min"
  22.105 -  unfolding numeral_simps by simp
  22.106 -
  22.107 -
  22.108 -subsection {* The Functions @{term succ}, @{term pred} and @{term uminus} *}
  22.109 -
  22.110 -lemma succ_Pls [simp]:
  22.111 -  "succ Pls = Pls BIT B1"
  22.112 -  unfolding numeral_simps by simp
  22.113 -
  22.114 -lemma succ_Min [simp]:
  22.115 -  "succ Min = Pls"
  22.116 -  unfolding numeral_simps by simp
  22.117 -
  22.118 -lemma succ_1 [simp]:
  22.119 -  "succ (k BIT B1) = succ k BIT B0"
  22.120 -  unfolding numeral_simps by simp
  22.121 -
  22.122 -lemma succ_0 [simp]:
  22.123 -  "succ (k BIT B0) = k BIT B1"
  22.124 -  unfolding numeral_simps by simp
  22.125 -
  22.126 -lemma pred_Pls [simp]:
  22.127 -  "pred Pls = Min"
  22.128 -  unfolding numeral_simps by simp
  22.129 -
  22.130 -lemma pred_Min [simp]:
  22.131 -  "pred Min = Min BIT B0"
  22.132 -  unfolding numeral_simps by simp
  22.133 -
  22.134 -lemma pred_1 [simp]:
  22.135 -  "pred (k BIT B1) = k BIT B0"
  22.136 -  unfolding numeral_simps by simp
  22.137 -
  22.138 -lemma pred_0 [simp]:
  22.139 -  "pred (k BIT B0) = pred k BIT B1"
  22.140 -  unfolding numeral_simps by simp 
  22.141 -
  22.142 -lemma minus_Pls [simp]:
  22.143 -  "- Pls = Pls"
  22.144 -  unfolding numeral_simps by simp 
  22.145 -
  22.146 -lemma minus_Min [simp]:
  22.147 -  "- Min = Pls BIT B1"
  22.148 -  unfolding numeral_simps by simp 
  22.149 -
  22.150 -lemma minus_1 [simp]:
  22.151 -  "- (k BIT B1) = pred (- k) BIT B1"
  22.152 -  unfolding numeral_simps by simp 
  22.153 -
  22.154 -lemma minus_0 [simp]:
  22.155 -  "- (k BIT B0) = (- k) BIT B0"
  22.156 -  unfolding numeral_simps by simp 
  22.157 -
  22.158 -
  22.159 -subsection {*
  22.160 -  Binary Addition and Multiplication: @{term "op + \<Colon> int \<Rightarrow> int \<Rightarrow> int"}
  22.161 -    and @{term "op * \<Colon> int \<Rightarrow> int \<Rightarrow> int"}
  22.162 -*}
  22.163 -
  22.164 -lemma add_Pls [simp]:
  22.165 -  "Pls + k = k"
  22.166 -  unfolding numeral_simps by simp 
  22.167 -
  22.168 -lemma add_Min [simp]:
  22.169 -  "Min + k = pred k"
  22.170 -  unfolding numeral_simps by simp
  22.171 -
  22.172 -lemma add_BIT_11 [simp]:
  22.173 -  "(k BIT B1) + (l BIT B1) = (k + succ l) BIT B0"
  22.174 -  unfolding numeral_simps by simp
  22.175 -
  22.176 -lemma add_BIT_10 [simp]:
  22.177 -  "(k BIT B1) + (l BIT B0) = (k + l) BIT B1"
  22.178 -  unfolding numeral_simps by simp
  22.179 -
  22.180 -lemma add_BIT_0 [simp]:
  22.181 -  "(k BIT B0) + (l BIT b) = (k + l) BIT b"
  22.182 -  unfolding numeral_simps by simp 
  22.183 -
  22.184 -lemma add_Pls_right [simp]:
  22.185 -  "k + Pls = k"
  22.186 -  unfolding numeral_simps by simp 
  22.187 -
  22.188 -lemma add_Min_right [simp]:
  22.189 -  "k + Min = pred k"
  22.190 -  unfolding numeral_simps by simp 
  22.191 -
  22.192 -lemma mult_Pls [simp]:
  22.193 -  "Pls * w = Pls"
  22.194 -  unfolding numeral_simps by simp 
  22.195 -
  22.196 -lemma mult_Min [simp]:
  22.197 -  "Min * k = - k"
  22.198 -  unfolding numeral_simps by simp 
  22.199 -
  22.200 -lemma mult_num1 [simp]:
  22.201 -  "(k BIT B1) * l = ((k * l) BIT B0) + l"
  22.202 -  unfolding numeral_simps int_distrib by simp 
  22.203 -
  22.204 -lemma mult_num0 [simp]:
  22.205 -  "(k BIT B0) * l = (k * l) BIT B0"
  22.206 -  unfolding numeral_simps int_distrib by simp 
  22.207 -
  22.208 -
  22.209 -subsection {* Converting Numerals to Rings: @{term number_of} *}
  22.210 -
  22.211 -class number_ring = number + comm_ring_1 +
  22.212 -  assumes number_of_eq: "number_of k = of_int k"
  22.213 -
  22.214 -text {* self-embedding of the integers *}
  22.215 -
  22.216 -instantiation int :: number_ring
  22.217 -begin
  22.218 -
  22.219 -definition
  22.220 -  int_number_of_def [code func del]: "number_of w = (of_int w \<Colon> int)"
  22.221 -
  22.222 -instance
  22.223 -  by intro_classes (simp only: int_number_of_def)
  22.224 -
  22.225 -end
  22.226 -
  22.227 -lemma number_of_is_id:
  22.228 -  "number_of (k::int) = k"
  22.229 -  unfolding int_number_of_def by simp
  22.230 -
  22.231 -lemma number_of_succ:
  22.232 -  "number_of (succ k) = (1 + number_of k ::'a::number_ring)"
  22.233 -  unfolding number_of_eq numeral_simps by simp
  22.234 -
  22.235 -lemma number_of_pred:
  22.236 -  "number_of (pred w) = (- 1 + number_of w ::'a::number_ring)"
  22.237 -  unfolding number_of_eq numeral_simps by simp
  22.238 -
  22.239 -lemma number_of_minus:
  22.240 -  "number_of (uminus w) = (- (number_of w)::'a::number_ring)"
  22.241 -  unfolding number_of_eq numeral_simps by simp
  22.242 -
  22.243 -lemma number_of_add:
  22.244 -  "number_of (v + w) = (number_of v + number_of w::'a::number_ring)"
  22.245 -  unfolding number_of_eq numeral_simps by simp
  22.246 -
  22.247 -lemma number_of_mult:
  22.248 -  "number_of (v * w) = (number_of v * number_of w::'a::number_ring)"
  22.249 -  unfolding number_of_eq numeral_simps by simp
  22.250 -
  22.251 -text {*
  22.252 -  The correctness of shifting.
  22.253 -  But it doesn't seem to give a measurable speed-up.
  22.254 -*}
  22.255 -
  22.256 -lemma double_number_of_BIT:
  22.257 -  "(1 + 1) * number_of w = (number_of (w BIT B0) ::'a::number_ring)"
  22.258 -  unfolding number_of_eq numeral_simps left_distrib by simp
  22.259 -
  22.260 -text {*
  22.261 -  Converting numerals 0 and 1 to their abstract versions.
  22.262 -*}
  22.263 -
  22.264 -lemma numeral_0_eq_0 [simp]:
  22.265 -  "Numeral0 = (0::'a::number_ring)"
  22.266 -  unfolding number_of_eq numeral_simps by simp
  22.267 -
  22.268 -lemma numeral_1_eq_1 [simp]:
  22.269 -  "Numeral1 = (1::'a::number_ring)"
  22.270 -  unfolding number_of_eq numeral_simps by simp
  22.271 -
  22.272 -text {*
  22.273 -  Special-case simplification for small constants.
  22.274 -*}
  22.275 -
  22.276 -text{*
  22.277 -  Unary minus for the abstract constant 1. Cannot be inserted
  22.278 -  as a simprule until later: it is @{text number_of_Min} re-oriented!
  22.279 -*}
  22.280 -
  22.281 -lemma numeral_m1_eq_minus_1:
  22.282 -  "(-1::'a::number_ring) = - 1"
  22.283 -  unfolding number_of_eq numeral_simps by simp
  22.284 -
  22.285 -lemma mult_minus1 [simp]:
  22.286 -  "-1 * z = -(z::'a::number_ring)"
  22.287 -  unfolding number_of_eq numeral_simps by simp
  22.288 -
  22.289 -lemma mult_minus1_right [simp]:
  22.290 -  "z * -1 = -(z::'a::number_ring)"
  22.291 -  unfolding number_of_eq numeral_simps by simp
  22.292 -
  22.293 -(*Negation of a coefficient*)
  22.294 -lemma minus_number_of_mult [simp]:
  22.295 -   "- (number_of w) * z = number_of (uminus w) * (z::'a::number_ring)"
  22.296 -   unfolding number_of_eq by simp
  22.297 -
  22.298 -text {* Subtraction *}
  22.299 -
  22.300 -lemma diff_number_of_eq:
  22.301 -  "number_of v - number_of w =
  22.302 -    (number_of (v + uminus w)::'a::number_ring)"
  22.303 -  unfolding number_of_eq by simp
  22.304 -
  22.305 -lemma number_of_Pls:
  22.306 -  "number_of Pls = (0::'a::number_ring)"
  22.307 -  unfolding number_of_eq numeral_simps by simp
  22.308 -
  22.309 -lemma number_of_Min:
  22.310 -  "number_of Min = (- 1::'a::number_ring)"
  22.311 -  unfolding number_of_eq numeral_simps by simp
  22.312 -
  22.313 -lemma number_of_BIT:
  22.314 -  "number_of(w BIT x) = (case x of B0 => 0 | B1 => (1::'a::number_ring))
  22.315 -    + (number_of w) + (number_of w)"
  22.316 -  unfolding number_of_eq numeral_simps by (simp split: bit.split)
  22.317 -
  22.318 -
  22.319 -subsection {* Equality of Binary Numbers *}
  22.320 -
  22.321 -text {* First version by Norbert Voelker *}
  22.322 -
  22.323 -lemma eq_number_of_eq:
  22.324 -  "((number_of x::'a::number_ring) = number_of y) =
  22.325 -   iszero (number_of (x + uminus y) :: 'a)"
  22.326 -  unfolding iszero_def number_of_add number_of_minus
  22.327 -  by (simp add: compare_rls)
  22.328 -
  22.329 -lemma iszero_number_of_Pls:
  22.330 -  "iszero ((number_of Pls)::'a::number_ring)"
  22.331 -  unfolding iszero_def numeral_0_eq_0 ..
  22.332 -
  22.333 -lemma nonzero_number_of_Min:
  22.334 -  "~ iszero ((number_of Min)::'a::number_ring)"
  22.335 -  unfolding iszero_def numeral_m1_eq_minus_1 by simp
  22.336 -
  22.337 -
  22.338 -subsection {* Comparisons, for Ordered Rings *}
  22.339 -
  22.340 -lemmas double_eq_0_iff = double_zero
  22.341 -
  22.342 -lemma le_imp_0_less: 
  22.343 -  assumes le: "0 \<le> z"
  22.344 -  shows "(0::int) < 1 + z"
  22.345 -proof -
  22.346 -  have "0 \<le> z" by fact
  22.347 -  also have "... < z + 1" by (rule less_add_one) 
  22.348 -  also have "... = 1 + z" by (simp add: add_ac)
  22.349 -  finally show "0 < 1 + z" .
  22.350 -qed
  22.351 -
  22.352 -lemma odd_nonzero:
  22.353 -  "1 + z + z \<noteq> (0::int)";
  22.354 -proof (cases z rule: int_cases)
  22.355 -  case (nonneg n)
  22.356 -  have le: "0 \<le> z+z" by (simp add: nonneg add_increasing) 
  22.357 -  thus ?thesis using  le_imp_0_less [OF le]
  22.358 -    by (auto simp add: add_assoc) 
  22.359 -next
  22.360 -  case (neg n)
  22.361 -  show ?thesis
  22.362 -  proof
  22.363 -    assume eq: "1 + z + z = 0"
  22.364 -    have "0 < 1 + (int n + int n)"
  22.365 -      by (simp add: le_imp_0_less add_increasing) 
  22.366 -    also have "... = - (1 + z + z)" 
  22.367 -      by (simp add: neg add_assoc [symmetric]) 
  22.368 -    also have "... = 0" by (simp add: eq) 
  22.369 -    finally have "0<0" ..
  22.370 -    thus False by blast
  22.371 -  qed
  22.372 -qed
  22.373 -
  22.374 -text {* The premise involving @{term Ints} prevents @{term "a = 1/2"}. *}
  22.375 -
  22.376 -lemma Ints_double_eq_0_iff:
  22.377 -  assumes in_Ints: "a \<in> Ints"
  22.378 -  shows "(a + a = 0) = (a = (0::'a::ring_char_0))"
  22.379 -proof -
  22.380 -  from in_Ints have "a \<in> range of_int" unfolding Ints_def [symmetric] .
  22.381 -  then obtain z where a: "a = of_int z" ..
  22.382 -  show ?thesis
  22.383 -  proof
  22.384 -    assume "a = 0"
  22.385 -    thus "a + a = 0" by simp
  22.386 -  next
  22.387 -    assume eq: "a + a = 0"
  22.388 -    hence "of_int (z + z) = (of_int 0 :: 'a)" by (simp add: a)
  22.389 -    hence "z + z = 0" by (simp only: of_int_eq_iff)
  22.390 -    hence "z = 0" by (simp only: double_eq_0_iff)
  22.391 -    thus "a = 0" by (simp add: a)
  22.392 -  qed
  22.393 -qed
  22.394 -
  22.395 -lemma Ints_odd_nonzero:
  22.396 -  assumes in_Ints: "a \<in> Ints"
  22.397 -  shows "1 + a + a \<noteq> (0::'a::ring_char_0)"
  22.398 -proof -
  22.399 -  from in_Ints have "a \<in> range of_int" unfolding Ints_def [symmetric] .
  22.400 -  then obtain z where a: "a = of_int z" ..
  22.401 -  show ?thesis
  22.402 -  proof
  22.403 -    assume eq: "1 + a + a = 0"
  22.404 -    hence "of_int (1 + z + z) = (of_int 0 :: 'a)" by (simp add: a)
  22.405 -    hence "1 + z + z = 0" by (simp only: of_int_eq_iff)
  22.406 -    with odd_nonzero show False by blast
  22.407 -  qed
  22.408 -qed 
  22.409 -
  22.410 -lemma Ints_number_of:
  22.411 -  "(number_of w :: 'a::number_ring) \<in> Ints"
  22.412 -  unfolding number_of_eq Ints_def by simp
  22.413 -
  22.414 -lemma iszero_number_of_BIT:
  22.415 -  "iszero (number_of (w BIT x)::'a) = 
  22.416 -   (x = B0 \<and> iszero (number_of w::'a::{ring_char_0,number_ring}))"
  22.417 -  by (simp add: iszero_def number_of_eq numeral_simps Ints_double_eq_0_iff 
  22.418 -    Ints_odd_nonzero Ints_def split: bit.split)
  22.419 -
  22.420 -lemma iszero_number_of_0:
  22.421 -  "iszero (number_of (w BIT B0) :: 'a::{ring_char_0,number_ring}) = 
  22.422 -  iszero (number_of w :: 'a)"
  22.423 -  by (simp only: iszero_number_of_BIT simp_thms)
  22.424 -
  22.425 -lemma iszero_number_of_1:
  22.426 -  "~ iszero (number_of (w BIT B1)::'a::{ring_char_0,number_ring})"
  22.427 -  by (simp add: iszero_number_of_BIT) 
  22.428 -
  22.429 -
  22.430 -subsection {* The Less-Than Relation *}
  22.431 -
  22.432 -lemma less_number_of_eq_neg:
  22.433 -  "((number_of x::'a::{ordered_idom,number_ring}) < number_of y)
  22.434 -  = neg (number_of (x + uminus y) :: 'a)"
  22.435 -apply (subst less_iff_diff_less_0) 
  22.436 -apply (simp add: neg_def diff_minus number_of_add number_of_minus)
  22.437 -done
  22.438 -
  22.439 -text {*
  22.440 -  If @{term Numeral0} is rewritten to 0 then this rule can't be applied:
  22.441 -  @{term Numeral0} IS @{term "number_of Pls"}
  22.442 -*}
  22.443 -
  22.444 -lemma not_neg_number_of_Pls:
  22.445 -  "~ neg (number_of Pls ::'a::{ordered_idom,number_ring})"
  22.446 -  by (simp add: neg_def numeral_0_eq_0)
  22.447 -
  22.448 -lemma neg_number_of_Min:
  22.449 -  "neg (number_of Min ::'a::{ordered_idom,number_ring})"
  22.450 -  by (simp add: neg_def zero_less_one numeral_m1_eq_minus_1)
  22.451 -
  22.452 -lemma double_less_0_iff:
  22.453 -  "(a + a < 0) = (a < (0::'a::ordered_idom))"
  22.454 -proof -
  22.455 -  have "(a + a < 0) = ((1+1)*a < 0)" by (simp add: left_distrib)
  22.456 -  also have "... = (a < 0)"
  22.457 -    by (simp add: mult_less_0_iff zero_less_two 
  22.458 -                  order_less_not_sym [OF zero_less_two]) 
  22.459 -  finally show ?thesis .
  22.460 -qed
  22.461 -
  22.462 -lemma odd_less_0:
  22.463 -  "(1 + z + z < 0) = (z < (0::int))";
  22.464 -proof (cases z rule: int_cases)
  22.465 -  case (nonneg n)
  22.466 -  thus ?thesis by (simp add: linorder_not_less add_assoc add_increasing
  22.467 -                             le_imp_0_less [THEN order_less_imp_le])  
  22.468 -next
  22.469 -  case (neg n)
  22.470 -  thus ?thesis by (simp del: of_nat_Suc of_nat_add
  22.471 -    add: compare_rls of_nat_1 [symmetric] of_nat_add [symmetric])
  22.472 -qed
  22.473 -
  22.474 -text {* The premise involving @{term Ints} prevents @{term "a = 1/2"}. *}
  22.475 -
  22.476 -lemma Ints_odd_less_0: 
  22.477 -  assumes in_Ints: "a \<in> Ints"
  22.478 -  shows "(1 + a + a < 0) = (a < (0::'a::ordered_idom))";
  22.479 -proof -
  22.480 -  from in_Ints have "a \<in> range of_int" unfolding Ints_def [symmetric] .
  22.481 -  then obtain z where a: "a = of_int z" ..
  22.482 -  hence "((1::'a) + a + a < 0) = (of_int (1 + z + z) < (of_int 0 :: 'a))"
  22.483 -    by (simp add: a)
  22.484 -  also have "... = (z < 0)" by (simp only: of_int_less_iff odd_less_0)
  22.485 -  also have "... = (a < 0)" by (simp add: a)
  22.486 -  finally show ?thesis .
  22.487 -qed
  22.488 -
  22.489 -lemma neg_number_of_BIT:
  22.490 -  "neg (number_of (w BIT x)::'a) = 
  22.491 -  neg (number_of w :: 'a::{ordered_idom,number_ring})"
  22.492 -  by (simp add: neg_def number_of_eq numeral_simps double_less_0_iff
  22.493 -    Ints_odd_less_0 Ints_def split: bit.split)
  22.494 -
  22.495 -
  22.496 -text {* Less-Than or Equals *}
  22.497 -
  22.498 -text {* Reduces @{term "a\<le>b"} to @{term "~ (b<a)"} for ALL numerals. *}
  22.499 -
  22.500 -lemmas le_number_of_eq_not_less =
  22.501 -  linorder_not_less [of "number_of w" "number_of v", symmetric, 
  22.502 -  standard]
  22.503 -
  22.504 -lemma le_number_of_eq:
  22.505 -    "((number_of x::'a::{ordered_idom,number_ring}) \<le> number_of y)
  22.506 -     = (~ (neg (number_of (y + uminus x) :: 'a)))"
  22.507 -by (simp add: le_number_of_eq_not_less less_number_of_eq_neg)
  22.508 -
  22.509 -
  22.510 -text {* Absolute value (@{term abs}) *}
  22.511 -
  22.512 -lemma abs_number_of:
  22.513 -  "abs(number_of x::'a::{ordered_idom,number_ring}) =
  22.514 -   (if number_of x < (0::'a) then -number_of x else number_of x)"
  22.515 -  by (simp add: abs_if)
  22.516 -
  22.517 -
  22.518 -text {* Re-orientation of the equation nnn=x *}
  22.519 -
  22.520 -lemma number_of_reorient:
  22.521 -  "(number_of w = x) = (x = number_of w)"
  22.522 -  by auto
  22.523 -
  22.524 -
  22.525 -subsection {* Simplification of arithmetic operations on integer constants. *}
  22.526 -
  22.527 -lemmas arith_extra_simps [standard, simp] =
  22.528 -  number_of_add [symmetric]
  22.529 -  number_of_minus [symmetric] numeral_m1_eq_minus_1 [symmetric]
  22.530 -  number_of_mult [symmetric]
  22.531 -  diff_number_of_eq abs_number_of 
  22.532 -
  22.533 -text {*
  22.534 -  For making a minimal simpset, one must include these default simprules.
  22.535 -  Also include @{text simp_thms}.
  22.536 -*}
  22.537 -
  22.538 -lemmas arith_simps = 
  22.539 -  bit.distinct
  22.540 -  Pls_0_eq Min_1_eq
  22.541 -  pred_Pls pred_Min pred_1 pred_0
  22.542 -  succ_Pls succ_Min succ_1 succ_0
  22.543 -  add_Pls add_Min add_BIT_0 add_BIT_10 add_BIT_11
  22.544 -  minus_Pls minus_Min minus_1 minus_0
  22.545 -  mult_Pls mult_Min mult_num1 mult_num0 
  22.546 -  add_Pls_right add_Min_right
  22.547 -  abs_zero abs_one arith_extra_simps
  22.548 -
  22.549 -text {* Simplification of relational operations *}
  22.550 -
  22.551 -lemmas rel_simps [simp] = 
  22.552 -  eq_number_of_eq iszero_0 nonzero_number_of_Min
  22.553 -  iszero_number_of_0 iszero_number_of_1
  22.554 -  less_number_of_eq_neg
  22.555 -  not_neg_number_of_Pls not_neg_0 not_neg_1 not_iszero_1
  22.556 -  neg_number_of_Min neg_number_of_BIT
  22.557 -  le_number_of_eq
  22.558 -(* iszero_number_of_Pls would never be used
  22.559 -   because its lhs simplifies to "iszero 0" *)
  22.560 -
  22.561 -
  22.562 -subsection {* Simplification of arithmetic when nested to the right. *}
  22.563 -
  22.564 -lemma add_number_of_left [simp]:
  22.565 -  "number_of v + (number_of w + z) =
  22.566 -   (number_of(v + w) + z::'a::number_ring)"
  22.567 -  by (simp add: add_assoc [symmetric])
  22.568 -
  22.569 -lemma mult_number_of_left [simp]:
  22.570 -  "number_of v * (number_of w * z) =
  22.571 -   (number_of(v * w) * z::'a::number_ring)"
  22.572 -  by (simp add: mult_assoc [symmetric])
  22.573 -
  22.574 -lemma add_number_of_diff1:
  22.575 -  "number_of v + (number_of w - c) = 
  22.576 -  number_of(v + w) - (c::'a::number_ring)"
  22.577 -  by (simp add: diff_minus add_number_of_left)
  22.578 -
  22.579 -lemma add_number_of_diff2 [simp]:
  22.580 -  "number_of v + (c - number_of w) =
  22.581 -   number_of (v + uminus w) + (c::'a::number_ring)"
  22.582 -apply (subst diff_number_of_eq [symmetric])
  22.583 -apply (simp only: compare_rls)
  22.584 -done
  22.585 -
  22.586 -
  22.587 -subsection {* Configuration of the code generator *}
  22.588 -
  22.589 -instance int :: eq ..
  22.590 -
  22.591 -code_datatype Pls Min Bit "number_of \<Colon> int \<Rightarrow> int"
  22.592 -
  22.593 -definition
  22.594 -  int_aux :: "nat \<Rightarrow> int \<Rightarrow> int" where
  22.595 -  "int_aux n i = int n + i"
  22.596 -
  22.597 -lemma [code]:
  22.598 -  "int_aux 0 i  = i"
  22.599 -  "int_aux (Suc n) i = int_aux n (i + 1)" -- {* tail recursive *}
  22.600 -  by (simp add: int_aux_def)+
  22.601 -
  22.602 -lemma [code, code unfold, code inline del]:
  22.603 -  "int n = int_aux n 0"
  22.604 -  by (simp add: int_aux_def)
  22.605 -
  22.606 -definition
  22.607 -  nat_aux :: "int \<Rightarrow> nat \<Rightarrow> nat" where
  22.608 -  "nat_aux i n = nat i + n"
  22.609 -
  22.610 -lemma [code]:
  22.611 -  "nat_aux i n = (if i \<le> 0 then n else nat_aux (i - 1) (Suc n))"  -- {* tail recursive *}
  22.612 -  by (auto simp add: nat_aux_def nat_eq_iff linorder_not_le order_less_imp_le
  22.613 -    dest: zless_imp_add1_zle)
  22.614 -
  22.615 -lemma [code]: "nat i = nat_aux i 0"
  22.616 -  by (simp add: nat_aux_def)
  22.617 -
  22.618 -lemma zero_is_num_zero [code func, code inline, symmetric, code post]:
  22.619 -  "(0\<Colon>int) = Numeral0" 
  22.620 -  by simp
  22.621 -
  22.622 -lemma one_is_num_one [code func, code inline, symmetric, code post]:
  22.623 -  "(1\<Colon>int) = Numeral1" 
  22.624 -  by simp 
  22.625 -
  22.626 -code_modulename SML
  22.627 -  IntDef Integer
  22.628 -
  22.629 -code_modulename OCaml
  22.630 -  IntDef Integer
  22.631 -
  22.632 -code_modulename Haskell
  22.633 -  IntDef Integer
  22.634 -
  22.635 -code_modulename SML
  22.636 -  Numeral Integer
  22.637 -
  22.638 -code_modulename OCaml
  22.639 -  Numeral Integer
  22.640 -
  22.641 -code_modulename Haskell
  22.642 -  Numeral Integer
  22.643 -
  22.644 -types_code
  22.645 -  "int" ("int")
  22.646 -attach (term_of) {*
  22.647 -val term_of_int = HOLogic.mk_number HOLogic.intT;
  22.648 -*}
  22.649 -attach (test) {*
  22.650 -fun gen_int i =
  22.651 -  let val j = one_of [~1, 1] * random_range 0 i
  22.652 -  in (j, fn () => term_of_int j) end;
  22.653 -*}
  22.654 -
  22.655 -setup {*
  22.656 -let
  22.657 -
  22.658 -fun strip_number_of (@{term "Numeral.number_of :: int => int"} $ t) = t
  22.659 -  | strip_number_of t = t;
  22.660 -
  22.661 -fun numeral_codegen thy defs gr dep module b t =
  22.662 -  let val i = HOLogic.dest_numeral (strip_number_of t)
  22.663 -  in
  22.664 -    SOME (fst (Codegen.invoke_tycodegen thy defs dep module false (gr, HOLogic.intT)),
  22.665 -      Pretty.str (string_of_int i))
  22.666 -  end handle TERM _ => NONE;
  22.667 -
  22.668 -in
  22.669 -
  22.670 -Codegen.add_codegen "numeral_codegen" numeral_codegen
  22.671 -
  22.672 -end
  22.673 -*}
  22.674 -
  22.675 -consts_code
  22.676 -  "number_of :: int \<Rightarrow> int"    ("(_)")
  22.677 -  "0 :: int"                   ("0")
  22.678 -  "1 :: int"                   ("1")
  22.679 -  "uminus :: int => int"       ("~")
  22.680 -  "op + :: int => int => int"  ("(_ +/ _)")
  22.681 -  "op * :: int => int => int"  ("(_ */ _)")
  22.682 -  "op \<le> :: int => int => bool" ("(_ <=/ _)")
  22.683 -  "op < :: int => int => bool" ("(_ </ _)")
  22.684 -
  22.685 -quickcheck_params [default_type = int]
  22.686 -
  22.687 -(*setup continues in theory Presburger*)
  22.688 -
  22.689 -hide (open) const Pls Min B0 B1 succ pred
  22.690 -
  22.691 -end
    23.1 --- a/src/HOL/Presburger.thy	Tue Jan 15 16:19:21 2008 +0100
    23.2 +++ b/src/HOL/Presburger.thy	Tue Jan 15 16:19:23 2008 +0100
    23.3 @@ -496,53 +496,53 @@
    23.4  *}
    23.5  
    23.6  lemma eq_Pls_Pls:
    23.7 -  "Numeral.Pls = Numeral.Pls \<longleftrightarrow> True" by presburger
    23.8 +  "Int.Pls = Int.Pls \<longleftrightarrow> True" by presburger
    23.9  
   23.10  lemma eq_Pls_Min:
   23.11 -  "Numeral.Pls = Numeral.Min \<longleftrightarrow> False"
   23.12 -  unfolding Pls_def Numeral.Min_def by presburger
   23.13 +  "Int.Pls = Int.Min \<longleftrightarrow> False"
   23.14 +  unfolding Pls_def Int.Min_def by presburger
   23.15  
   23.16  lemma eq_Pls_Bit0:
   23.17 -  "Numeral.Pls = Numeral.Bit k bit.B0 \<longleftrightarrow> Numeral.Pls = k"
   23.18 +  "Int.Pls = Int.Bit k bit.B0 \<longleftrightarrow> Int.Pls = k"
   23.19    unfolding Pls_def Bit_def bit.cases by presburger
   23.20  
   23.21  lemma eq_Pls_Bit1:
   23.22 -  "Numeral.Pls = Numeral.Bit k bit.B1 \<longleftrightarrow> False"
   23.23 +  "Int.Pls = Int.Bit k bit.B1 \<longleftrightarrow> False"
   23.24    unfolding Pls_def Bit_def bit.cases by presburger
   23.25  
   23.26  lemma eq_Min_Pls:
   23.27 -  "Numeral.Min = Numeral.Pls \<longleftrightarrow> False"
   23.28 -  unfolding Pls_def Numeral.Min_def by presburger
   23.29 +  "Int.Min = Int.Pls \<longleftrightarrow> False"
   23.30 +  unfolding Pls_def Int.Min_def by presburger
   23.31  
   23.32  lemma eq_Min_Min:
   23.33 -  "Numeral.Min = Numeral.Min \<longleftrightarrow> True" by presburger
   23.34 +  "Int.Min = Int.Min \<longleftrightarrow> True" by presburger
   23.35  
   23.36  lemma eq_Min_Bit0:
   23.37 -  "Numeral.Min = Numeral.Bit k bit.B0 \<longleftrightarrow> False"
   23.38 -  unfolding Numeral.Min_def Bit_def bit.cases by presburger
   23.39 +  "Int.Min = Int.Bit k bit.B0 \<longleftrightarrow> False"
   23.40 +  unfolding Int.Min_def Bit_def bit.cases by presburger
   23.41  
   23.42  lemma eq_Min_Bit1:
   23.43 -  "Numeral.Min = Numeral.Bit k bit.B1 \<longleftrightarrow> Numeral.Min = k"
   23.44 -  unfolding Numeral.Min_def Bit_def bit.cases by presburger
   23.45 +  "Int.Min = Int.Bit k bit.B1 \<longleftrightarrow> Int.Min = k"
   23.46 +  unfolding Int.Min_def Bit_def bit.cases by presburger
   23.47  
   23.48  lemma eq_Bit0_Pls:
   23.49 -  "Numeral.Bit k bit.B0 = Numeral.Pls \<longleftrightarrow> Numeral.Pls = k"
   23.50 +  "Int.Bit k bit.B0 = Int.Pls \<longleftrightarrow> Int.Pls = k"
   23.51    unfolding Pls_def Bit_def bit.cases by presburger
   23.52  
   23.53  lemma eq_Bit1_Pls:
   23.54 -  "Numeral.Bit k bit.B1 = Numeral.Pls \<longleftrightarrow> False"
   23.55 +  "Int.Bit k bit.B1 = Int.Pls \<longleftrightarrow> False"
   23.56    unfolding Pls_def Bit_def bit.cases  by presburger
   23.57  
   23.58  lemma eq_Bit0_Min:
   23.59 -  "Numeral.Bit k bit.B0 = Numeral.Min \<longleftrightarrow> False"
   23.60 -  unfolding Numeral.Min_def Bit_def bit.cases  by presburger
   23.61 +  "Int.Bit k bit.B0 = Int.Min \<longleftrightarrow> False"
   23.62 +  unfolding Int.Min_def Bit_def bit.cases  by presburger
   23.63  
   23.64  lemma eq_Bit1_Min:
   23.65 -  "(Numeral.Bit k bit.B1) = Numeral.Min \<longleftrightarrow> Numeral.Min = k"
   23.66 -  unfolding Numeral.Min_def Bit_def bit.cases  by presburger
   23.67 +  "(Int.Bit k bit.B1) = Int.Min \<longleftrightarrow> Int.Min = k"
   23.68 +  unfolding Int.Min_def Bit_def bit.cases  by presburger
   23.69  
   23.70  lemma eq_Bit_Bit:
   23.71 -  "Numeral.Bit k1 v1 = Numeral.Bit k2 v2 \<longleftrightarrow>
   23.72 +  "Int.Bit k1 v1 = Int.Bit k2 v2 \<longleftrightarrow>
   23.73      v1 = v2 \<and> k1 = k2" 
   23.74    unfolding Bit_def
   23.75    apply (cases v1)
   23.76 @@ -562,53 +562,53 @@
   23.77  
   23.78  
   23.79  lemma less_eq_Pls_Pls:
   23.80 -  "Numeral.Pls \<le> Numeral.Pls \<longleftrightarrow> True" by rule+
   23.81 +  "Int.Pls \<le> Int.Pls \<longleftrightarrow> True" by rule+
   23.82  
   23.83  lemma less_eq_Pls_Min:
   23.84 -  "Numeral.Pls \<le> Numeral.Min \<longleftrightarrow> False"
   23.85 -  unfolding Pls_def Numeral.Min_def by presburger
   23.86 +  "Int.Pls \<le> Int.Min \<longleftrightarrow> False"
   23.87 +  unfolding Pls_def Int.Min_def by presburger
   23.88  
   23.89  lemma less_eq_Pls_Bit:
   23.90 -  "Numeral.Pls \<le> Numeral.Bit k v \<longleftrightarrow> Numeral.Pls \<le> k"
   23.91 +  "Int.Pls \<le> Int.Bit k v \<longleftrightarrow> Int.Pls \<le> k"
   23.92    unfolding Pls_def Bit_def by (cases v) auto
   23.93  
   23.94  lemma less_eq_Min_Pls:
   23.95 -  "Numeral.Min \<le> Numeral.Pls \<longleftrightarrow> True"
   23.96 -  unfolding Pls_def Numeral.Min_def by presburger
   23.97 +  "Int.Min \<le> Int.Pls \<longleftrightarrow> True"
   23.98 +  unfolding Pls_def Int.Min_def by presburger
   23.99  
  23.100  lemma less_eq_Min_Min:
  23.101 -  "Numeral.Min \<le> Numeral.Min \<longleftrightarrow> True" by rule+
  23.102 +  "Int.Min \<le> Int.Min \<longleftrightarrow> True" by rule+
  23.103  
  23.104  lemma less_eq_Min_Bit0:
  23.105 -  "Numeral.Min \<le> Numeral.Bit k bit.B0 \<longleftrightarrow> Numeral.Min < k"
  23.106 -  unfolding Numeral.Min_def Bit_def by auto
  23.107 +  "Int.Min \<le> Int.Bit k bit.B0 \<longleftrightarrow> Int.Min < k"
  23.108 +  unfolding Int.Min_def Bit_def by auto
  23.109  
  23.110  lemma less_eq_Min_Bit1:
  23.111 -  "Numeral.Min \<le> Numeral.Bit k bit.B1 \<longleftrightarrow> Numeral.Min \<le> k"
  23.112 -  unfolding Numeral.Min_def Bit_def by auto
  23.113 +  "Int.Min \<le> Int.Bit k bit.B1 \<longleftrightarrow> Int.Min \<le> k"
  23.114 +  unfolding Int.Min_def Bit_def by auto
  23.115  
  23.116  lemma less_eq_Bit0_Pls:
  23.117 -  "Numeral.Bit k bit.B0 \<le> Numeral.Pls \<longleftrightarrow> k \<le> Numeral.Pls"
  23.118 +  "Int.Bit k bit.B0 \<le> Int.Pls \<longleftrightarrow> k \<le> Int.Pls"
  23.119    unfolding Pls_def Bit_def by simp
  23.120  
  23.121  lemma less_eq_Bit1_Pls:
  23.122 -  "Numeral.Bit k bit.B1 \<le> Numeral.Pls \<longleftrightarrow> k < Numeral.Pls"
  23.123 +  "Int.Bit k bit.B1 \<le> Int.Pls \<longleftrightarrow> k < Int.Pls"
  23.124    unfolding Pls_def Bit_def by auto
  23.125  
  23.126  lemma less_eq_Bit_Min:
  23.127 -  "Numeral.Bit k v \<le> Numeral.Min \<longleftrightarrow> k \<le> Numeral.Min"
  23.128 -  unfolding Numeral.Min_def Bit_def by (cases v) auto
  23.129 +  "Int.Bit k v \<le> Int.Min \<longleftrightarrow> k \<le> Int.Min"
  23.130 +  unfolding Int.Min_def Bit_def by (cases v) auto
  23.131  
  23.132  lemma less_eq_Bit0_Bit:
  23.133 -  "Numeral.Bit k1 bit.B0 \<le> Numeral.Bit k2 v \<longleftrightarrow> k1 \<le> k2"
  23.134 +  "Int.Bit k1 bit.B0 \<le> Int.Bit k2 v \<longleftrightarrow> k1 \<le> k2"
  23.135    unfolding Bit_def bit.cases by (cases v) auto
  23.136  
  23.137  lemma less_eq_Bit_Bit1:
  23.138 -  "Numeral.Bit k1 v \<le> Numeral.Bit k2 bit.B1 \<longleftrightarrow> k1 \<le> k2"
  23.139 +  "Int.Bit k1 v \<le> Int.Bit k2 bit.B1 \<longleftrightarrow> k1 \<le> k2"
  23.140    unfolding Bit_def bit.cases by (cases v) auto
  23.141  
  23.142  lemma less_eq_Bit1_Bit0:
  23.143 -  "Numeral.Bit k1 bit.B1 \<le> Numeral.Bit k2 bit.B0 \<longleftrightarrow> k1 < k2"
  23.144 +  "Int.Bit k1 bit.B1 \<le> Int.Bit k2 bit.B0 \<longleftrightarrow> k1 < k2"
  23.145    unfolding Bit_def by (auto split: bit.split)
  23.146  
  23.147  lemma less_eq_number_of:
  23.148 @@ -617,53 +617,53 @@
  23.149  
  23.150  
  23.151  lemma less_Pls_Pls:
  23.152 -  "Numeral.Pls < Numeral.Pls \<longleftrightarrow> False" by simp 
  23.153 +  "Int.Pls < Int.Pls \<longleftrightarrow> False" by simp 
  23.154  
  23.155  lemma less_Pls_Min:
  23.156 -  "Numeral.Pls < Numeral.Min \<longleftrightarrow> False"
  23.157 -  unfolding Pls_def Numeral.Min_def  by presburger 
  23.158 +  "Int.Pls < Int.Min \<longleftrightarrow> False"
  23.159 +  unfolding Pls_def Int.Min_def  by presburger 
  23.160  
  23.161  lemma less_Pls_Bit0:
  23.162 -  "Numeral.Pls < Numeral.Bit k bit.B0 \<longleftrightarrow> Numeral.Pls < k"
  23.163 +  "Int.Pls < Int.Bit k bit.B0 \<longleftrightarrow> Int.Pls < k"
  23.164    unfolding Pls_def Bit_def by auto
  23.165  
  23.166  lemma less_Pls_Bit1:
  23.167 -  "Numeral.Pls < Numeral.Bit k bit.B1 \<longleftrightarrow> Numeral.Pls \<le> k"
  23.168 +  "Int.Pls < Int.Bit k bit.B1 \<longleftrightarrow> Int.Pls \<le> k"
  23.169    unfolding Pls_def Bit_def by auto
  23.170  
  23.171  lemma less_Min_Pls:
  23.172 -  "Numeral.Min < Numeral.Pls \<longleftrightarrow> True"
  23.173 -  unfolding Pls_def Numeral.Min_def by presburger 
  23.174 +  "Int.Min < Int.Pls \<longleftrightarrow> True"
  23.175 +  unfolding Pls_def Int.Min_def by presburger 
  23.176  
  23.177  lemma less_Min_Min:
  23.178 -  "Numeral.Min < Numeral.Min \<longleftrightarrow> False"  by simp
  23.179 +  "Int.Min < Int.Min \<longleftrightarrow> False"  by simp
  23.180  
  23.181  lemma less_Min_Bit:
  23.182 -  "Numeral.Min < Numeral.Bit k v \<longleftrightarrow> Numeral.Min < k"
  23.183 -  unfolding Numeral.Min_def Bit_def by (auto split: bit.split)
  23.184 +  "Int.Min < Int.Bit k v \<longleftrightarrow> Int.Min < k"
  23.185 +  unfolding Int.Min_def Bit_def by (auto split: bit.split)
  23.186  
  23.187  lemma less_Bit_Pls:
  23.188 -  "Numeral.Bit k v < Numeral.Pls \<longleftrightarrow> k < Numeral.Pls"
  23.189 +  "Int.Bit k v < Int.Pls \<longleftrightarrow> k < Int.Pls"
  23.190    unfolding Pls_def Bit_def by (auto split: bit.split)
  23.191  
  23.192  lemma less_Bit0_Min:
  23.193 -  "Numeral.Bit k bit.B0 < Numeral.Min \<longleftrightarrow> k \<le> Numeral.Min"
  23.194 -  unfolding Numeral.Min_def Bit_def by auto
  23.195 +  "Int.Bit k bit.B0 < Int.Min \<longleftrightarrow> k \<le> Int.Min"
  23.196 +  unfolding Int.Min_def Bit_def by auto
  23.197  
  23.198  lemma less_Bit1_Min:
  23.199 -  "Numeral.Bit k bit.B1 < Numeral.Min \<longleftrightarrow> k < Numeral.Min"
  23.200 -  unfolding Numeral.Min_def Bit_def by auto
  23.201 +  "Int.Bit k bit.B1 < Int.Min \<longleftrightarrow> k < Int.Min"
  23.202 +  unfolding Int.Min_def Bit_def by auto
  23.203  
  23.204  lemma less_Bit_Bit0:
  23.205 -  "Numeral.Bit k1 v < Numeral.Bit k2 bit.B0 \<longleftrightarrow> k1 < k2"
  23.206 +  "Int.Bit k1 v < Int.Bit k2 bit.B0 \<longleftrightarrow> k1 < k2"
  23.207    unfolding Bit_def by (auto split: bit.split)
  23.208  
  23.209  lemma less_Bit1_Bit:
  23.210 -  "Numeral.Bit k1 bit.B1 < Numeral.Bit k2 v \<longleftrightarrow> k1 < k2"
  23.211 +  "Int.Bit k1 bit.B1 < Int.Bit k2 v \<longleftrightarrow> k1 < k2"
  23.212    unfolding Bit_def by (auto split: bit.split)
  23.213  
  23.214  lemma less_Bit0_Bit1:
  23.215 -  "Numeral.Bit k1 bit.B0 < Numeral.Bit k2 bit.B1 \<longleftrightarrow> k1 \<le> k2"
  23.216 +  "Int.Bit k1 bit.B0 < Int.Bit k2 bit.B1 \<longleftrightarrow> k1 \<le> k2"
  23.217    unfolding Bit_def bit.cases  by arith
  23.218  
  23.219  lemma less_number_of:
    24.1 --- a/src/HOL/SetInterval.thy	Tue Jan 15 16:19:21 2008 +0100
    24.2 +++ b/src/HOL/SetInterval.thy	Tue Jan 15 16:19:23 2008 +0100
    24.3 @@ -10,7 +10,7 @@
    24.4  header {* Set intervals *}
    24.5  
    24.6  theory SetInterval
    24.7 -imports IntArith
    24.8 +imports Int
    24.9  begin
   24.10  
   24.11  context ord
    25.1 --- a/src/HOL/Tools/ComputeNumeral.thy	Tue Jan 15 16:19:21 2008 +0100
    25.2 +++ b/src/HOL/Tools/ComputeNumeral.thy	Tue Jan 15 16:19:23 2008 +0100
    25.3 @@ -6,84 +6,84 @@
    25.4  lemmas bitnorm = Pls_0_eq Min_1_eq
    25.5  
    25.6  (* neg for bit strings *)
    25.7 -lemma neg1: "neg Numeral.Pls = False" by (simp add: Numeral.Pls_def)
    25.8 -lemma neg2: "neg Numeral.Min = True" apply (subst Numeral.Min_def) by auto
    25.9 -lemma neg3: "neg (x BIT Numeral.B0) = neg x" apply (simp add: neg_def) apply (subst Bit_def) by auto
   25.10 -lemma neg4: "neg (x BIT Numeral.B1) = neg x" apply (simp add: neg_def) apply (subst Bit_def) by auto  
   25.11 +lemma neg1: "neg Int.Pls = False" by (simp add: Int.Pls_def)
   25.12 +lemma neg2: "neg Int.Min = True" apply (subst Int.Min_def) by auto
   25.13 +lemma neg3: "neg (x BIT Int.B0) = neg x" apply (simp add: neg_def) apply (subst Bit_def) by auto
   25.14 +lemma neg4: "neg (x BIT Int.B1) = neg x" apply (simp add: neg_def) apply (subst Bit_def) by auto  
   25.15  lemmas bitneg = neg1 neg2 neg3 neg4
   25.16  
   25.17  (* iszero for bit strings *)
   25.18 -lemma iszero1: "iszero Numeral.Pls = True" by (simp add: Numeral.Pls_def iszero_def)
   25.19 -lemma iszero2: "iszero Numeral.Min = False" apply (subst Numeral.Min_def) apply (subst iszero_def) by simp
   25.20 -lemma iszero3: "iszero (x BIT Numeral.B0) = iszero x" apply (subst Numeral.Bit_def) apply (subst iszero_def)+ by auto
   25.21 -lemma iszero4: "iszero (x BIT Numeral.B1) = False" apply (subst Numeral.Bit_def) apply (subst iszero_def)+  apply simp by arith
   25.22 +lemma iszero1: "iszero Int.Pls = True" by (simp add: Int.Pls_def iszero_def)
   25.23 +lemma iszero2: "iszero Int.Min = False" apply (subst Int.Min_def) apply (subst iszero_def) by simp
   25.24 +lemma iszero3: "iszero (x BIT Int.B0) = iszero x" apply (subst Int.Bit_def) apply (subst iszero_def)+ by auto
   25.25 +lemma iszero4: "iszero (x BIT Int.B1) = False" apply (subst Int.Bit_def) apply (subst iszero_def)+  apply simp by arith
   25.26  lemmas bitiszero = iszero1 iszero2 iszero3 iszero4
   25.27  
   25.28  (* lezero for bit strings *)
   25.29  constdefs
   25.30    "lezero x == (x \<le> 0)"
   25.31 -lemma lezero1: "lezero Numeral.Pls = True" unfolding Numeral.Pls_def lezero_def by auto
   25.32 -lemma lezero2: "lezero Numeral.Min = True" unfolding Numeral.Min_def lezero_def by auto
   25.33 -lemma lezero3: "lezero (x BIT Numeral.B0) = lezero x" unfolding Numeral.Bit_def lezero_def by auto
   25.34 -lemma lezero4: "lezero (x BIT Numeral.B1) = neg x" unfolding Numeral.Bit_def lezero_def neg_def by auto
   25.35 +lemma lezero1: "lezero Int.Pls = True" unfolding Int.Pls_def lezero_def by auto
   25.36 +lemma lezero2: "lezero Int.Min = True" unfolding Int.Min_def lezero_def by auto
   25.37 +lemma lezero3: "lezero (x BIT Int.B0) = lezero x" unfolding Int.Bit_def lezero_def by auto
   25.38 +lemma lezero4: "lezero (x BIT Int.B1) = neg x" unfolding Int.Bit_def lezero_def neg_def by auto
   25.39  lemmas bitlezero = lezero1 lezero2 lezero3 lezero4
   25.40  
   25.41  (* equality for bit strings *)
   25.42 -lemma biteq1: "(Numeral.Pls = Numeral.Pls) = True" by auto
   25.43 -lemma biteq2: "(Numeral.Min = Numeral.Min) = True" by auto
   25.44 -lemma biteq3: "(Numeral.Pls = Numeral.Min) = False" unfolding Pls_def Min_def by auto
   25.45 -lemma biteq4: "(Numeral.Min = Numeral.Pls) = False" unfolding Pls_def Min_def by auto
   25.46 -lemma biteq5: "(x BIT Numeral.B0 = y BIT Numeral.B0) = (x = y)" unfolding Bit_def by auto
   25.47 -lemma biteq6: "(x BIT Numeral.B1 = y BIT Numeral.B1) = (x = y)" unfolding Bit_def by auto
   25.48 -lemma biteq7: "(x BIT Numeral.B0 = y BIT Numeral.B1) = False" unfolding Bit_def by (simp, arith) 
   25.49 -lemma biteq8: "(x BIT Numeral.B1 = y BIT Numeral.B0) = False" unfolding Bit_def by (simp, arith)
   25.50 -lemma biteq9: "(Numeral.Pls = x BIT Numeral.B0) = (Numeral.Pls = x)" unfolding Bit_def Pls_def by auto
   25.51 -lemma biteq10: "(Numeral.Pls = x BIT Numeral.B1) = False" unfolding Bit_def Pls_def by (simp, arith) 
   25.52 -lemma biteq11: "(Numeral.Min = x BIT Numeral.B0) = False" unfolding Bit_def Min_def by (simp, arith)
   25.53 -lemma biteq12: "(Numeral.Min = x BIT Numeral.B1) = (Numeral.Min = x)" unfolding Bit_def Min_def by auto
   25.54 -lemma biteq13: "(x BIT Numeral.B0 = Numeral.Pls) = (x = Numeral.Pls)" unfolding Bit_def Pls_def by auto
   25.55 -lemma biteq14: "(x BIT Numeral.B1 = Numeral.Pls) = False" unfolding Bit_def Pls_def by (simp, arith)
   25.56 -lemma biteq15: "(x BIT Numeral.B0 = Numeral.Min) = False" unfolding Bit_def Pls_def Min_def by (simp, arith)
   25.57 -lemma biteq16: "(x BIT Numeral.B1 = Numeral.Min) = (x = Numeral.Min)" unfolding Bit_def Min_def by (simp, arith)
   25.58 +lemma biteq1: "(Int.Pls = Int.Pls) = True" by auto
   25.59 +lemma biteq2: "(Int.Min = Int.Min) = True" by auto
   25.60 +lemma biteq3: "(Int.Pls = Int.Min) = False" unfolding Pls_def Min_def by auto
   25.61 +lemma biteq4: "(Int.Min = Int.Pls) = False" unfolding Pls_def Min_def by auto
   25.62 +lemma biteq5: "(x BIT Int.B0 = y BIT Int.B0) = (x = y)" unfolding Bit_def by auto
   25.63 +lemma biteq6: "(x BIT Int.B1 = y BIT Int.B1) = (x = y)" unfolding Bit_def by auto
   25.64 +lemma biteq7: "(x BIT Int.B0 = y BIT Int.B1) = False" unfolding Bit_def by (simp, arith) 
   25.65 +lemma biteq8: "(x BIT Int.B1 = y BIT Int.B0) = False" unfolding Bit_def by (simp, arith)
   25.66 +lemma biteq9: "(Int.Pls = x BIT Int.B0) = (Int.Pls = x)" unfolding Bit_def Pls_def by auto
   25.67 +lemma biteq10: "(Int.Pls = x BIT Int.B1) = False" unfolding Bit_def Pls_def by (simp, arith) 
   25.68 +lemma biteq11: "(Int.Min = x BIT Int.B0) = False" unfolding Bit_def Min_def by (simp, arith)
   25.69 +lemma biteq12: "(Int.Min = x BIT Int.B1) = (Int.Min = x)" unfolding Bit_def Min_def by auto
   25.70 +lemma biteq13: "(x BIT Int.B0 = Int.Pls) = (x = Int.Pls)" unfolding Bit_def Pls_def by auto
   25.71 +lemma biteq14: "(x BIT Int.B1 = Int.Pls) = False" unfolding Bit_def Pls_def by (simp, arith)
   25.72 +lemma biteq15: "(x BIT Int.B0 = Int.Min) = False" unfolding Bit_def Pls_def Min_def by (simp, arith)
   25.73 +lemma biteq16: "(x BIT Int.B1 = Int.Min) = (x = Int.Min)" unfolding Bit_def Min_def by (simp, arith)
   25.74  lemmas biteq = biteq1 biteq2 biteq3 biteq4 biteq5 biteq6 biteq7 biteq8 biteq9 biteq10 biteq11 biteq12 biteq13 biteq14 biteq15 biteq16
   25.75  
   25.76  (* x < y for bit strings *)
   25.77 -lemma bitless1: "(Numeral.Pls < Numeral.Min) = False" unfolding Pls_def Min_def by auto
   25.78 -lemma bitless2: "(Numeral.Pls < Numeral.Pls) = False" by auto
   25.79 -lemma bitless3: "(Numeral.Min < Numeral.Pls) = True" unfolding Pls_def Min_def by auto
   25.80 -lemma bitless4: "(Numeral.Min < Numeral.Min) = False" unfolding Pls_def Min_def by auto
   25.81 -lemma bitless5: "(x BIT Numeral.B0 < y BIT Numeral.B0) = (x < y)" unfolding Bit_def by auto
   25.82 -lemma bitless6: "(x BIT Numeral.B1 < y BIT Numeral.B1) = (x < y)" unfolding Bit_def by auto
   25.83 -lemma bitless7: "(x BIT Numeral.B0 < y BIT Numeral.B1) = (x \<le> y)" unfolding Bit_def by auto
   25.84 -lemma bitless8: "(x BIT Numeral.B1 < y BIT Numeral.B0) = (x < y)" unfolding Bit_def by auto
   25.85 -lemma bitless9: "(Numeral.Pls < x BIT Numeral.B0) = (Numeral.Pls < x)" unfolding Bit_def Pls_def by auto
   25.86 -lemma bitless10: "(Numeral.Pls < x BIT Numeral.B1) = (Numeral.Pls \<le> x)" unfolding Bit_def Pls_def by auto
   25.87 -lemma bitless11: "(Numeral.Min < x BIT Numeral.B0) = (Numeral.Pls \<le> x)" unfolding Bit_def Pls_def Min_def by auto
   25.88 -lemma bitless12: "(Numeral.Min < x BIT Numeral.B1) = (Numeral.Min < x)" unfolding Bit_def Min_def by auto
   25.89 -lemma bitless13: "(x BIT Numeral.B0 < Numeral.Pls) = (x < Numeral.Pls)" unfolding Bit_def Pls_def by auto
   25.90 -lemma bitless14: "(x BIT Numeral.B1 < Numeral.Pls) = (x < Numeral.Pls)" unfolding Bit_def Pls_def by auto
   25.91 -lemma bitless15: "(x BIT Numeral.B0 < Numeral.Min) = (x < Numeral.Pls)" unfolding Bit_def Pls_def Min_def by auto
   25.92 -lemma bitless16: "(x BIT Numeral.B1 < Numeral.Min) = (x < Numeral.Min)" unfolding Bit_def Min_def by auto
   25.93 +lemma bitless1: "(Int.Pls < Int.Min) = False" unfolding Pls_def Min_def by auto
   25.94 +lemma bitless2: "(Int.Pls < Int.Pls) = False" by auto
   25.95 +lemma bitless3: "(Int.Min < Int.Pls) = True" unfolding Pls_def Min_def by auto
   25.96 +lemma bitless4: "(Int.Min < Int.Min) = False" unfolding Pls_def Min_def by auto
   25.97 +lemma bitless5: "(x BIT Int.B0 < y BIT Int.B0) = (x < y)" unfolding Bit_def by auto
   25.98 +lemma bitless6: "(x BIT Int.B1 < y BIT Int.B1) = (x < y)" unfolding Bit_def by auto
   25.99 +lemma bitless7: "(x BIT Int.B0 < y BIT Int.B1) = (x \<le> y)" unfolding Bit_def by auto
  25.100 +lemma bitless8: "(x BIT Int.B1 < y BIT Int.B0) = (x < y)" unfolding Bit_def by auto
  25.101 +lemma bitless9: "(Int.Pls < x BIT Int.B0) = (Int.Pls < x)" unfolding Bit_def Pls_def by auto
  25.102 +lemma bitless10: "(Int.Pls < x BIT Int.B1) = (Int.Pls \<le> x)" unfolding Bit_def Pls_def by auto
  25.103 +lemma bitless11: "(Int.Min < x BIT Int.B0) = (Int.Pls \<le> x)" unfolding Bit_def Pls_def Min_def by auto
  25.104 +lemma bitless12: "(Int.Min < x BIT Int.B1) = (Int.Min < x)" unfolding Bit_def Min_def by auto
  25.105 +lemma bitless13: "(x BIT Int.B0 < Int.Pls) = (x < Int.Pls)" unfolding Bit_def Pls_def by auto
  25.106 +lemma bitless14: "(x BIT Int.B1 < Int.Pls) = (x < Int.Pls)" unfolding Bit_def Pls_def by auto
  25.107 +lemma bitless15: "(x BIT Int.B0 < Int.Min) = (x < Int.Pls)" unfolding Bit_def Pls_def Min_def by auto
  25.108 +lemma bitless16: "(x BIT Int.B1 < Int.Min) = (x < Int.Min)" unfolding Bit_def Min_def by auto
  25.109  lemmas bitless = bitless1 bitless2 bitless3 bitless4 bitless5 bitless6 bitless7 bitless8 
  25.110                   bitless9 bitless10 bitless11 bitless12 bitless13 bitless14 bitless15 bitless16
  25.111  
  25.112  (* x \<le> y for bit strings *)
  25.113 -lemma bitle1: "(Numeral.Pls \<le> Numeral.Min) = False" unfolding Pls_def Min_def by auto
  25.114 -lemma bitle2: "(Numeral.Pls \<le> Numeral.Pls) = True" by auto
  25.115 -lemma bitle3: "(Numeral.Min \<le> Numeral.Pls) = True" unfolding Pls_def Min_def by auto
  25.116 -lemma bitle4: "(Numeral.Min \<le> Numeral.Min) = True" unfolding Pls_def Min_def by auto
  25.117 -lemma bitle5: "(x BIT Numeral.B0 \<le> y BIT Numeral.B0) = (x \<le> y)" unfolding Bit_def by auto
  25.118 -lemma bitle6: "(x BIT Numeral.B1 \<le> y BIT Numeral.B1) = (x \<le> y)" unfolding Bit_def by auto
  25.119 -lemma bitle7: "(x BIT Numeral.B0 \<le> y BIT Numeral.B1) = (x \<le> y)" unfolding Bit_def by auto
  25.120 -lemma bitle8: "(x BIT Numeral.B1 \<le> y BIT Numeral.B0) = (x < y)" unfolding Bit_def by auto
  25.121 -lemma bitle9: "(Numeral.Pls \<le> x BIT Numeral.B0) = (Numeral.Pls \<le> x)" unfolding Bit_def Pls_def by auto
  25.122 -lemma bitle10: "(Numeral.Pls \<le> x BIT Numeral.B1) = (Numeral.Pls \<le> x)" unfolding Bit_def Pls_def by auto
  25.123 -lemma bitle11: "(Numeral.Min \<le> x BIT Numeral.B0) = (Numeral.Pls \<le> x)" unfolding Bit_def Pls_def Min_def by auto
  25.124 -lemma bitle12: "(Numeral.Min \<le> x BIT Numeral.B1) = (Numeral.Min \<le> x)" unfolding Bit_def Min_def by auto
  25.125 -lemma bitle13: "(x BIT Numeral.B0 \<le> Numeral.Pls) = (x \<le> Numeral.Pls)" unfolding Bit_def Pls_def by auto
  25.126 -lemma bitle14: "(x BIT Numeral.B1 \<le> Numeral.Pls) = (x < Numeral.Pls)" unfolding Bit_def Pls_def by auto
  25.127 -lemma bitle15: "(x BIT Numeral.B0 \<le> Numeral.Min) = (x < Numeral.Pls)" unfolding Bit_def Pls_def Min_def by auto
  25.128 -lemma bitle16: "(x BIT Numeral.B1 \<le> Numeral.Min) = (x \<le> Numeral.Min)" unfolding Bit_def Min_def by auto
  25.129 +lemma bitle1: "(Int.Pls \<le> Int.Min) = False" unfolding Pls_def Min_def by auto
  25.130 +lemma bitle2: "(Int.Pls \<le> Int.Pls) = True" by auto
  25.131 +lemma bitle3: "(Int.Min \<le> Int.Pls) = True" unfolding Pls_def Min_def by auto
  25.132 +lemma bitle4: "(Int.Min \<le> Int.Min) = True" unfolding Pls_def Min_def by auto
  25.133 +lemma bitle5: "(x BIT Int.B0 \<le> y BIT Int.B0) = (x \<le> y)" unfolding Bit_def by auto
  25.134 +lemma bitle6: "(x BIT Int.B1 \<le> y BIT Int.B1) = (x \<le> y)" unfolding Bit_def by auto
  25.135 +lemma bitle7: "(x BIT Int.B0 \<le> y BIT Int.B1) = (x \<le> y)" unfolding Bit_def by auto
  25.136 +lemma bitle8: "(x BIT Int.B1 \<le> y BIT Int.B0) = (x < y)" unfolding Bit_def by auto
  25.137 +lemma bitle9: "(Int.Pls \<le> x BIT Int.B0) = (Int.Pls \<le> x)" unfolding Bit_def Pls_def by auto
  25.138 +lemma bitle10: "(Int.Pls \<le> x BIT Int.B1) = (Int.Pls \<le> x)" unfolding Bit_def Pls_def by auto
  25.139 +lemma bitle11: "(Int.Min \<le> x BIT Int.B0) = (Int.Pls \<le> x)" unfolding Bit_def Pls_def Min_def by auto
  25.140 +lemma bitle12: "(Int.Min \<le> x BIT Int.B1) = (Int.Min \<le> x)" unfolding Bit_def Min_def by auto
  25.141 +lemma bitle13: "(x BIT Int.B0 \<le> Int.Pls) = (x \<le> Int.Pls)" unfolding Bit_def Pls_def by auto
  25.142 +lemma bitle14: "(x BIT Int.B1 \<le> Int.Pls) = (x < Int.Pls)" unfolding Bit_def Pls_def by auto
  25.143 +lemma bitle15: "(x BIT Int.B0 \<le> Int.Min) = (x < Int.Pls)" unfolding Bit_def Pls_def Min_def by auto
  25.144 +lemma bitle16: "(x BIT Int.B1 \<le> Int.Min) = (x \<le> Int.Min)" unfolding Bit_def Min_def by auto
  25.145  lemmas bitle = bitle1 bitle2 bitle3 bitle4 bitle5 bitle6 bitle7 bitle8 
  25.146                   bitle9 bitle10 bitle11 bitle12 bitle13 bitle14 bitle15 bitle16
  25.147  
  25.148 @@ -97,14 +97,14 @@
  25.149  lemmas bituminus = minus_Pls minus_Min minus_1 minus_0 
  25.150  
  25.151  (* addition for bit strings *)
  25.152 -lemmas bitadd = add_Pls add_Pls_right add_Min add_Min_right add_BIT_11 add_BIT_10 add_BIT_0[where b="Numeral.B0"] add_BIT_0[where b="Numeral.B1"]
  25.153 +lemmas bitadd = add_Pls add_Pls_right add_Min add_Min_right add_BIT_11 add_BIT_10 add_BIT_0[where b="Int.B0"] add_BIT_0[where b="Int.B1"]
  25.154  
  25.155  (* multiplication for bit strings *) 
  25.156 -lemma mult_Pls_right: "x * Numeral.Pls = Numeral.Pls" by (simp add: Pls_def)
  25.157 -lemma mult_Min_right: "x * Numeral.Min = - x" by (subst mult_commute, simp add: mult_Min)
  25.158 -lemma multb0x: "(x BIT Numeral.B0) * y = (x * y) BIT Numeral.B0" unfolding Bit_def by simp
  25.159 -lemma multxb0: "x * (y BIT Numeral.B0) = (x * y) BIT Numeral.B0" unfolding Bit_def by simp
  25.160 -lemma multb1: "(x BIT Numeral.B1) * (y BIT Numeral.B1) = (((x * y) BIT Numeral.B0) + x + y) BIT Numeral.B1"
  25.161 +lemma mult_Pls_right: "x * Int.Pls = Int.Pls" by (simp add: Pls_def)
  25.162 +lemma mult_Min_right: "x * Int.Min = - x" by (subst mult_commute, simp add: mult_Min)
  25.163 +lemma multb0x: "(x BIT Int.B0) * y = (x * y) BIT Int.B0" unfolding Bit_def by simp
  25.164 +lemma multxb0: "x * (y BIT Int.B0) = (x * y) BIT Int.B0" unfolding Bit_def by simp
  25.165 +lemma multb1: "(x BIT Int.B1) * (y BIT Int.B1) = (((x * y) BIT Int.B0) + x + y) BIT Int.B1"
  25.166    unfolding Bit_def by (simp add: ring_simps)
  25.167  lemmas bitmul = mult_Pls mult_Min mult_Pls_right mult_Min_right multb0x multxb0 multb1
  25.168  
  25.169 @@ -120,12 +120,12 @@
  25.170    done
  25.171  
  25.172  (* Normalization of nat literals *)
  25.173 -lemma natnorm0: "(0::nat) = number_of (Numeral.Pls)" by auto
  25.174 -lemma natnorm1: "(1 :: nat) = number_of (Numeral.Pls BIT Numeral.B1)"  by auto 
  25.175 +lemma natnorm0: "(0::nat) = number_of (Int.Pls)" by auto
  25.176 +lemma natnorm1: "(1 :: nat) = number_of (Int.Pls BIT Int.B1)"  by auto 
  25.177  lemmas natnorm = natnorm0 natnorm1 nat_norm_number_of
  25.178  
  25.179  (* Suc *)
  25.180 -lemma natsuc: "Suc (number_of x) = (if neg x then 1 else number_of (Numeral.succ x))" by (auto simp add: number_of_is_id)
  25.181 +lemma natsuc: "Suc (number_of x) = (if neg x then 1 else number_of (Int.succ x))" by (auto simp add: number_of_is_id)
  25.182  
  25.183  (* Addition for nat *)
  25.184  lemma natadd: "number_of x + ((number_of y)::nat) = (if neg x then (number_of y) else (if neg y then number_of x else (number_of (x + y))))"
  25.185 @@ -220,19 +220,19 @@
  25.186  
  25.187  (* collecting all the theorems *)
  25.188  
  25.189 -lemma even_Pls: "even (Numeral.Pls) = True"
  25.190 +lemma even_Pls: "even (Int.Pls) = True"
  25.191    apply (unfold Pls_def even_def)
  25.192    by simp
  25.193  
  25.194 -lemma even_Min: "even (Numeral.Min) = False"
  25.195 +lemma even_Min: "even (Int.Min) = False"
  25.196    apply (unfold Min_def even_def)
  25.197    by simp
  25.198  
  25.199 -lemma even_B0: "even (x BIT Numeral.B0) = True"
  25.200 +lemma even_B0: "even (x BIT Int.B0) = True"
  25.201    apply (unfold Bit_def)
  25.202    by simp
  25.203  
  25.204 -lemma even_B1: "even (x BIT Numeral.B1) = False"
  25.205 +lemma even_B1: "even (x BIT Int.B1) = False"
  25.206    apply (unfold Bit_def)
  25.207    by simp
  25.208  
    26.1 --- a/src/HOL/Tools/Qelim/cooper_data.ML	Tue Jan 15 16:19:21 2008 +0100
    26.2 +++ b/src/HOL/Tools/Qelim/cooper_data.ML	Tue Jan 15 16:19:23 2008 +0100
    26.3 @@ -24,7 +24,7 @@
    26.4     @{term "op * :: int => _"}, @{term "op * :: nat => _"},
    26.5     @{term "op div :: int => _"}, @{term "op div :: nat => _"},
    26.6     @{term "op mod :: int => _"}, @{term "op mod :: nat => _"},
    26.7 -   @{term "Numeral.Bit"},
    26.8 +   @{term "Int.Bit"},
    26.9     @{term "op &"}, @{term "op |"}, @{term "op -->"}, 
   26.10     @{term "op = :: int => _"}, @{term "op = :: nat => _"}, @{term "op = :: bool => _"},
   26.11     @{term "op < :: int => _"}, @{term "op < :: nat => _"},
   26.12 @@ -38,9 +38,9 @@
   26.13     @{term "Ex :: (int => _) => _"}, @{term "Ex :: (nat => _) => _"},
   26.14     @{term "All :: (int => _) => _"}, @{term "All :: (nat => _) => _"},
   26.15     @{term "nat"}, @{term "int"},
   26.16 -   @{term "Numeral.bit.B0"},@{term "Numeral.bit.B1"}, 
   26.17 -   @{term "Numeral.Bit"}, @{term "Numeral.Pls"}, @{term "Numeral.Min"},
   26.18 -   @{term "Numeral.number_of :: int => int"}, @{term "Numeral.number_of :: int => nat"},
   26.19 +   @{term "Int.bit.B0"},@{term "Int.bit.B1"}, 
   26.20 +   @{term "Int.Bit"}, @{term "Int.Pls"}, @{term "Int.Min"},
   26.21 +   @{term "Int.number_of :: int => int"}, @{term "Int.number_of :: int => nat"},
   26.22     @{term "0::int"}, @{term "1::int"}, @{term "0::nat"}, @{term "1::nat"},
   26.23     @{term "True"}, @{term "False"}];
   26.24  
    27.1 --- a/src/HOL/Tools/lin_arith.ML	Tue Jan 15 16:19:21 2008 +0100
    27.2 +++ b/src/HOL/Tools/lin_arith.ML	Tue Jan 15 16:19:23 2008 +0100
    27.3 @@ -203,7 +203,7 @@
    27.4        in which case dest_numeral raises TERM; hence all the handles below.
    27.5        Same for Suc-terms that turn out not to be numerals -
    27.6        although the simplifier should eliminate those anyway ...*)
    27.7 -    | demult (t as Const ("Numeral.number_class.number_of", _) $ n, m) =
    27.8 +    | demult (t as Const ("Int.number_class.number_of", _) $ n, m) =
    27.9        ((NONE, Rat.mult m (Rat.rat_of_int (HOLogic.dest_numeral n)))
   27.10          handle TERM _ => (SOME t, m))
   27.11      | demult (t as Const (@{const_name Suc}, _) $ _, m) =
   27.12 @@ -242,7 +242,7 @@
   27.13          (case demult inj_consts (all, m) of
   27.14             (NONE,   m') => (p, Rat.add i m')
   27.15           | (SOME u, m') => add_atom u m' pi)
   27.16 -    | poly (all as Const ("Numeral.number_class.number_of", Type(_,[_,T])) $ t, m, pi as (p, i)) =
   27.17 +    | poly (all as Const ("Int.number_class.number_of", Type(_,[_,T])) $ t, m, pi as (p, i)) =
   27.18          (let val k = HOLogic.dest_numeral t
   27.19              val k2 = if k < 0 andalso T = HOLogic.natT then 0 else k
   27.20          in (p, Rat.add i (Rat.mult m (Rat.rat_of_int k2))) end
   27.21 @@ -324,7 +324,7 @@
   27.22                                      @{const_name Orderings.min},
   27.23                                      @{const_name HOL.abs},
   27.24                                      @{const_name HOL.minus},
   27.25 -                                    "IntDef.nat",
   27.26 +                                    "Int.nat",
   27.27                                      "Divides.div_class.mod",
   27.28                                      "Divides.div_class.div"] a
   27.29      | _            => (warning ("Lin. Arith.: wrong format for split rule " ^
   27.30 @@ -462,7 +462,7 @@
   27.31          SOME [(Ts, subgoal1), (split_type :: Ts, subgoal2)]
   27.32        end
   27.33      (* ?P (nat ?i) = ((ALL n. ?i = int n --> ?P n) & (?i < 0 --> ?P 0)) *)
   27.34 -    | (Const ("IntDef.nat", _), [t1]) =>
   27.35 +    | (Const ("Int.nat", _), [t1]) =>
   27.36        let
   27.37          val rev_terms   = rev terms
   27.38          val zero_int    = Const (@{const_name HOL.zero}, HOLogic.intT)
   27.39 @@ -553,7 +553,7 @@
   27.40            (neg (number_of ?k) -->
   27.41              (ALL i j. number_of ?k < j & j <= 0 & ?n = number_of ?k * i + j --> ?P j))) *)
   27.42      | (Const ("Divides.div_class.mod",
   27.43 -        Type ("fun", [Type ("IntDef.int", []), _])), [t1, t2 as (number_of $ k)]) =>
   27.44 +        Type ("fun", [Type ("Int.int", []), _])), [t1, t2 as (number_of $ k)]) =>
   27.45        let
   27.46          val rev_terms               = rev terms
   27.47          val zero                    = Const (@{const_name HOL.zero}, split_type)
   27.48 @@ -564,8 +564,8 @@
   27.49                                          (map (incr_boundvars 2) rev_terms)
   27.50          val t1'                     = incr_boundvars 2 t1
   27.51          val (t2' as (_ $ k'))       = incr_boundvars 2 t2
   27.52 -        val iszero_t2               = Const ("IntDef.iszero", split_type --> HOLogic.boolT) $ t2
   27.53 -        val neg_minus_k             = Const ("IntDef.neg", split_type --> HOLogic.boolT) $
   27.54 +        val iszero_t2               = Const ("Int.iszero", split_type --> HOLogic.boolT) $ t2
   27.55 +        val neg_minus_k             = Const ("Int.neg", split_type --> HOLogic.boolT) $
   27.56                                          (number_of $
   27.57                                            (Const (@{const_name HOL.uminus},
   27.58                                              HOLogic.intT --> HOLogic.intT) $ k'))
   27.59 @@ -577,7 +577,7 @@
   27.60                                         (Const (@{const_name HOL.plus}, split_type --> split_type --> split_type) $
   27.61                                           (Const (@{const_name HOL.times},
   27.62                                             split_type --> split_type --> split_type) $ t2' $ i) $ j)
   27.63 -        val neg_t2                  = Const ("IntDef.neg", split_type --> HOLogic.boolT) $ t2'
   27.64 +        val neg_t2                  = Const ("Int.neg", split_type --> HOLogic.boolT) $ t2'
   27.65          val t2_lt_j                 = Const (@{const_name HOL.less},
   27.66                                          split_type --> split_type--> HOLogic.boolT) $ t2' $ j
   27.67          val j_leq_zero              = Const (@{const_name HOL.less_eq},
   27.68 @@ -605,7 +605,7 @@
   27.69            (neg (number_of ?k) -->
   27.70              (ALL i. (EX j. number_of ?k < j & j <= 0 & ?n = number_of ?k * i + j) --> ?P i))) *)
   27.71      | (Const ("Divides.div_class.div",
   27.72 -        Type ("fun", [Type ("IntDef.int", []), _])), [t1, t2 as (number_of $ k)]) =>
   27.73 +        Type ("fun", [Type ("Int.int", []), _])), [t1, t2 as (number_of $ k)]) =>
   27.74        let
   27.75          val rev_terms               = rev terms
   27.76          val zero                    = Const (@{const_name HOL.zero}, split_type)
   27.77 @@ -616,8 +616,8 @@
   27.78                                          (map (incr_boundvars 2) rev_terms)
   27.79          val t1'                     = incr_boundvars 2 t1
   27.80          val (t2' as (_ $ k'))       = incr_boundvars 2 t2
   27.81 -        val iszero_t2               = Const ("IntDef.iszero", split_type --> HOLogic.boolT) $ t2
   27.82 -        val neg_minus_k             = Const ("IntDef.neg", split_type --> HOLogic.boolT) $
   27.83 +        val iszero_t2               = Const ("Int.iszero", split_type --> HOLogic.boolT) $ t2
   27.84 +        val neg_minus_k             = Const ("Int.neg", split_type --> HOLogic.boolT) $
   27.85                                          (number_of $
   27.86                                            (Const (@{const_name HOL.uminus},
   27.87                                              HOLogic.intT --> HOLogic.intT) $ k'))
   27.88 @@ -630,7 +630,7 @@
   27.89                                         (Const (@{const_name HOL.plus}, split_type --> split_type --> split_type) $
   27.90                                           (Const (@{const_name HOL.times},
   27.91                                             split_type --> split_type --> split_type) $ t2' $ i) $ j)
   27.92 -        val neg_t2                  = Const ("IntDef.neg", split_type --> HOLogic.boolT) $ t2'
   27.93 +        val neg_t2                  = Const ("Int.neg", split_type --> HOLogic.boolT) $ t2'
   27.94          val t2_lt_j                 = Const (@{const_name HOL.less},
   27.95                                          split_type --> split_type--> HOLogic.boolT) $ t2' $ j
   27.96          val j_leq_zero              = Const (@{const_name HOL.less_eq},
    28.1 --- a/src/HOL/Tools/numeral.ML	Tue Jan 15 16:19:21 2008 +0100
    28.2 +++ b/src/HOL/Tools/numeral.ML	Tue Jan 15 16:19:23 2008 +0100
    28.3 @@ -1,4 +1,4 @@
    28.4 -(*  Title:      HOL/Tools/numeral.ML
    28.5 +(*  Title:      HOL/Tools/Int.ML
    28.6      ID:         $Id$
    28.7      Author:     Makarius
    28.8  
    28.9 @@ -16,15 +16,15 @@
   28.10  
   28.11  (* numeral *)
   28.12  
   28.13 -fun mk_cbit 0 = @{cterm "Numeral.bit.B0"}
   28.14 -  | mk_cbit 1 = @{cterm "Numeral.bit.B1"}
   28.15 +fun mk_cbit 0 = @{cterm "Int.bit.B0"}
   28.16 +  | mk_cbit 1 = @{cterm "Int.bit.B1"}
   28.17    | mk_cbit _ = raise CTERM ("mk_cbit", []);
   28.18  
   28.19 -fun mk_cnumeral 0 = @{cterm "Numeral.Pls"}
   28.20 -  | mk_cnumeral ~1 = @{cterm "Numeral.Min"}
   28.21 +fun mk_cnumeral 0 = @{cterm "Int.Pls"}
   28.22 +  | mk_cnumeral ~1 = @{cterm "Int.Min"}
   28.23    | mk_cnumeral i =
   28.24        let val (q, r) = Integer.div_mod i 2 in
   28.25 -        Thm.capply (Thm.capply @{cterm "Numeral.Bit"} (mk_cnumeral q)) (mk_cbit r)
   28.26 +        Thm.capply (Thm.capply @{cterm "Int.Bit"} (mk_cnumeral q)) (mk_cbit r)
   28.27        end;
   28.28  
   28.29  
    29.1 --- a/src/HOL/Tools/numeral_syntax.ML	Tue Jan 15 16:19:21 2008 +0100
    29.2 +++ b/src/HOL/Tools/numeral_syntax.ML	Tue Jan 15 16:19:23 2008 +0100
    29.3 @@ -20,16 +20,16 @@
    29.4  fun mk_bin num =
    29.5    let
    29.6      val {leading_zeros = z, value, ...} = Syntax.read_xnum num;
    29.7 -    fun bit b bs = Syntax.const @{const_name Numeral.Bit} $ bs $ HOLogic.mk_bit b;
    29.8 -    fun mk 0 = (* FIXME funpow z (bit 0) *) (Syntax.const @{const_name Numeral.Pls})
    29.9 -      | mk ~1 = (* FIXME funpow z (bit 1) *) (Syntax.const @{const_name Numeral.Min})
   29.10 +    fun bit b bs = Syntax.const @{const_name Int.Bit} $ bs $ HOLogic.mk_bit b;
   29.11 +    fun mk 0 = (* FIXME funpow z (bit 0) *) (Syntax.const @{const_name Int.Pls})
   29.12 +      | mk ~1 = (* FIXME funpow z (bit 1) *) (Syntax.const @{const_name Int.Min})
   29.13        | mk i = let val (q, r) = Integer.div_mod i 2 in bit r (mk q) end;
   29.14    in mk value end;
   29.15  
   29.16  in
   29.17  
   29.18  fun numeral_tr (*"_Numeral"*) [t as Const (num, _)] =
   29.19 -      Syntax.const @{const_name Numeral.number_of} $ mk_bin num
   29.20 +      Syntax.const @{const_name Int.number_of} $ mk_bin num
   29.21    | numeral_tr (*"_Numeral"*) ts = raise TERM ("numeral_tr", ts);
   29.22  
   29.23  end;
   29.24 @@ -39,15 +39,15 @@
   29.25  
   29.26  local
   29.27  
   29.28 -fun dest_bit (Const (@{const_syntax Numeral.bit.B0}, _)) = 0
   29.29 -  | dest_bit (Const (@{const_syntax Numeral.bit.B1}, _)) = 1
   29.30 +fun dest_bit (Const (@{const_syntax Int.bit.B0}, _)) = 0
   29.31 +  | dest_bit (Const (@{const_syntax Int.bit.B1}, _)) = 1
   29.32    | dest_bit (Const ("bit.B0", _)) = 0
   29.33    | dest_bit (Const ("bit.B1", _)) = 1
   29.34    | dest_bit _ = raise Match;
   29.35  
   29.36 -fun dest_bin (Const (@{const_syntax "Numeral.Pls"}, _)) = []
   29.37 -  | dest_bin (Const (@{const_syntax "Numeral.Min"}, _)) = [~1]
   29.38 -  | dest_bin (Const (@{const_syntax "Numeral.Bit"}, _) $ bs $ b) = dest_bit b :: dest_bin bs
   29.39 +fun dest_bin (Const (@{const_syntax "Int.Pls"}, _)) = []
   29.40 +  | dest_bin (Const (@{const_syntax "Int.Min"}, _)) = [~1]
   29.41 +  | dest_bin (Const (@{const_syntax "Int.Bit"}, _) $ bs $ b) = dest_bit b :: dest_bin bs
   29.42    | dest_bin _ = raise Match;
   29.43  
   29.44  fun leading _ [] = 0
   29.45 @@ -89,6 +89,6 @@
   29.46  
   29.47  val setup =
   29.48    Sign.add_trfuns ([], [("_Numeral", numeral_tr)], [], []) #>
   29.49 -  Sign.add_trfunsT [(@{const_syntax Numeral.number_of}, numeral_tr')];
   29.50 +  Sign.add_trfunsT [(@{const_syntax Int.number_of}, numeral_tr')];
   29.51  
   29.52  end;
    30.1 --- a/src/HOL/Word/BinBoolList.thy	Tue Jan 15 16:19:21 2008 +0100
    30.2 +++ b/src/HOL/Word/BinBoolList.thy	Tue Jan 15 16:19:23 2008 +0100
    30.3 @@ -76,13 +76,13 @@
    30.4    by (induct n) (auto simp: butlast_take)
    30.5  
    30.6  lemma bin_to_bl_aux_Pls_minus_simp:
    30.7 -  "0 < n ==> bin_to_bl_aux n Numeral.Pls bl = 
    30.8 -    bin_to_bl_aux (n - 1) Numeral.Pls (False # bl)"
    30.9 +  "0 < n ==> bin_to_bl_aux n Int.Pls bl = 
   30.10 +    bin_to_bl_aux (n - 1) Int.Pls (False # bl)"
   30.11    by (cases n) auto
   30.12  
   30.13  lemma bin_to_bl_aux_Min_minus_simp:
   30.14 -  "0 < n ==> bin_to_bl_aux n Numeral.Min bl = 
   30.15 -    bin_to_bl_aux (n - 1) Numeral.Min (True # bl)"
   30.16 +  "0 < n ==> bin_to_bl_aux n Int.Min bl = 
   30.17 +    bin_to_bl_aux (n - 1) Int.Min (True # bl)"
   30.18    by (cases n) auto
   30.19  
   30.20  lemma bin_to_bl_aux_Bit_minus_simp:
   30.21 @@ -166,21 +166,21 @@
   30.22  lemma bl_to_bin_False: "bl_to_bin (False # bl) = bl_to_bin bl"
   30.23    unfolding bl_to_bin_def by auto
   30.24    
   30.25 -lemma bl_to_bin_Nil: "bl_to_bin [] = Numeral.Pls"
   30.26 +lemma bl_to_bin_Nil: "bl_to_bin [] = Int.Pls"
   30.27    unfolding bl_to_bin_def by auto
   30.28  
   30.29  lemma bin_to_bl_Pls_aux [rule_format] : 
   30.30 -  "ALL bl. bin_to_bl_aux n Numeral.Pls bl = replicate n False @ bl"
   30.31 +  "ALL bl. bin_to_bl_aux n Int.Pls bl = replicate n False @ bl"
   30.32    by (induct n) (auto simp: replicate_app_Cons_same)
   30.33  
   30.34 -lemma bin_to_bl_Pls: "bin_to_bl n Numeral.Pls = replicate n False"
   30.35 +lemma bin_to_bl_Pls: "bin_to_bl n Int.Pls = replicate n False"
   30.36    unfolding bin_to_bl_def by (simp add : bin_to_bl_Pls_aux)
   30.37  
   30.38  lemma bin_to_bl_Min_aux [rule_format] : 
   30.39 -  "ALL bl. bin_to_bl_aux n Numeral.Min bl = replicate n True @ bl"
   30.40 +  "ALL bl. bin_to_bl_aux n Int.Min bl = replicate n True @ bl"
   30.41    by (induct n) (auto simp: replicate_app_Cons_same)
   30.42  
   30.43 -lemma bin_to_bl_Min: "bin_to_bl n Numeral.Min = replicate n True"
   30.44 +lemma bin_to_bl_Min: "bin_to_bl n Int.Min = replicate n True"
   30.45    unfolding bin_to_bl_def by (simp add : bin_to_bl_Min_aux)
   30.46  
   30.47  lemma bl_to_bin_rep_F: 
   30.48 @@ -214,7 +214,7 @@
   30.49  lemmas bin_to_bl_bintr = 
   30.50    bin_to_bl_aux_bintr [where bl = "[]", folded bin_to_bl_def]
   30.51  
   30.52 -lemma bl_to_bin_rep_False: "bl_to_bin (replicate n False) = Numeral.Pls"
   30.53 +lemma bl_to_bin_rep_False: "bl_to_bin (replicate n False) = Int.Pls"
   30.54    by (induct n) auto
   30.55  
   30.56  lemma len_bin_to_bl_aux [rule_format] : 
   30.57 @@ -228,12 +228,12 @@
   30.58    "ALL w. bin_sign (bl_to_bin_aux w bs) = bin_sign w"
   30.59    by (induct bs) auto
   30.60    
   30.61 -lemma sign_bl_bin: "bin_sign (bl_to_bin bs) = Numeral.Pls"
   30.62 +lemma sign_bl_bin: "bin_sign (bl_to_bin bs) = Int.Pls"
   30.63    unfolding bl_to_bin_def by (simp add : sign_bl_bin')
   30.64    
   30.65  lemma bl_sbin_sign_aux [rule_format] : 
   30.66    "ALL w bs. hd (bin_to_bl_aux (Suc n) w bs) = 
   30.67 -    (bin_sign (sbintrunc n w) = Numeral.Min)"
   30.68 +    (bin_sign (sbintrunc n w) = Int.Min)"
   30.69    apply (induct "n")
   30.70     apply clarsimp
   30.71     apply (case_tac w rule: bin_exhaust)
   30.72 @@ -242,7 +242,7 @@
   30.73    done
   30.74      
   30.75  lemma bl_sbin_sign: 
   30.76 -  "hd (bin_to_bl (Suc n) w) = (bin_sign (sbintrunc n w) = Numeral.Min)"
   30.77 +  "hd (bin_to_bl (Suc n) w) = (bin_sign (sbintrunc n w) = Int.Min)"
   30.78    unfolding bin_to_bl_def by (rule bl_sbin_sign_aux)
   30.79  
   30.80  lemma bin_nth_of_bl_aux [rule_format] : 
   30.81 @@ -658,7 +658,7 @@
   30.82    by (induct nw) auto 
   30.83  
   30.84  lemmas bl_to_bin_aux_alt = 
   30.85 -  bl_to_bin_aux_cat [where nv = "0" and v = "Numeral.Pls", 
   30.86 +  bl_to_bin_aux_cat [where nv = "0" and v = "Int.Pls", 
   30.87      simplified bl_to_bin_def [symmetric], simplified]
   30.88  
   30.89  lemmas bin_to_bl_cat =
   30.90 @@ -671,7 +671,7 @@
   30.91    trans [OF bin_to_bl_aux_cat bin_to_bl_aux_alt]
   30.92  
   30.93  lemmas bl_to_bin_app_cat = bl_to_bin_aux_app_cat
   30.94 -  [where w = "Numeral.Pls", folded bl_to_bin_def]
   30.95 +  [where w = "Int.Pls", folded bl_to_bin_def]
   30.96  
   30.97  lemmas bin_to_bl_cat_app = bin_to_bl_aux_cat_app
   30.98    [where bs = "[]", folded bin_to_bl_def]
   30.99 @@ -682,7 +682,7 @@
  30.100    by (simp add : bl_to_bin_app_cat)
  30.101  
  30.102  lemma mask_lem: "(bl_to_bin (True # replicate n False)) = 
  30.103 -    Numeral.succ (bl_to_bin (replicate n True))"
  30.104 +    Int.succ (bl_to_bin (replicate n True))"
  30.105    apply (unfold bl_to_bin_def)
  30.106    apply (induct n)
  30.107     apply simp
  30.108 @@ -745,7 +745,7 @@
  30.109    rbl_pred.Nil rbl_succ.Nil rbl_add.Nil rbl_mult.Nil
  30.110  
  30.111  lemma rbl_pred: 
  30.112 -  "!!bin. rbl_pred (rev (bin_to_bl n bin)) = rev (bin_to_bl n (Numeral.pred bin))"
  30.113 +  "!!bin. rbl_pred (rev (bin_to_bl n bin)) = rev (bin_to_bl n (Int.pred bin))"
  30.114    apply (induct n, simp)
  30.115    apply (unfold bin_to_bl_def)
  30.116    apply clarsimp
  30.117 @@ -755,7 +755,7 @@
  30.118    done
  30.119  
  30.120  lemma rbl_succ: 
  30.121 -  "!!bin. rbl_succ (rev (bin_to_bl n bin)) = rev (bin_to_bl n (Numeral.succ bin))"
  30.122 +  "!!bin. rbl_succ (rev (bin_to_bl n bin)) = rev (bin_to_bl n (Int.succ bin))"
  30.123    apply (induct n, simp)
  30.124    apply (unfold bin_to_bl_def)
  30.125    apply clarsimp
  30.126 @@ -1011,7 +1011,7 @@
  30.127  lemma bin_split_pred_simp [simp]: 
  30.128    "(0::nat) < number_of bin \<Longrightarrow>
  30.129    bin_split (number_of bin) w =
  30.130 -  (let (w1, w2) = bin_split (number_of (Numeral.pred bin)) (bin_rest w)
  30.131 +  (let (w1, w2) = bin_split (number_of (Int.pred bin)) (bin_rest w)
  30.132     in (w1, w2 BIT bin_last w))" 
  30.133    by (simp only: nobm1 bin_split_minus_simp)
  30.134  
    31.1 --- a/src/HOL/Word/BinGeneral.thy	Tue Jan 15 16:19:21 2008 +0100
    31.2 +++ b/src/HOL/Word/BinGeneral.thy	Tue Jan 15 16:19:23 2008 +0100
    31.3 @@ -15,14 +15,14 @@
    31.4  
    31.5  subsection {* Recursion combinator for binary integers *}
    31.6  
    31.7 -lemma brlem: "(bin = Numeral.Min) = (- bin + Numeral.pred 0 = 0)"
    31.8 +lemma brlem: "(bin = Int.Min) = (- bin + Int.pred 0 = 0)"
    31.9    unfolding Min_def pred_def by arith
   31.10  
   31.11  function
   31.12    bin_rec' :: "int * 'a * 'a * (int => bit => 'a => 'a) => 'a"  
   31.13    where 
   31.14 -  "bin_rec' (bin, f1, f2, f3) = (if bin = Numeral.Pls then f1 
   31.15 -    else if bin = Numeral.Min then f2
   31.16 +  "bin_rec' (bin, f1, f2, f3) = (if bin = Int.Pls then f1 
   31.17 +    else if bin = Int.Min then f2
   31.18      else case bin_rl bin of (w, b) => f3 w b (bin_rec' (w, f1, f2, f3)))"
   31.19    by pat_completeness auto
   31.20  
   31.21 @@ -43,7 +43,7 @@
   31.22    "bin_rec f1 f2 f3 bin == bin_rec' (bin, f1, f2, f3)"
   31.23  
   31.24  lemma bin_rec_PM:
   31.25 -  "f = bin_rec f1 f2 f3 ==> f Numeral.Pls = f1 & f Numeral.Min = f2"
   31.26 +  "f = bin_rec f1 f2 f3 ==> f Int.Pls = f1 & f Int.Min = f2"
   31.27    apply safe
   31.28     apply (unfold bin_rec_def)
   31.29     apply (auto intro: bin_rec'.simps [THEN trans])
   31.30 @@ -53,8 +53,8 @@
   31.31  lemmas bin_rec_Min = refl [THEN bin_rec_PM, THEN conjunct2, standard]
   31.32  
   31.33  lemma bin_rec_Bit:
   31.34 -  "f = bin_rec f1 f2 f3  ==> f3 Numeral.Pls bit.B0 f1 = f1 ==> 
   31.35 -    f3 Numeral.Min bit.B1 f2 = f2 ==> f (w BIT b) = f3 w b (f w)"
   31.36 +  "f = bin_rec f1 f2 f3  ==> f3 Int.Pls bit.B0 f1 = f1 ==> 
   31.37 +    f3 Int.Min bit.B1 f2 = f2 ==> f (w BIT b) = f3 w b (f w)"
   31.38    apply clarify
   31.39    apply (unfold bin_rec_def)
   31.40    apply (rule bin_rec'.simps [THEN trans])
   31.41 @@ -81,7 +81,7 @@
   31.42  defs  
   31.43    bin_rest_def : "bin_rest w == fst (bin_rl w)"
   31.44    bin_last_def : "bin_last w == snd (bin_rl w)"
   31.45 -  bin_sign_def : "bin_sign == bin_rec Numeral.Pls Numeral.Min (%w b s. s)"
   31.46 +  bin_sign_def : "bin_sign == bin_rec Int.Pls Int.Min (%w b s. s)"
   31.47  
   31.48  lemma bin_rl: "bin_rl w = (bin_rest w, bin_last w)"
   31.49    unfolding bin_rest_def bin_last_def by auto
   31.50 @@ -89,20 +89,20 @@
   31.51  lemmas bin_rl_simp [simp] = iffD1 [OF bin_rl_char bin_rl]
   31.52  
   31.53  lemma bin_rest_simps [simp]: 
   31.54 -  "bin_rest Numeral.Pls = Numeral.Pls"
   31.55 -  "bin_rest Numeral.Min = Numeral.Min"
   31.56 +  "bin_rest Int.Pls = Int.Pls"
   31.57 +  "bin_rest Int.Min = Int.Min"
   31.58    "bin_rest (w BIT b) = w"
   31.59    unfolding bin_rest_def by auto
   31.60  
   31.61  lemma bin_last_simps [simp]: 
   31.62 -  "bin_last Numeral.Pls = bit.B0"
   31.63 -  "bin_last Numeral.Min = bit.B1"
   31.64 +  "bin_last Int.Pls = bit.B0"
   31.65 +  "bin_last Int.Min = bit.B1"
   31.66    "bin_last (w BIT b) = b"
   31.67    unfolding bin_last_def by auto
   31.68      
   31.69  lemma bin_sign_simps [simp]:
   31.70 -  "bin_sign Numeral.Pls = Numeral.Pls"
   31.71 -  "bin_sign Numeral.Min = Numeral.Min"
   31.72 +  "bin_sign Int.Pls = Int.Pls"
   31.73 +  "bin_sign Int.Min = Int.Min"
   31.74    "bin_sign (w BIT b) = bin_sign w"
   31.75    unfolding bin_sign_def by (auto simp: bin_rec_simps)
   31.76  
   31.77 @@ -176,10 +176,10 @@
   31.78  
   31.79  lemmas bin_eqI = ext [THEN bin_nth_eq_iff [THEN iffD1], standard]
   31.80  
   31.81 -lemma bin_nth_Pls [simp]: "~ bin_nth Numeral.Pls n"
   31.82 +lemma bin_nth_Pls [simp]: "~ bin_nth Int.Pls n"
   31.83    by (induct n) auto
   31.84  
   31.85 -lemma bin_nth_Min [simp]: "bin_nth Numeral.Min n"
   31.86 +lemma bin_nth_Min [simp]: "bin_nth Int.Min n"
   31.87    by (induct n) auto
   31.88  
   31.89  lemma bin_nth_0_BIT: "bin_nth (w BIT b) 0 = (b = bit.B1)"
   31.90 @@ -206,18 +206,18 @@
   31.91  consts
   31.92    bintrunc :: "nat => int => int"
   31.93  primrec 
   31.94 -  Z : "bintrunc 0 bin = Numeral.Pls"
   31.95 +  Z : "bintrunc 0 bin = Int.Pls"
   31.96    Suc : "bintrunc (Suc n) bin = bintrunc n (bin_rest bin) BIT (bin_last bin)"
   31.97  
   31.98  consts
   31.99    sbintrunc :: "nat => int => int" 
  31.100  primrec 
  31.101    Z : "sbintrunc 0 bin = 
  31.102 -    (case bin_last bin of bit.B1 => Numeral.Min | bit.B0 => Numeral.Pls)"
  31.103 +    (case bin_last bin of bit.B1 => Int.Min | bit.B0 => Int.Pls)"
  31.104    Suc : "sbintrunc (Suc n) bin = sbintrunc n (bin_rest bin) BIT (bin_last bin)"
  31.105  
  31.106  lemma sign_bintr:
  31.107 -  "!!w. bin_sign (bintrunc n w) = Numeral.Pls"
  31.108 +  "!!w. bin_sign (bintrunc n w) = Int.Pls"
  31.109    by (induct n) auto
  31.110  
  31.111  lemma bintrunc_mod2p:
  31.112 @@ -253,7 +253,7 @@
  31.113  lemmas bit_bool1 [simp] = refl [THEN bit_bool [THEN iffD1], symmetric]
  31.114  
  31.115  lemma bin_sign_lem:
  31.116 -  "!!bin. (bin_sign (sbintrunc n bin) = Numeral.Min) = bin_nth bin n"
  31.117 +  "!!bin. (bin_sign (sbintrunc n bin) = Int.Min) = bin_nth bin n"
  31.118    apply (induct n)
  31.119     apply (case_tac bin rule: bin_exhaust, case_tac b, auto)+
  31.120    done
  31.121 @@ -304,10 +304,10 @@
  31.122    done
  31.123  
  31.124  lemmas bintrunc_Pls = 
  31.125 -  bintrunc.Suc [where bin="Numeral.Pls", simplified bin_last_simps bin_rest_simps, standard]
  31.126 +  bintrunc.Suc [where bin="Int.Pls", simplified bin_last_simps bin_rest_simps, standard]
  31.127  
  31.128  lemmas bintrunc_Min [simp] = 
  31.129 -  bintrunc.Suc [where bin="Numeral.Min", simplified bin_last_simps bin_rest_simps, standard]
  31.130 +  bintrunc.Suc [where bin="Int.Min", simplified bin_last_simps bin_rest_simps, standard]
  31.131  
  31.132  lemmas bintrunc_BIT  [simp] = 
  31.133    bintrunc.Suc [where bin="w BIT b", simplified bin_last_simps bin_rest_simps, standard]
  31.134 @@ -315,10 +315,10 @@
  31.135  lemmas bintrunc_Sucs = bintrunc_Pls bintrunc_Min bintrunc_BIT
  31.136  
  31.137  lemmas sbintrunc_Suc_Pls = 
  31.138 -  sbintrunc.Suc [where bin="Numeral.Pls", simplified bin_last_simps bin_rest_simps, standard]
  31.139 +  sbintrunc.Suc [where bin="Int.Pls", simplified bin_last_simps bin_rest_simps, standard]
  31.140  
  31.141  lemmas sbintrunc_Suc_Min = 
  31.142 -  sbintrunc.Suc [where bin="Numeral.Min", simplified bin_last_simps bin_rest_simps, standard]
  31.143 +  sbintrunc.Suc [where bin="Int.Min", simplified bin_last_simps bin_rest_simps, standard]
  31.144  
  31.145  lemmas sbintrunc_Suc_BIT [simp] = 
  31.146    sbintrunc.Suc [where bin="w BIT b", simplified bin_last_simps bin_rest_simps, standard]
  31.147 @@ -326,11 +326,11 @@
  31.148  lemmas sbintrunc_Sucs = sbintrunc_Suc_Pls sbintrunc_Suc_Min sbintrunc_Suc_BIT
  31.149  
  31.150  lemmas sbintrunc_Pls = 
  31.151 -  sbintrunc.Z [where bin="Numeral.Pls", 
  31.152 +  sbintrunc.Z [where bin="Int.Pls", 
  31.153                 simplified bin_last_simps bin_rest_simps bit.simps, standard]
  31.154  
  31.155  lemmas sbintrunc_Min = 
  31.156 -  sbintrunc.Z [where bin="Numeral.Min", 
  31.157 +  sbintrunc.Z [where bin="Int.Min", 
  31.158                 simplified bin_last_simps bin_rest_simps bit.simps, standard]
  31.159  
  31.160  lemmas sbintrunc_0_BIT_B0 [simp] = 
  31.161 @@ -361,12 +361,12 @@
  31.162    sbintrunc_Sucs [THEN [2] sbintrunc_minus [symmetric, THEN trans], standard]
  31.163  
  31.164  lemma bintrunc_n_Pls [simp]:
  31.165 -  "bintrunc n Numeral.Pls = Numeral.Pls"
  31.166 +  "bintrunc n Int.Pls = Int.Pls"
  31.167    by (induct n) auto
  31.168  
  31.169  lemma sbintrunc_n_PM [simp]:
  31.170 -  "sbintrunc n Numeral.Pls = Numeral.Pls"
  31.171 -  "sbintrunc n Numeral.Min = Numeral.Min"
  31.172 +  "sbintrunc n Int.Pls = Int.Pls"
  31.173 +  "sbintrunc n Int.Min = Int.Min"
  31.174    by (induct n) auto
  31.175  
  31.176  lemmas thobini1 = arg_cong [where f = "%w. w BIT b", standard]
  31.177 @@ -379,9 +379,9 @@
  31.178  lemmas bintrunc_Min_minus_I = bmsts(2)
  31.179  lemmas bintrunc_BIT_minus_I = bmsts(3)
  31.180  
  31.181 -lemma bintrunc_0_Min: "bintrunc 0 Numeral.Min = Numeral.Pls"
  31.182 +lemma bintrunc_0_Min: "bintrunc 0 Int.Min = Int.Pls"
  31.183    by auto
  31.184 -lemma bintrunc_0_BIT: "bintrunc 0 (w BIT b) = Numeral.Pls"
  31.185 +lemma bintrunc_0_BIT: "bintrunc 0 (w BIT b) = Int.Pls"
  31.186    by auto
  31.187  
  31.188  lemma bintrunc_Suc_lem:
  31.189 @@ -558,7 +558,7 @@
  31.190    by (simp add : no_bintr m2pths)
  31.191  
  31.192  lemma bintr_Min: 
  31.193 -  "number_of (bintrunc n Numeral.Min) = (2 ^ n :: int) - 1"
  31.194 +  "number_of (bintrunc n Int.Min) = (2 ^ n :: int) - 1"
  31.195    by (simp add : no_bintr m1mod2k)
  31.196  
  31.197  lemma sbintr_ge: "(- (2 ^ n) :: int) <= number_of (sbintrunc n w)"
  31.198 @@ -572,11 +572,11 @@
  31.199    by (case_tac bin rule: bin_exhaust) auto
  31.200  
  31.201  lemma sign_Pls_ge_0: 
  31.202 -  "(bin_sign bin = Numeral.Pls) = (number_of bin >= (0 :: int))"
  31.203 +  "(bin_sign bin = Int.Pls) = (number_of bin >= (0 :: int))"
  31.204    by (induct bin rule: bin_induct) auto
  31.205  
  31.206  lemma sign_Min_lt_0: 
  31.207 -  "(bin_sign bin = Numeral.Min) = (number_of bin < (0 :: int))"
  31.208 +  "(bin_sign bin = Int.Min) = (number_of bin < (0 :: int))"
  31.209    by (induct bin rule: bin_induct) auto
  31.210  
  31.211  lemmas sign_Min_neg = trans [OF sign_Min_lt_0 neg_def [symmetric]] 
  31.212 @@ -647,7 +647,7 @@
  31.213  consts
  31.214    bin_split :: "nat => int => int * int"
  31.215  primrec
  31.216 -  Z : "bin_split 0 w = (w, Numeral.Pls)"
  31.217 +  Z : "bin_split 0 w = (w, Int.Pls)"
  31.218    Suc : "bin_split (Suc n) w = (let (w1, w2) = bin_split n (bin_rest w)
  31.219      in (w1, w2 BIT bin_last w))"
  31.220  
  31.221 @@ -702,7 +702,7 @@
  31.222    by auto
  31.223  
  31.224  lemma size_Cons_lem_eq_bin:
  31.225 -  "y = xa # list ==> size y = number_of (Numeral.succ k) ==> 
  31.226 +  "y = xa # list ==> size y = number_of (Int.succ k) ==> 
  31.227      size list = number_of k"
  31.228    by (auto simp: pred_def succ_def split add : split_if_asm)
  31.229  
    32.1 --- a/src/HOL/Word/BinOperations.thy	Tue Jan 15 16:19:21 2008 +0100
    32.2 +++ b/src/HOL/Word/BinOperations.thy	Tue Jan 15 16:19:23 2008 +0100
    32.3 @@ -21,15 +21,15 @@
    32.4  begin
    32.5  
    32.6  definition
    32.7 -  int_not_def: "bitNOT = bin_rec Numeral.Min Numeral.Pls 
    32.8 +  int_not_def: "bitNOT = bin_rec Int.Min Int.Pls 
    32.9      (\<lambda>w b s. s BIT (NOT b))"
   32.10  
   32.11  definition
   32.12 -  int_and_def: "bitAND = bin_rec (\<lambda>x. Numeral.Pls) (\<lambda>y. y) 
   32.13 +  int_and_def: "bitAND = bin_rec (\<lambda>x. Int.Pls) (\<lambda>y. y) 
   32.14      (\<lambda>w b s y. s (bin_rest y) BIT (b AND bin_last y))"
   32.15  
   32.16  definition
   32.17 -  int_or_def: "bitOR = bin_rec (\<lambda>x. x) (\<lambda>y. Numeral.Min) 
   32.18 +  int_or_def: "bitOR = bin_rec (\<lambda>x. x) (\<lambda>y. Int.Min) 
   32.19      (\<lambda>w b s y. s (bin_rest y) BIT (b OR bin_last y))"
   32.20  
   32.21  definition
   32.22 @@ -41,17 +41,17 @@
   32.23  end
   32.24  
   32.25  lemma int_not_simps [simp]:
   32.26 -  "NOT Numeral.Pls = Numeral.Min"
   32.27 -  "NOT Numeral.Min = Numeral.Pls"
   32.28 +  "NOT Int.Pls = Int.Min"
   32.29 +  "NOT Int.Min = Int.Pls"
   32.30    "NOT (w BIT b) = (NOT w) BIT (NOT b)"
   32.31    by (unfold int_not_def) (auto intro: bin_rec_simps)
   32.32  
   32.33  lemma int_xor_Pls [simp]: 
   32.34 -  "Numeral.Pls XOR x = x"
   32.35 +  "Int.Pls XOR x = x"
   32.36    unfolding int_xor_def by (simp add: bin_rec_PM)
   32.37  
   32.38  lemma int_xor_Min [simp]: 
   32.39 -  "Numeral.Min XOR x = NOT x"
   32.40 +  "Int.Min XOR x = NOT x"
   32.41    unfolding int_xor_def by (simp add: bin_rec_PM)
   32.42  
   32.43  lemma int_xor_Bits [simp]: 
   32.44 @@ -66,8 +66,8 @@
   32.45    done
   32.46  
   32.47  lemma int_xor_x_simps':
   32.48 -  "w XOR (Numeral.Pls BIT bit.B0) = w"
   32.49 -  "w XOR (Numeral.Min BIT bit.B1) = NOT w"
   32.50 +  "w XOR (Int.Pls BIT bit.B0) = w"
   32.51 +  "w XOR (Int.Min BIT bit.B1) = NOT w"
   32.52    apply (induct w rule: bin_induct)
   32.53         apply simp_all[4]
   32.54     apply (unfold int_xor_Bits)
   32.55 @@ -77,11 +77,11 @@
   32.56  lemmas int_xor_extra_simps [simp] = int_xor_x_simps' [simplified arith_simps]
   32.57  
   32.58  lemma int_or_Pls [simp]: 
   32.59 -  "Numeral.Pls OR x = x"
   32.60 +  "Int.Pls OR x = x"
   32.61    by (unfold int_or_def) (simp add: bin_rec_PM)
   32.62    
   32.63  lemma int_or_Min [simp]:
   32.64 -  "Numeral.Min OR x = Numeral.Min"
   32.65 +  "Int.Min OR x = Int.Min"
   32.66    by (unfold int_or_def) (simp add: bin_rec_PM)
   32.67  
   32.68  lemma int_or_Bits [simp]: 
   32.69 @@ -89,8 +89,8 @@
   32.70    unfolding int_or_def by (simp add: bin_rec_simps)
   32.71  
   32.72  lemma int_or_x_simps': 
   32.73 -  "w OR (Numeral.Pls BIT bit.B0) = w"
   32.74 -  "w OR (Numeral.Min BIT bit.B1) = Numeral.Min"
   32.75 +  "w OR (Int.Pls BIT bit.B0) = w"
   32.76 +  "w OR (Int.Min BIT bit.B1) = Int.Min"
   32.77    apply (induct w rule: bin_induct)
   32.78         apply simp_all[4]
   32.79     apply (unfold int_or_Bits)
   32.80 @@ -101,11 +101,11 @@
   32.81  
   32.82  
   32.83  lemma int_and_Pls [simp]:
   32.84 -  "Numeral.Pls AND x = Numeral.Pls"
   32.85 +  "Int.Pls AND x = Int.Pls"
   32.86    unfolding int_and_def by (simp add: bin_rec_PM)
   32.87  
   32.88  lemma int_and_Min [simp]:
   32.89 -  "Numeral.Min AND x = x"
   32.90 +  "Int.Min AND x = x"
   32.91    unfolding int_and_def by (simp add: bin_rec_PM)
   32.92  
   32.93  lemma int_and_Bits [simp]: 
   32.94 @@ -113,8 +113,8 @@
   32.95    unfolding int_and_def by (simp add: bin_rec_simps)
   32.96  
   32.97  lemma int_and_x_simps': 
   32.98 -  "w AND (Numeral.Pls BIT bit.B0) = Numeral.Pls"
   32.99 -  "w AND (Numeral.Min BIT bit.B1) = w"
  32.100 +  "w AND (Int.Pls BIT bit.B0) = Int.Pls"
  32.101 +  "w AND (Int.Min BIT bit.B1) = w"
  32.102    apply (induct w rule: bin_induct)
  32.103         apply simp_all[4]
  32.104     apply (unfold int_and_Bits)
  32.105 @@ -137,7 +137,7 @@
  32.106  lemma bin_ops_same [simp]:
  32.107    "(x::int) AND x = x" 
  32.108    "(x::int) OR x = x" 
  32.109 -  "(x::int) XOR x = Numeral.Pls"
  32.110 +  "(x::int) XOR x = Int.Pls"
  32.111    by (induct x rule: bin_induct) auto
  32.112  
  32.113  lemma int_not_not [simp]: "NOT (NOT (x::int)) = x"
  32.114 @@ -268,7 +268,7 @@
  32.115    done
  32.116  
  32.117  lemma le_int_or:
  32.118 -  "!!x.  bin_sign y = Numeral.Pls ==> x <= x OR y"
  32.119 +  "!!x.  bin_sign y = Int.Pls ==> x <= x OR y"
  32.120    apply (induct y rule: bin_induct)
  32.121      apply clarsimp
  32.122     apply clarsimp
  32.123 @@ -297,7 +297,7 @@
  32.124  
  32.125  (* interaction between bit-wise and arithmetic *)
  32.126  (* good example of bin_induction *)
  32.127 -lemma bin_add_not: "x + NOT x = Numeral.Min"
  32.128 +lemma bin_add_not: "x + NOT x = Int.Min"
  32.129    apply (induct x rule: bin_induct)
  32.130      apply clarsimp
  32.131     apply clarsimp
  32.132 @@ -428,10 +428,10 @@
  32.133     apply (simp_all split: bit.split)
  32.134    done
  32.135  
  32.136 -lemma bin_sc_FP [simp]: "bin_sc n bit.B0 Numeral.Pls = Numeral.Pls"
  32.137 +lemma bin_sc_FP [simp]: "bin_sc n bit.B0 Int.Pls = Int.Pls"
  32.138    by (induct n) auto
  32.139  
  32.140 -lemma bin_sc_TM [simp]: "bin_sc n bit.B1 Numeral.Min = Numeral.Min"
  32.141 +lemma bin_sc_TM [simp]: "bin_sc n bit.B1 Int.Min = Int.Min"
  32.142    by (induct n) auto
  32.143    
  32.144  lemmas bin_sc_simps = bin_sc.Z bin_sc.Suc bin_sc_TM bin_sc_FP
  32.145 @@ -468,7 +468,7 @@
  32.146  
  32.147  defs
  32.148    bin_to_bl_def : "bin_to_bl n w == bin_to_bl_aux n w []"
  32.149 -  bl_to_bin_def : "bl_to_bin bs == bl_to_bin_aux Numeral.Pls bs"
  32.150 +  bl_to_bin_def : "bl_to_bin bs == bl_to_bin_aux Int.Pls bs"
  32.151  
  32.152  primrec
  32.153    Suc : "bl_of_nth (Suc n) f = f n # bl_of_nth n f"
  32.154 @@ -512,7 +512,7 @@
  32.155        in bin_rsplitl_aux (n, b # bs, (m - n, a)))"
  32.156  
  32.157  defs
  32.158 -  bin_rcat_def : "bin_rcat n bs == foldl (%u v. bin_cat u n v) Numeral.Pls bs"
  32.159 +  bin_rcat_def : "bin_rcat n bs == foldl (%u v. bin_cat u n v) Int.Pls bs"
  32.160    bin_rsplit_def : "bin_rsplit n w == bin_rsplit_aux (n, [], w)"
  32.161    bin_rsplitl_def : "bin_rsplitl n w == bin_rsplitl_aux (n, [], w)"
  32.162       
  32.163 @@ -559,7 +559,7 @@
  32.164    done
  32.165  
  32.166  lemma bin_cat_Pls [simp]: 
  32.167 -  "!!w. bin_cat Numeral.Pls n w = bintrunc n w"
  32.168 +  "!!w. bin_cat Int.Pls n w = bintrunc n w"
  32.169    by (induct n) auto
  32.170  
  32.171  lemma bintr_cat1: 
  32.172 @@ -591,11 +591,11 @@
  32.173    by (induct n) auto
  32.174  
  32.175  lemma bin_split_Pls [simp]:
  32.176 -  "bin_split n Numeral.Pls = (Numeral.Pls, Numeral.Pls)"
  32.177 +  "bin_split n Int.Pls = (Int.Pls, Int.Pls)"
  32.178    by (induct n) (auto simp: Let_def split: ls_splits)
  32.179  
  32.180  lemma bin_split_Min [simp]:
  32.181 -  "bin_split n Numeral.Min = (Numeral.Min, bintrunc n Numeral.Min)"
  32.182 +  "bin_split n Int.Min = (Int.Min, bintrunc n Int.Min)"
  32.183    by (induct n) (auto simp: Let_def split: ls_splits)
  32.184  
  32.185  lemma bin_split_trunc:
    33.1 --- a/src/HOL/Word/Num_Lemmas.thy	Tue Jan 15 16:19:21 2008 +0100
    33.2 +++ b/src/HOL/Word/Num_Lemmas.thy	Tue Jan 15 16:19:23 2008 +0100
    33.3 @@ -50,7 +50,7 @@
    33.4  lemmas xtr8 = xtrans(8)
    33.5  
    33.6  lemma Min_ne_Pls [iff]:  
    33.7 -  "Numeral.Min ~= Numeral.Pls"
    33.8 +  "Int.Min ~= Int.Pls"
    33.9    unfolding Min_def Pls_def by auto
   33.10  
   33.11  lemmas Pls_ne_Min [iff] = Min_ne_Pls [symmetric]
   33.12 @@ -72,7 +72,7 @@
   33.13  
   33.14  lemma nobm1:
   33.15    "0 < (number_of w :: nat) ==> 
   33.16 -   number_of w - (1 :: nat) = number_of (Numeral.pred w)"
   33.17 +   number_of w - (1 :: nat) = number_of (Int.pred w)"
   33.18    apply (unfold nat_number_of_def One_nat_def nat_1 [symmetric] pred_def)
   33.19    apply (simp add: number_of_eq nat_diff_distrib [symmetric])
   33.20    done
   33.21 @@ -201,7 +201,7 @@
   33.22    Pls_0_eq Min_1_eq refl 
   33.23  
   33.24  lemma bin_abs_lem:
   33.25 -  "bin = (w BIT b) ==> ~ bin = Numeral.Min --> ~ bin = Numeral.Pls -->
   33.26 +  "bin = (w BIT b) ==> ~ bin = Int.Min --> ~ bin = Int.Pls -->
   33.27      nat (abs w) < nat (abs bin)"
   33.28    apply (clarsimp simp add: bin_rl_char)
   33.29    apply (unfold Pls_def Min_def Bit_def)
   33.30 @@ -211,8 +211,8 @@
   33.31    done
   33.32  
   33.33  lemma bin_induct:
   33.34 -  assumes PPls: "P Numeral.Pls"
   33.35 -    and PMin: "P Numeral.Min"
   33.36 +  assumes PPls: "P Int.Pls"
   33.37 +    and PMin: "P Int.Min"
   33.38      and PBit: "!!bin bit. P bin ==> P (bin BIT bit)"
   33.39    shows "P bin"
   33.40    apply (rule_tac P=P and a=bin and f1="nat o abs" 
    34.1 --- a/src/HOL/Word/WordArith.thy	Tue Jan 15 16:19:21 2008 +0100
    34.2 +++ b/src/HOL/Word/WordArith.thy	Tue Jan 15 16:19:23 2008 +0100
    34.3 @@ -61,17 +61,17 @@
    34.4  lemmas word_0_wi_Pls = word_0_wi [folded Pls_def]
    34.5  lemmas word_0_no = word_0_wi_Pls [folded word_no_wi]
    34.6  
    34.7 -lemma int_one_bin: "(1 :: int) == (Numeral.Pls BIT bit.B1)"
    34.8 +lemma int_one_bin: "(1 :: int) == (Int.Pls BIT bit.B1)"
    34.9    unfolding Pls_def Bit_def by auto
   34.10  
   34.11  lemma word_1_no: 
   34.12 -  "(1 :: 'a :: len0 word) == number_of (Numeral.Pls BIT bit.B1)"
   34.13 +  "(1 :: 'a :: len0 word) == number_of (Int.Pls BIT bit.B1)"
   34.14    unfolding word_1_wi word_number_of_def int_one_bin by auto
   34.15  
   34.16  lemma word_m1_wi: "-1 == word_of_int -1" 
   34.17    by (rule word_number_of_alt)
   34.18  
   34.19 -lemma word_m1_wi_Min: "-1 = word_of_int Numeral.Min"
   34.20 +lemma word_m1_wi_Min: "-1 = word_of_int Int.Min"
   34.21    by (simp add: word_m1_wi number_of_eq)
   34.22  
   34.23  lemma word_0_bl: "of_bl [] = 0" 
   34.24 @@ -169,8 +169,8 @@
   34.25    wi_hom_add: "word_of_int a + word_of_int b = word_of_int (a + b)" and
   34.26    wi_hom_mult: "word_of_int a * word_of_int b = word_of_int (a * b)" and
   34.27    wi_hom_neg: "- word_of_int a = word_of_int (- a)" and
   34.28 -  wi_hom_succ: "word_succ (word_of_int a) = word_of_int (Numeral.succ a)" and
   34.29 -  wi_hom_pred: "word_pred (word_of_int a) = word_of_int (Numeral.pred a)"
   34.30 +  wi_hom_succ: "word_succ (word_of_int a) = word_of_int (Int.succ a)" and
   34.31 +  wi_hom_pred: "word_pred (word_of_int a) = word_of_int (Int.pred a)"
   34.32    by (auto simp: word_arith_wis arths)
   34.33  
   34.34  lemmas wi_hom_syms = wi_homs [symmetric]
   34.35 @@ -255,15 +255,15 @@
   34.36    unfolding word_pred_def number_of_eq
   34.37    by (simp add : pred_def word_no_wi)
   34.38  
   34.39 -lemma word_pred_0_Min: "word_pred 0 = word_of_int Numeral.Min"
   34.40 +lemma word_pred_0_Min: "word_pred 0 = word_of_int Int.Min"
   34.41    by (simp add: word_pred_0_n1 number_of_eq)
   34.42  
   34.43 -lemma word_m1_Min: "- 1 = word_of_int Numeral.Min"
   34.44 +lemma word_m1_Min: "- 1 = word_of_int Int.Min"
   34.45    unfolding Min_def by (simp only: word_of_int_hom_syms)
   34.46  
   34.47  lemma succ_pred_no [simp]:
   34.48 -  "word_succ (number_of bin) = number_of (Numeral.succ bin) & 
   34.49 -    word_pred (number_of bin) = number_of (Numeral.pred bin)"
   34.50 +  "word_succ (number_of bin) = number_of (Int.succ bin) & 
   34.51 +    word_pred (number_of bin) = number_of (Int.pred bin)"
   34.52    unfolding word_number_of_def by (simp add : new_word_of_int_homs)
   34.53  
   34.54  lemma word_sp_01 [simp] : 
   34.55 @@ -797,7 +797,7 @@
   34.56     which requires word length >= 1, ie 'a :: len word *) 
   34.57  lemma zero_bintrunc:
   34.58    "iszero (number_of x :: 'a :: len word) = 
   34.59 -    (bintrunc (len_of TYPE('a)) x = Numeral.Pls)"
   34.60 +    (bintrunc (len_of TYPE('a)) x = Int.Pls)"
   34.61    apply (unfold iszero_def word_0_wi word_no_wi)
   34.62    apply (rule word_ubin.norm_eq_iff [symmetric, THEN trans])
   34.63    apply (simp add : Pls_def [symmetric])
    35.1 --- a/src/HOL/Word/WordDefinition.thy	Tue Jan 15 16:19:21 2008 +0100
    35.2 +++ b/src/HOL/Word/WordDefinition.thy	Tue Jan 15 16:19:23 2008 +0100
    35.3 @@ -160,12 +160,12 @@
    35.4  definition
    35.5    word_succ :: "'a :: len0 word => 'a word"
    35.6  where
    35.7 -  "word_succ a = word_of_int (Numeral.succ (uint a))"
    35.8 +  "word_succ a = word_of_int (Int.succ (uint a))"
    35.9  
   35.10  definition
   35.11    word_pred :: "'a :: len0 word => 'a word"
   35.12  where
   35.13 -  "word_pred a = word_of_int (Numeral.pred (uint a))"
   35.14 +  "word_pred a = word_of_int (Int.pred (uint a))"
   35.15  
   35.16  constdefs
   35.17    udvd :: "'a::len word => 'a::len word => bool" (infixl "udvd" 50)
   35.18 @@ -195,7 +195,7 @@
   35.19    "lsb (a::'a::len0 word) == bin_last (uint a) = bit.B1"
   35.20  
   35.21    word_msb_def: 
   35.22 -  "msb (a::'a::len word) == bin_sign (sint a) = Numeral.Min"
   35.23 +  "msb (a::'a::len word) == bin_sign (sint a) = Int.Min"
   35.24  
   35.25  
   35.26  constdefs
   35.27 @@ -475,7 +475,7 @@
   35.28  lemmas sint_lt = sint_lem [THEN conjunct2, standard]
   35.29  
   35.30  lemma sign_uint_Pls [simp]: 
   35.31 -  "bin_sign (uint x) = Numeral.Pls"
   35.32 +  "bin_sign (uint x) = Int.Pls"
   35.33    by (simp add: sign_Pls_ge_0 number_of_eq)
   35.34  
   35.35  lemmas uint_m2p_neg = iffD2 [OF diff_less_0_iff_less uint_lt2p, standard]
   35.36 @@ -498,7 +498,7 @@
   35.37    by (simp only: int_word_uint)
   35.38  
   35.39  lemma unat_number_of: 
   35.40 -  "bin_sign b = Numeral.Pls ==> 
   35.41 +  "bin_sign b = Int.Pls ==> 
   35.42    unat (number_of b::'a::len0 word) = number_of b mod 2 ^ len_of TYPE ('a)"
   35.43    apply (unfold unat_def)
   35.44    apply (clarsimp simp only: uint_number_of)
   35.45 @@ -643,7 +643,7 @@
   35.46    length_bl_gt_0 [THEN length_greater_0_conv [THEN iffD1], standard]
   35.47  lemmas length_bl_neq_0 [iff] = length_bl_gt_0 [THEN gr_implies_not0]
   35.48  
   35.49 -lemma hd_bl_sign_sint: "hd (to_bl w) = (bin_sign (sint w) = Numeral.Min)"
   35.50 +lemma hd_bl_sign_sint: "hd (to_bl w) = (bin_sign (sint w) = Int.Min)"
   35.51    apply (unfold to_bl_def sint_uint)
   35.52    apply (rule trans [OF _ bl_sbin_sign])
   35.53    apply simp
    36.1 --- a/src/HOL/Word/WordShift.thy	Tue Jan 15 16:19:21 2008 +0100
    36.2 +++ b/src/HOL/Word/WordShift.thy	Tue Jan 15 16:19:23 2008 +0100
    36.3 @@ -483,7 +483,7 @@
    36.4  lemma mask_bl: "mask n = of_bl (replicate n True)"
    36.5    by (auto simp add : test_bit_of_bl word_size intro: word_eqI)
    36.6  
    36.7 -lemma mask_bin: "mask n = number_of (bintrunc n Numeral.Min)"
    36.8 +lemma mask_bin: "mask n = number_of (bintrunc n Int.Min)"
    36.9    by (auto simp add: nth_bintr word_size intro: word_eqI)
   36.10  
   36.11  lemma and_mask_bintr: "w AND mask n = number_of (bintrunc n (uint w))"
    37.1 --- a/src/HOL/ex/SVC_Oracle.thy	Tue Jan 15 16:19:21 2008 +0100
    37.2 +++ b/src/HOL/ex/SVC_Oracle.thy	Tue Jan 15 16:19:23 2008 +0100
    37.3 @@ -64,7 +64,7 @@
    37.4      (*abstraction of a numeric literal*)
    37.5      fun lit (t as Const(@{const_name HOL.zero}, _)) = t
    37.6        | lit (t as Const(@{const_name HOL.one}, _)) = t
    37.7 -      | lit (t as Const(@{const_name Numeral.number_of}, _) $ w) = t
    37.8 +      | lit (t as Const(@{const_name Int.number_of}, _) $ w) = t
    37.9        | lit t = replace t
   37.10      (*abstraction of a real/rational expression*)
   37.11      fun rat ((c as Const(@{const_name HOL.plus}, _)) $ x $ y) = c $ (rat x) $ (rat y)
    38.1 --- a/src/HOL/hologic.ML	Tue Jan 15 16:19:21 2008 +0100
    38.2 +++ b/src/HOL/hologic.ML	Tue Jan 15 16:19:23 2008 +0100
    38.3 @@ -448,27 +448,27 @@
    38.4  
    38.5  (* bit *)
    38.6  
    38.7 -val bitT = Type ("Numeral.bit", []);
    38.8 +val bitT = Type ("Int.bit", []);
    38.9  
   38.10 -val B0_const = Const ("Numeral.bit.B0", bitT);
   38.11 -val B1_const =  Const ("Numeral.bit.B1", bitT);
   38.12 +val B0_const = Const ("Int.bit.B0", bitT);
   38.13 +val B1_const =  Const ("Int.bit.B1", bitT);
   38.14  
   38.15  fun mk_bit 0 = B0_const
   38.16    | mk_bit 1 = B1_const
   38.17    | mk_bit _ = raise TERM ("mk_bit", []);
   38.18  
   38.19 -fun dest_bit (Const ("Numeral.bit.B0", _)) = 0
   38.20 -  | dest_bit (Const ("Numeral.bit.B1", _)) = 1
   38.21 +fun dest_bit (Const ("Int.bit.B0", _)) = 0
   38.22 +  | dest_bit (Const ("Int.bit.B1", _)) = 1
   38.23    | dest_bit t = raise TERM ("dest_bit", [t]);
   38.24  
   38.25  
   38.26  (* binary numerals and int -- non-unique representation due to leading zeros/ones! *)
   38.27  
   38.28 -val intT = Type ("IntDef.int", []);
   38.29 +val intT = Type ("Int.int", []);
   38.30  
   38.31 -val pls_const = Const ("Numeral.Pls", intT)
   38.32 -and min_const = Const ("Numeral.Min", intT)
   38.33 -and bit_const = Const ("Numeral.Bit", intT --> bitT --> intT);
   38.34 +val pls_const = Const ("Int.Pls", intT)
   38.35 +and min_const = Const ("Int.Min", intT)
   38.36 +and bit_const = Const ("Int.Bit", intT --> bitT --> intT);
   38.37  
   38.38  fun mk_numeral 0 = pls_const
   38.39    | mk_numeral ~1 = min_const
   38.40 @@ -476,14 +476,14 @@
   38.41        let val (q, r) = Integer.div_mod i 2;
   38.42        in bit_const $ mk_numeral q $ mk_bit r end;
   38.43  
   38.44 -fun dest_numeral (Const ("Numeral.Pls", _)) = 0
   38.45 -  | dest_numeral (Const ("Numeral.Min", _)) = ~1
   38.46 -  | dest_numeral (Const ("Numeral.Bit", _) $ bs $ b) = 2 * dest_numeral bs + dest_bit b
   38.47 +fun dest_numeral (Const ("Int.Pls", _)) = 0
   38.48 +  | dest_numeral (Const ("Int.Min", _)) = ~1
   38.49 +  | dest_numeral (Const ("Int.Bit", _) $ bs $ b) = 2 * dest_numeral bs + dest_bit b
   38.50    | dest_numeral t = raise TERM ("dest_numeral", [t]);
   38.51  
   38.52 -fun number_of_const T = Const ("Numeral.number_class.number_of", intT --> T);
   38.53 +fun number_of_const T = Const ("Int.number_class.number_of", intT --> T);
   38.54  
   38.55 -fun add_numerals (Const ("Numeral.number_class.number_of", Type (_, [_, T])) $ t) = cons (t, T)
   38.56 +fun add_numerals (Const ("Int.number_class.number_of", Type (_, [_, T])) $ t) = cons (t, T)
   38.57    | add_numerals (t $ u) = add_numerals t #> add_numerals u
   38.58    | add_numerals (Abs (_, _, t)) = add_numerals t
   38.59    | add_numerals _ = I;
   38.60 @@ -494,7 +494,7 @@
   38.61  
   38.62  fun dest_number (Const ("HOL.zero_class.zero", T)) = (T, 0)
   38.63    | dest_number (Const ("HOL.one_class.one", T)) = (T, 1)
   38.64 -  | dest_number (Const ("Numeral.number_class.number_of", Type ("fun", [_, T])) $ t) =
   38.65 +  | dest_number (Const ("Int.number_class.number_of", Type ("fun", [_, T])) $ t) =
   38.66        (T, dest_numeral t)
   38.67    | dest_number t = raise TERM ("dest_number", [t]);
   38.68  
    39.1 --- a/src/HOL/int_arith1.ML	Tue Jan 15 16:19:21 2008 +0100
    39.2 +++ b/src/HOL/int_arith1.ML	Tue Jan 15 16:19:23 2008 +0100
    39.3 @@ -18,7 +18,7 @@
    39.4    fun prep_simproc (name, pats, proc) =
    39.5      Simplifier.simproc (the_context()) name pats proc;
    39.6  
    39.7 -  fun is_numeral (Const(@{const_name Numeral.number_of}, _) $ w) = true
    39.8 +  fun is_numeral (Const(@{const_name Int.number_of}, _) $ w) = true
    39.9      | is_numeral _ = false
   39.10  
   39.11    fun simplify_meta_eq f_number_of_eq f_eq =
   39.12 @@ -30,16 +30,16 @@
   39.13    val meta_number_of_reorient = @{thm number_of_reorient} RS eq_reflection
   39.14  
   39.15    (*reorientation simplification procedure: reorients (polymorphic) 
   39.16 -    0 = x, 1 = x, nnn = x provided x isn't 0, 1 or a numeral.*)
   39.17 +    0 = x, 1 = x, nnn = x provided x isn't 0, 1 or a Int.*)
   39.18    fun reorient_proc sg _ (_ $ t $ u) =
   39.19      case u of
   39.20          Const(@{const_name HOL.zero}, _) => NONE
   39.21        | Const(@{const_name HOL.one}, _) => NONE
   39.22 -      | Const(@{const_name Numeral.number_of}, _) $ _ => NONE
   39.23 +      | Const(@{const_name Int.number_of}, _) $ _ => NONE
   39.24        | _ => SOME (case t of
   39.25            Const(@{const_name HOL.zero}, _) => meta_zero_reorient
   39.26          | Const(@{const_name HOL.one}, _) => meta_one_reorient
   39.27 -        | Const(@{const_name Numeral.number_of}, _) $ _ => meta_number_of_reorient)
   39.28 +        | Const(@{const_name Int.number_of}, _) $ _ => meta_number_of_reorient)
   39.29  
   39.30    val reorient_simproc = 
   39.31        prep_simproc ("reorient_simproc", ["0=x", "1=x", "number_of w = x"], reorient_proc)
   39.32 @@ -73,10 +73,10 @@
   39.33  fun numterm_ord (Abs (_, T, t), Abs(_, U, u)) =
   39.34        (case numterm_ord (t, u) of EQUAL => typ_ord (T, U) | ord => ord)
   39.35    | numterm_ord
   39.36 -     (Const(@{const_name Numeral.number_of}, _) $ v, Const(@{const_name Numeral.number_of}, _) $ w) =
   39.37 +     (Const(@{const_name Int.number_of}, _) $ v, Const(@{const_name Int.number_of}, _) $ w) =
   39.38       num_ord (HOLogic.dest_numeral v, HOLogic.dest_numeral w)
   39.39 -  | numterm_ord (Const(@{const_name Numeral.number_of}, _) $ _, _) = LESS
   39.40 -  | numterm_ord (_, Const(@{const_name Numeral.number_of}, _) $ _) = GREATER
   39.41 +  | numterm_ord (Const(@{const_name Int.number_of}, _) $ _, _) = LESS
   39.42 +  | numterm_ord (_, Const(@{const_name Int.number_of}, _) $ _) = GREATER
   39.43    | numterm_ord (t, u) =
   39.44        (case int_ord (size_of_term t, size_of_term u) of
   39.45          EQUAL =>
   39.46 @@ -575,7 +575,7 @@
   39.47                        addsimprocs Int_Numeral_Base_Simprocs
   39.48                        addcongs [if_weak_cong]}) #>
   39.49    arith_inj_const (@{const_name of_nat}, HOLogic.natT --> HOLogic.intT) #>
   39.50 -  arith_discrete "IntDef.int"
   39.51 +  arith_discrete @{type_name Int.int}
   39.52  
   39.53  end;
   39.54  
    40.1 --- a/src/HOL/nat_simprocs.ML	Tue Jan 15 16:19:21 2008 +0100
    40.2 +++ b/src/HOL/nat_simprocs.ML	Tue Jan 15 16:19:23 2008 +0100
    40.3 @@ -105,7 +105,7 @@
    40.4        handle TERM _ => (k, t::ts);
    40.5  
    40.6  (*Code for testing whether numerals are already used in the goal*)
    40.7 -fun is_numeral (Const(@{const_name Numeral.number_of}, _) $ w) = true
    40.8 +fun is_numeral (Const(@{const_name Int.number_of}, _) $ w) = true
    40.9    | is_numeral _ = false;
   40.10  
   40.11  fun prod_has_numeral t = exists is_numeral (dest_prod t);
    41.1 --- a/src/Provers/Arith/assoc_fold.ML	Tue Jan 15 16:19:21 2008 +0100
    41.2 +++ b/src/Provers/Arith/assoc_fold.ML	Tue Jan 15 16:19:23 2008 +0100
    41.3 @@ -30,7 +30,7 @@
    41.4  (*Separate the literals from the other terms being combined*)
    41.5  fun sift_terms plus (t, (lits,others)) =
    41.6    (case t of
    41.7 -    Const (@{const_name Numeral.number_of}, _) $ _ =>       (* FIXME logic dependent *)
    41.8 +    Const (@{const_name Int.number_of}, _) $ _ =>       (* FIXME logic dependent *)
    41.9        (t::lits, others)         (*new literal*)
   41.10    | (f as Const _) $ x $ y =>
   41.11        if f = plus