src/HOL/Integ/Int.ML
author wenzelm
Fri, 08 Mar 2002 16:24:06 +0100
changeset 13049 ce180e5b7fa0
parent 12613 279facb4253a
permissions -rw-r--r--
tuned;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5562
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
     1
(*  Title:      HOL/Integ/Int.ML
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
     2
    ID:         $Id$
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
     4
    Copyright   1998  University of Cambridge
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
     5
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
     6
Type "int" is a linear order
6866
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
     7
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
     8
And many further lemmas
5562
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
     9
*)
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
    10
7707
1f4b67fdfdae simprocs now in IntArith;
wenzelm
parents: 7518
diff changeset
    11
11868
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
    12
Goal "int 0 = (0::int)";
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
    13
by (simp_tac (simpset() addsimps [Zero_int_def]) 1);
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
    14
qed "int_0";
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
    15
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
    16
Goal "int 1 = 1";
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
    17
by (simp_tac (simpset() addsimps [One_int_def]) 1); 
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
    18
qed "int_1";
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
    19
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
    20
Goal "int (Suc 0) = 1";
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
    21
by (simp_tac (simpset() addsimps [One_int_def, One_nat_def]) 1); 
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
    22
qed "int_Suc0_eq_1";
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
    23
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
    24
Goalw [zdiff_def,zless_def] "neg x = (x < 0)";
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
    25
by Auto_tac; 
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
    26
qed "neg_eq_less_0"; 
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
    27
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
    28
Goalw [zle_def] "(~neg x) = (0 <= x)";
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
    29
by (simp_tac (simpset() addsimps [neg_eq_less_0]) 1); 
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
    30
qed "not_neg_eq_ge_0"; 
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
    31
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
    32
(** Needed to simplify inequalities when Numeral1 can get simplified to 1 **)
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
    33
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
    34
Goal "~ neg 0";
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
    35
by (simp_tac (simpset() addsimps [One_int_def, neg_eq_less_0]) 1);  
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
    36
qed "not_neg_0"; 
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
    37
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
    38
Goal "~ neg 1";
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
    39
by (simp_tac (simpset() addsimps [One_int_def, neg_eq_less_0]) 1);  
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
    40
qed "not_neg_1"; 
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
    41
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
    42
Goal "iszero 0";
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
    43
by (simp_tac (simpset() addsimps [iszero_def]) 1);
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
    44
qed "iszero_0"; 
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
    45
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
    46
Goal "~ iszero 1";
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
    47
by (simp_tac (simpset() addsimps [Zero_int_def, One_int_def, One_nat_def, 
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
    48
                                  iszero_def]) 1);
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
    49
qed "not_iszero_1"; 
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
    50
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
    51
Goal "0 < (1::int)";
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
    52
by (simp_tac (simpset() addsimps [Zero_int_def, One_int_def, One_nat_def]) 1); 
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
    53
qed "int_0_less_1";
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
    54
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
    55
Goal "0 \\<noteq> (1::int)";
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
    56
by (simp_tac (simpset() addsimps [Zero_int_def, One_int_def, One_nat_def]) 1); 
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
    57
qed "int_0_neq_1";
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
    58
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
    59
Addsimps [int_0, int_1, int_0_neq_1];
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
    60
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
    61
7707
1f4b67fdfdae simprocs now in IntArith;
wenzelm
parents: 7518
diff changeset
    62
(*** Abel_Cancel simproc on the integers ***)
1f4b67fdfdae simprocs now in IntArith;
wenzelm
parents: 7518
diff changeset
    63
1f4b67fdfdae simprocs now in IntArith;
wenzelm
parents: 7518
diff changeset
    64
(* Lemmas needed for the simprocs *)
1f4b67fdfdae simprocs now in IntArith;
wenzelm
parents: 7518
diff changeset
    65
1f4b67fdfdae simprocs now in IntArith;
wenzelm
parents: 7518
diff changeset
    66
(*Deletion of other terms in the formula, seeking the -x at the front of z*)
1f4b67fdfdae simprocs now in IntArith;
wenzelm
parents: 7518
diff changeset
    67
Goal "((x::int) + (y + z) = y + u) = ((x + z) = u)";
1f4b67fdfdae simprocs now in IntArith;
wenzelm
parents: 7518
diff changeset
    68
by (stac zadd_left_commute 1);
1f4b67fdfdae simprocs now in IntArith;
wenzelm
parents: 7518
diff changeset
    69
by (rtac zadd_left_cancel 1);
1f4b67fdfdae simprocs now in IntArith;
wenzelm
parents: 7518
diff changeset
    70
qed "zadd_cancel_21";
1f4b67fdfdae simprocs now in IntArith;
wenzelm
parents: 7518
diff changeset
    71
1f4b67fdfdae simprocs now in IntArith;
wenzelm
parents: 7518
diff changeset
    72
(*A further rule to deal with the case that
1f4b67fdfdae simprocs now in IntArith;
wenzelm
parents: 7518
diff changeset
    73
  everything gets cancelled on the right.*)
1f4b67fdfdae simprocs now in IntArith;
wenzelm
parents: 7518
diff changeset
    74
Goal "((x::int) + (y + z) = y) = (x = -z)";
1f4b67fdfdae simprocs now in IntArith;
wenzelm
parents: 7518
diff changeset
    75
by (stac zadd_left_commute 1);
11868
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
    76
by (res_inst_tac [("t", "y")] (zadd_0_right RS subst) 1
7707
1f4b67fdfdae simprocs now in IntArith;
wenzelm
parents: 7518
diff changeset
    77
    THEN stac zadd_left_cancel 1);
1f4b67fdfdae simprocs now in IntArith;
wenzelm
parents: 7518
diff changeset
    78
by (simp_tac (simpset() addsimps [eq_zdiff_eq RS sym]) 1);
1f4b67fdfdae simprocs now in IntArith;
wenzelm
parents: 7518
diff changeset
    79
qed "zadd_cancel_end";
1f4b67fdfdae simprocs now in IntArith;
wenzelm
parents: 7518
diff changeset
    80
1f4b67fdfdae simprocs now in IntArith;
wenzelm
parents: 7518
diff changeset
    81
1f4b67fdfdae simprocs now in IntArith;
wenzelm
parents: 7518
diff changeset
    82
structure Int_Cancel_Data =
1f4b67fdfdae simprocs now in IntArith;
wenzelm
parents: 7518
diff changeset
    83
struct
1f4b67fdfdae simprocs now in IntArith;
wenzelm
parents: 7518
diff changeset
    84
  val ss		= HOL_ss
1f4b67fdfdae simprocs now in IntArith;
wenzelm
parents: 7518
diff changeset
    85
  val eq_reflection	= eq_reflection
1f4b67fdfdae simprocs now in IntArith;
wenzelm
parents: 7518
diff changeset
    86
9436
62bb04ab4b01 rearranged setup of arithmetic procedures, avoiding global reference values;
wenzelm
parents: 8785
diff changeset
    87
  val sg_ref 		= Sign.self_ref (Theory.sign_of (the_context ()))
7707
1f4b67fdfdae simprocs now in IntArith;
wenzelm
parents: 7518
diff changeset
    88
  val T		= HOLogic.intT
11868
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
    89
  val zero		= Const ("0", HOLogic.intT)
7707
1f4b67fdfdae simprocs now in IntArith;
wenzelm
parents: 7518
diff changeset
    90
  val restrict_to_left  = restrict_to_left
1f4b67fdfdae simprocs now in IntArith;
wenzelm
parents: 7518
diff changeset
    91
  val add_cancel_21	= zadd_cancel_21
1f4b67fdfdae simprocs now in IntArith;
wenzelm
parents: 7518
diff changeset
    92
  val add_cancel_end	= zadd_cancel_end
1f4b67fdfdae simprocs now in IntArith;
wenzelm
parents: 7518
diff changeset
    93
  val add_left_cancel	= zadd_left_cancel
1f4b67fdfdae simprocs now in IntArith;
wenzelm
parents: 7518
diff changeset
    94
  val add_assoc		= zadd_assoc
1f4b67fdfdae simprocs now in IntArith;
wenzelm
parents: 7518
diff changeset
    95
  val add_commute	= zadd_commute
1f4b67fdfdae simprocs now in IntArith;
wenzelm
parents: 7518
diff changeset
    96
  val add_left_commute	= zadd_left_commute
11868
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
    97
  val add_0		= zadd_0
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
    98
  val add_0_right	= zadd_0_right
7707
1f4b67fdfdae simprocs now in IntArith;
wenzelm
parents: 7518
diff changeset
    99
1f4b67fdfdae simprocs now in IntArith;
wenzelm
parents: 7518
diff changeset
   100
  val eq_diff_eq	= eq_zdiff_eq
1f4b67fdfdae simprocs now in IntArith;
wenzelm
parents: 7518
diff changeset
   101
  val eqI_rules		= [zless_eqI, zeq_eqI, zle_eqI]
1f4b67fdfdae simprocs now in IntArith;
wenzelm
parents: 7518
diff changeset
   102
  fun dest_eqI th = 
11701
3d51fbf81c17 sane numerals (stage 1): added generic 1, removed 1' and 2 on nat,
wenzelm
parents: 10646
diff changeset
   103
      #1 (HOLogic.dest_bin "op =" HOLogic.boolT
7707
1f4b67fdfdae simprocs now in IntArith;
wenzelm
parents: 7518
diff changeset
   104
	      (HOLogic.dest_Trueprop (concl_of th)))
1f4b67fdfdae simprocs now in IntArith;
wenzelm
parents: 7518
diff changeset
   105
1f4b67fdfdae simprocs now in IntArith;
wenzelm
parents: 7518
diff changeset
   106
  val diff_def		= zdiff_def
1f4b67fdfdae simprocs now in IntArith;
wenzelm
parents: 7518
diff changeset
   107
  val minus_add_distrib	= zminus_zadd_distrib
1f4b67fdfdae simprocs now in IntArith;
wenzelm
parents: 7518
diff changeset
   108
  val minus_minus	= zminus_zminus
11868
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   109
  val minus_0		= zminus_0
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   110
  val add_inverses	= [zadd_zminus_inverse, zadd_zminus_inverse2]
7707
1f4b67fdfdae simprocs now in IntArith;
wenzelm
parents: 7518
diff changeset
   111
  val cancel_simps	= [zadd_zminus_cancel, zminus_zadd_cancel]
1f4b67fdfdae simprocs now in IntArith;
wenzelm
parents: 7518
diff changeset
   112
end;
1f4b67fdfdae simprocs now in IntArith;
wenzelm
parents: 7518
diff changeset
   113
1f4b67fdfdae simprocs now in IntArith;
wenzelm
parents: 7518
diff changeset
   114
structure Int_Cancel = Abel_Cancel (Int_Cancel_Data);
1f4b67fdfdae simprocs now in IntArith;
wenzelm
parents: 7518
diff changeset
   115
1f4b67fdfdae simprocs now in IntArith;
wenzelm
parents: 7518
diff changeset
   116
Addsimprocs [Int_Cancel.sum_conv, Int_Cancel.rel_conv];
1f4b67fdfdae simprocs now in IntArith;
wenzelm
parents: 7518
diff changeset
   117
1f4b67fdfdae simprocs now in IntArith;
wenzelm
parents: 7518
diff changeset
   118
1f4b67fdfdae simprocs now in IntArith;
wenzelm
parents: 7518
diff changeset
   119
1f4b67fdfdae simprocs now in IntArith;
wenzelm
parents: 7518
diff changeset
   120
(*** misc ***)
1f4b67fdfdae simprocs now in IntArith;
wenzelm
parents: 7518
diff changeset
   121
8785
00cff9d083df Installation of CombineNumerals for the integers
paulson
parents: 8442
diff changeset
   122
Goal "- (z - y) = y - (z::int)";
00cff9d083df Installation of CombineNumerals for the integers
paulson
parents: 8442
diff changeset
   123
by (Simp_tac 1);
00cff9d083df Installation of CombineNumerals for the integers
paulson
parents: 8442
diff changeset
   124
qed "zminus_zdiff_eq";
00cff9d083df Installation of CombineNumerals for the integers
paulson
parents: 8442
diff changeset
   125
Addsimps [zminus_zdiff_eq];
00cff9d083df Installation of CombineNumerals for the integers
paulson
parents: 8442
diff changeset
   126
5562
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   127
Goal "(w<z) = neg(w-z)";
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   128
by (simp_tac (simpset() addsimps [zless_def]) 1);
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   129
qed "zless_eq_neg";
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   130
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   131
Goal "(w=z) = iszero(w-z)";
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   132
by (simp_tac (simpset() addsimps [iszero_def, zdiff_eq_eq]) 1);
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   133
qed "eq_eq_iszero";
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   134
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   135
Goal "(w<=z) = (~ neg(z-w))";
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   136
by (simp_tac (simpset() addsimps [zle_def, zless_def]) 1);
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   137
qed "zle_eq_not_neg";
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   138
11868
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   139
(** Inequality reasoning **)
5562
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   140
11868
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   141
Goal "(w < z + (1::int)) = (w<z | w=z)";
5593
33bca87deae5 new lemmas
paulson
parents: 5582
diff changeset
   142
by (auto_tac (claset(),
11868
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   143
	      simpset() addsimps [zless_iff_Suc_zadd, int_Suc,
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   144
                                  gr0_conv_Suc, zero_reorient]));
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   145
by (res_inst_tac [("x","Suc n")] exI 1); 
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   146
by (simp_tac (simpset() addsimps [int_Suc]) 1); 
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   147
qed "zless_add1_eq";
5593
33bca87deae5 new lemmas
paulson
parents: 5582
diff changeset
   148
11868
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   149
Goal "(w + (1::int) <= z) = (w<z)";
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   150
by (asm_full_simp_tac (simpset() addsimps [zle_def, zless_add1_eq]) 1); 
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   151
by (auto_tac (claset() addIs [zle_anti_sym],
10646
37b9897dbf3a greater use of overloaded rules (order_less_imp_le not zless_imp_zle, ...)
paulson
parents: 10472
diff changeset
   152
	      simpset() addsimps [order_less_imp_le, symmetric zle_def]));
11868
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   153
qed "add1_zle_eq";
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   154
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   155
Goal "((1::int) + w <= z) = (w<z)";
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   156
by (stac zadd_commute 1);
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   157
by (rtac add1_zle_eq 1);
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   158
qed "add1_left_zle_eq";
5593
33bca87deae5 new lemmas
paulson
parents: 5582
diff changeset
   159
33bca87deae5 new lemmas
paulson
parents: 5582
diff changeset
   160
5562
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   161
(*** Monotonicity results ***)
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   162
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   163
Goal "(v+z < w+z) = (v < (w::int))";
5582
a356fb49e69e many renamings and changes. Simproc for cancelling common terms in relations
paulson
parents: 5562
diff changeset
   164
by (Simp_tac 1);
5562
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   165
qed "zadd_right_cancel_zless";
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   166
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   167
Goal "(z+v < z+w) = (v < (w::int))";
5582
a356fb49e69e many renamings and changes. Simproc for cancelling common terms in relations
paulson
parents: 5562
diff changeset
   168
by (Simp_tac 1);
5562
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   169
qed "zadd_left_cancel_zless";
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   170
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   171
Addsimps [zadd_right_cancel_zless, zadd_left_cancel_zless];
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   172
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   173
Goal "(v+z <= w+z) = (v <= (w::int))";
5582
a356fb49e69e many renamings and changes. Simproc for cancelling common terms in relations
paulson
parents: 5562
diff changeset
   174
by (Simp_tac 1);
5562
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   175
qed "zadd_right_cancel_zle";
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   176
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   177
Goal "(z+v <= z+w) = (v <= (w::int))";
5582
a356fb49e69e many renamings and changes. Simproc for cancelling common terms in relations
paulson
parents: 5562
diff changeset
   178
by (Simp_tac 1);
5562
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   179
qed "zadd_left_cancel_zle";
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   180
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   181
Addsimps [zadd_right_cancel_zle, zadd_left_cancel_zle];
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   182
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   183
(*"v<=w ==> v+z <= w+z"*)
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   184
bind_thm ("zadd_zless_mono1", zadd_right_cancel_zless RS iffD2);
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   185
6998
8a1a39b8fad8 new montonicity theorems
paulson
parents: 6990
diff changeset
   186
(*"v<=w ==> z+v <= z+w"*)
8a1a39b8fad8 new montonicity theorems
paulson
parents: 6990
diff changeset
   187
bind_thm ("zadd_zless_mono2", zadd_left_cancel_zless RS iffD2);
8a1a39b8fad8 new montonicity theorems
paulson
parents: 6990
diff changeset
   188
5562
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   189
(*"v<=w ==> v+z <= w+z"*)
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   190
bind_thm ("zadd_zle_mono1", zadd_right_cancel_zle RS iffD2);
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   191
6998
8a1a39b8fad8 new montonicity theorems
paulson
parents: 6990
diff changeset
   192
(*"v<=w ==> z+v <= z+w"*)
8a1a39b8fad8 new montonicity theorems
paulson
parents: 6990
diff changeset
   193
bind_thm ("zadd_zle_mono2", zadd_left_cancel_zle RS iffD2);
8a1a39b8fad8 new montonicity theorems
paulson
parents: 6990
diff changeset
   194
7081
paulson
parents: 7034
diff changeset
   195
Goal "[| w'<=w; z'<=z |] ==> w' + z' <= w + (z::int)";
5562
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   196
by (etac (zadd_zle_mono1 RS zle_trans) 1);
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   197
by (Simp_tac 1);
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   198
qed "zadd_zle_mono";
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   199
7081
paulson
parents: 7034
diff changeset
   200
Goal "[| w'<w; z'<=z |] ==> w' + z' < w + (z::int)";
10646
37b9897dbf3a greater use of overloaded rules (order_less_imp_le not zless_imp_zle, ...)
paulson
parents: 10472
diff changeset
   201
by (etac (zadd_zless_mono1 RS order_less_le_trans) 1);
5562
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   202
by (Simp_tac 1);
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   203
qed "zadd_zless_mono";
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   204
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   205
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   206
(*** Comparison laws ***)
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   207
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   208
Goal "(- x < - y) = (y < (x::int))";
5582
a356fb49e69e many renamings and changes. Simproc for cancelling common terms in relations
paulson
parents: 5562
diff changeset
   209
by (simp_tac (simpset() addsimps [zless_def, zdiff_def] @ zadd_ac) 1);
5562
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   210
qed "zminus_zless_zminus"; 
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   211
Addsimps [zminus_zless_zminus];
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   212
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   213
Goal "(- x <= - y) = (y <= (x::int))";
5582
a356fb49e69e many renamings and changes. Simproc for cancelling common terms in relations
paulson
parents: 5562
diff changeset
   214
by (simp_tac (simpset() addsimps [zle_def]) 1);
5562
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   215
qed "zminus_zle_zminus"; 
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   216
Addsimps [zminus_zle_zminus];
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   217
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   218
(** The next several equations can make the simplifier loop! **)
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   219
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   220
Goal "(x < - y) = (y < - (x::int))";
5582
a356fb49e69e many renamings and changes. Simproc for cancelling common terms in relations
paulson
parents: 5562
diff changeset
   221
by (simp_tac (simpset() addsimps [zless_def, zdiff_def] @ zadd_ac) 1);
5562
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   222
qed "zless_zminus"; 
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   223
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   224
Goal "(- x < y) = (- y < (x::int))";
5582
a356fb49e69e many renamings and changes. Simproc for cancelling common terms in relations
paulson
parents: 5562
diff changeset
   225
by (simp_tac (simpset() addsimps [zless_def, zdiff_def] @ zadd_ac) 1);
5562
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   226
qed "zminus_zless"; 
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   227
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   228
Goal "(x <= - y) = (y <= - (x::int))";
5582
a356fb49e69e many renamings and changes. Simproc for cancelling common terms in relations
paulson
parents: 5562
diff changeset
   229
by (simp_tac (simpset() addsimps [zle_def, zminus_zless]) 1);
5562
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   230
qed "zle_zminus"; 
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   231
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   232
Goal "(- x <= y) = (- y <= (x::int))";
5582
a356fb49e69e many renamings and changes. Simproc for cancelling common terms in relations
paulson
parents: 5562
diff changeset
   233
by (simp_tac (simpset() addsimps [zle_def, zless_zminus]) 1);
5562
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   234
qed "zminus_zle"; 
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   235
6917
eba301caceea Introduction of integer division algorithm
paulson
parents: 6866
diff changeset
   236
Goal "(x = - y) = (y = - (x::int))";
eba301caceea Introduction of integer division algorithm
paulson
parents: 6866
diff changeset
   237
by Auto_tac;
eba301caceea Introduction of integer division algorithm
paulson
parents: 6866
diff changeset
   238
qed "equation_zminus";
eba301caceea Introduction of integer division algorithm
paulson
parents: 6866
diff changeset
   239
eba301caceea Introduction of integer division algorithm
paulson
parents: 6866
diff changeset
   240
Goal "(- x = y) = (- (y::int) = x)";
eba301caceea Introduction of integer division algorithm
paulson
parents: 6866
diff changeset
   241
by Auto_tac;
eba301caceea Introduction of integer division algorithm
paulson
parents: 6866
diff changeset
   242
qed "zminus_equation";
eba301caceea Introduction of integer division algorithm
paulson
parents: 6866
diff changeset
   243
11868
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   244
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   245
(** Instances of the equations above, for zero **)
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   246
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   247
(*instantiate a variable to zero and simplify*)
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   248
fun zero_instance v th = simplify (simpset()) (inst v "0" th);
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   249
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   250
Addsimps [zero_instance "x" zless_zminus,
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   251
          zero_instance "y" zminus_zless,
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   252
          zero_instance "x" zle_zminus,
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   253
          zero_instance "y" zminus_zle,
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   254
          zero_instance "x" equation_zminus,
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   255
          zero_instance "y" zminus_equation];
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   256
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   257
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   258
Goal "- (int (Suc n)) < 0";
5582
a356fb49e69e many renamings and changes. Simproc for cancelling common terms in relations
paulson
parents: 5562
diff changeset
   259
by (simp_tac (simpset() addsimps [zless_def]) 1);
5562
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   260
qed "negative_zless_0"; 
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   261
5582
a356fb49e69e many renamings and changes. Simproc for cancelling common terms in relations
paulson
parents: 5562
diff changeset
   262
Goal "- (int (Suc n)) < int m";
10646
37b9897dbf3a greater use of overloaded rules (order_less_imp_le not zless_imp_zle, ...)
paulson
parents: 10472
diff changeset
   263
by (rtac (negative_zless_0 RS order_less_le_trans) 1);
5562
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   264
by (Simp_tac 1); 
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   265
qed "negative_zless"; 
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   266
AddIffs [negative_zless]; 
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   267
11868
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   268
Goal "- int n <= 0";
5582
a356fb49e69e many renamings and changes. Simproc for cancelling common terms in relations
paulson
parents: 5562
diff changeset
   269
by (simp_tac (simpset() addsimps [zminus_zle]) 1);
5562
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   270
qed "negative_zle_0"; 
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   271
5582
a356fb49e69e many renamings and changes. Simproc for cancelling common terms in relations
paulson
parents: 5562
diff changeset
   272
Goal "- int n <= int m";
a356fb49e69e many renamings and changes. Simproc for cancelling common terms in relations
paulson
parents: 5562
diff changeset
   273
by (simp_tac (simpset() addsimps [zless_def, zle_def, zdiff_def, zadd_int]) 1);
5562
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   274
qed "negative_zle"; 
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   275
AddIffs [negative_zle]; 
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   276
11868
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   277
Goal "~(0 <= - (int (Suc n)))";
5562
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   278
by (stac zle_zminus 1);
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   279
by (Simp_tac 1);
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   280
qed "not_zle_0_negative"; 
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   281
Addsimps [not_zle_0_negative]; 
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   282
5582
a356fb49e69e many renamings and changes. Simproc for cancelling common terms in relations
paulson
parents: 5562
diff changeset
   283
Goal "(int n <= - int m) = (n = 0 & m = 0)"; 
5562
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   284
by Safe_tac; 
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   285
by (Simp_tac 3); 
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   286
by (dtac (zle_zminus RS iffD1) 2); 
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   287
by (ALLGOALS (dtac (negative_zle_0 RSN(2,zle_trans)))); 
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   288
by (ALLGOALS Asm_full_simp_tac); 
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   289
qed "int_zle_neg"; 
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   290
5582
a356fb49e69e many renamings and changes. Simproc for cancelling common terms in relations
paulson
parents: 5562
diff changeset
   291
Goal "~(int n < - int m)";
5562
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   292
by (simp_tac (simpset() addsimps [symmetric zle_def]) 1); 
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   293
qed "not_int_zless_negative"; 
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   294
5582
a356fb49e69e many renamings and changes. Simproc for cancelling common terms in relations
paulson
parents: 5562
diff changeset
   295
Goal "(- int n = int m) = (n = 0 & m = 0)"; 
5562
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   296
by (rtac iffI 1);
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   297
by (rtac (int_zle_neg RS iffD1) 1); 
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   298
by (dtac sym 1); 
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   299
by (ALLGOALS Asm_simp_tac); 
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   300
qed "negative_eq_positive"; 
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   301
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   302
Addsimps [negative_eq_positive, not_int_zless_negative]; 
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   303
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   304
5582
a356fb49e69e many renamings and changes. Simproc for cancelling common terms in relations
paulson
parents: 5562
diff changeset
   305
Goal "(w <= z) = (EX n. z = w + int n)";
11868
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   306
by (auto_tac (claset() addIs [inst "x" "0::nat" exI]
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   307
		       addSIs [not_sym RS not0_implies_Suc],
10472
6569febd98e5 renamed integ_le_less to int_le_less;
wenzelm
parents: 9945
diff changeset
   308
	      simpset() addsimps [zless_iff_Suc_zadd, int_le_less]));
5562
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   309
qed "zle_iff_zadd";
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   310
9945
a0efbd7c88dc more integer theorems, better simplification
paulson
parents: 9633
diff changeset
   311
Goal "abs (int m) = int m";
a0efbd7c88dc more integer theorems, better simplification
paulson
parents: 9633
diff changeset
   312
by (simp_tac (simpset() addsimps [zabs_def]) 1); 
a0efbd7c88dc more integer theorems, better simplification
paulson
parents: 9633
diff changeset
   313
qed "abs_int_eq";
a0efbd7c88dc more integer theorems, better simplification
paulson
parents: 9633
diff changeset
   314
Addsimps [abs_int_eq];
a0efbd7c88dc more integer theorems, better simplification
paulson
parents: 9633
diff changeset
   315
5562
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   316
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   317
(**** nat: magnitide of an integer, as a natural number ****)
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   318
5582
a356fb49e69e many renamings and changes. Simproc for cancelling common terms in relations
paulson
parents: 5562
diff changeset
   319
Goalw [nat_def] "nat(int n) = n";
5562
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   320
by Auto_tac;
7009
d6a721e7125d more renaming of theorems from _nat to _int (corresponding to a function that
paulson
parents: 6998
diff changeset
   321
qed "nat_int";
11868
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   322
Addsimps [nat_int];
5562
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   323
11868
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   324
Goalw [nat_def] "nat(- (int n)) = 0";
5562
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   325
by (auto_tac (claset(),
11868
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   326
     simpset() addsimps [neg_eq_less_0, zero_reorient, zminus_zless])); 
7009
d6a721e7125d more renaming of theorems from _nat to _int (corresponding to a function that
paulson
parents: 6998
diff changeset
   327
qed "nat_zminus_int";
11868
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   328
Addsimps [nat_zminus_int];
5562
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   329
11868
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   330
Goalw [Zero_int_def] "nat 0 = 0";
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   331
by (rtac nat_int 1);
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   332
qed "nat_zero";
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   333
Addsimps [nat_zero];
5562
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   334
5582
a356fb49e69e many renamings and changes. Simproc for cancelling common terms in relations
paulson
parents: 5562
diff changeset
   335
Goal "~ neg z ==> int (nat z) = z"; 
11868
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   336
by (dtac (not_neg_eq_ge_0 RS iffD1) 1); 
5562
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   337
by (dtac zle_imp_zless_or_eq 1); 
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   338
by (auto_tac (claset(), simpset() addsimps [zless_iff_Suc_zadd])); 
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   339
qed "not_neg_nat"; 
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   340
7081
paulson
parents: 7034
diff changeset
   341
Goal "neg x ==> EX n. x = - (int (Suc n))"; 
5562
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   342
by (auto_tac (claset(), 
11868
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   343
	      simpset() addsimps [neg_eq_less_0, zless_iff_Suc_zadd,
5562
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   344
				  zdiff_eq_eq RS sym, zdiff_def])); 
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   345
qed "negD"; 
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   346
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   347
Goalw [nat_def] "neg z ==> nat z = 0"; 
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   348
by Auto_tac; 
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   349
qed "neg_nat"; 
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   350
7518
67bde103ec0c generalized the theorem zless_zero_nat to zless_nat_eq_int_zless, and
paulson
parents: 7081
diff changeset
   351
Goal "(m < nat z) = (int m < z)";
67bde103ec0c generalized the theorem zless_zero_nat to zless_nat_eq_int_zless, and
paulson
parents: 7081
diff changeset
   352
by (case_tac "neg z" 1);
67bde103ec0c generalized the theorem zless_zero_nat to zless_nat_eq_int_zless, and
paulson
parents: 7081
diff changeset
   353
by (etac (not_neg_nat RS subst) 2);
67bde103ec0c generalized the theorem zless_zero_nat to zless_nat_eq_int_zless, and
paulson
parents: 7081
diff changeset
   354
by (auto_tac (claset(), simpset() addsimps [neg_nat])); 
67bde103ec0c generalized the theorem zless_zero_nat to zless_nat_eq_int_zless, and
paulson
parents: 7081
diff changeset
   355
by (auto_tac (claset() addDs [order_less_trans], 
11868
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   356
	      simpset() addsimps [neg_eq_less_0])); 
7518
67bde103ec0c generalized the theorem zless_zero_nat to zless_nat_eq_int_zless, and
paulson
parents: 7081
diff changeset
   357
qed "zless_nat_eq_int_zless";
67bde103ec0c generalized the theorem zless_zero_nat to zless_nat_eq_int_zless, and
paulson
parents: 7081
diff changeset
   358
12613
279facb4253a Literal arithmetic: raising numbers to powers (nat, int, real, hypreal)
paulson
parents: 11868
diff changeset
   359
Goal "0 <= z ==> int (nat z) = z"; 
279facb4253a Literal arithmetic: raising numbers to powers (nat, int, real, hypreal)
paulson
parents: 11868
diff changeset
   360
by (asm_full_simp_tac
279facb4253a Literal arithmetic: raising numbers to powers (nat, int, real, hypreal)
paulson
parents: 11868
diff changeset
   361
    (simpset() addsimps [neg_eq_less_0, zle_def, not_neg_nat]) 1); 
279facb4253a Literal arithmetic: raising numbers to powers (nat, int, real, hypreal)
paulson
parents: 11868
diff changeset
   362
qed "nat_0_le"; 
279facb4253a Literal arithmetic: raising numbers to powers (nat, int, real, hypreal)
paulson
parents: 11868
diff changeset
   363
11868
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   364
Goal "z <= 0 ==> nat z = 0"; 
7518
67bde103ec0c generalized the theorem zless_zero_nat to zless_nat_eq_int_zless, and
paulson
parents: 7081
diff changeset
   365
by (auto_tac (claset(), 
11868
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   366
	      simpset() addsimps [order_le_less, neg_eq_less_0, 
7518
67bde103ec0c generalized the theorem zless_zero_nat to zless_nat_eq_int_zless, and
paulson
parents: 7081
diff changeset
   367
				  zle_def, neg_nat])); 
12613
279facb4253a Literal arithmetic: raising numbers to powers (nat, int, real, hypreal)
paulson
parents: 11868
diff changeset
   368
qed "nat_le_0"; 
279facb4253a Literal arithmetic: raising numbers to powers (nat, int, real, hypreal)
paulson
parents: 11868
diff changeset
   369
Addsimps [nat_0_le, nat_le_0];
7518
67bde103ec0c generalized the theorem zless_zero_nat to zless_nat_eq_int_zless, and
paulson
parents: 7081
diff changeset
   370
11868
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   371
(*An alternative condition is  0 <= w  *)
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   372
Goal "0 < z ==> (nat w < nat z) = (w < z)";
6866
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   373
by (stac (zless_int RS sym) 1);
11868
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   374
by (asm_simp_tac (simpset() addsimps [not_neg_nat, not_neg_eq_ge_0, 
6866
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   375
				      order_le_less]) 1);
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   376
by (case_tac "neg w" 1);
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   377
by (asm_simp_tac (simpset() addsimps [not_neg_nat]) 2);
11868
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   378
by (asm_full_simp_tac (simpset() addsimps [neg_eq_less_0, neg_nat]) 1);
6866
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   379
by (blast_tac (claset() addIs [order_less_trans]) 1);
6917
eba301caceea Introduction of integer division algorithm
paulson
parents: 6866
diff changeset
   380
val lemma = result();
eba301caceea Introduction of integer division algorithm
paulson
parents: 6866
diff changeset
   381
11868
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   382
Goal "(nat w < nat z) = (0 < z & w < z)";
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   383
by (case_tac "0 < z" 1);
12613
279facb4253a Literal arithmetic: raising numbers to powers (nat, int, real, hypreal)
paulson
parents: 11868
diff changeset
   384
by (auto_tac (claset(), simpset() addsimps [lemma, linorder_not_less])); 
6917
eba301caceea Introduction of integer division algorithm
paulson
parents: 6866
diff changeset
   385
qed "zless_nat_conj";
eba301caceea Introduction of integer division algorithm
paulson
parents: 6866
diff changeset
   386
6866
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   387
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   388
(* a case theorem distinguishing non-negative and negative int *)  
5562
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   389
6942
f291292d727c more monotonicity laws for times
paulson
parents: 6917
diff changeset
   390
val prems = Goal
f291292d727c more monotonicity laws for times
paulson
parents: 6917
diff changeset
   391
     "[|!! n. z = int n ==> P;  !! n. z =  - (int (Suc n)) ==> P |] ==> P"; 
5562
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   392
by (case_tac "neg z" 1); 
6942
f291292d727c more monotonicity laws for times
paulson
parents: 6917
diff changeset
   393
by (fast_tac (claset() addSDs [negD] addSEs prems) 1); 
f291292d727c more monotonicity laws for times
paulson
parents: 6917
diff changeset
   394
by (dtac (not_neg_nat RS sym) 1);
f291292d727c more monotonicity laws for times
paulson
parents: 6917
diff changeset
   395
by (eresolve_tac prems 1);
5562
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   396
qed "int_cases"; 
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   397
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   398
fun int_case_tac x = res_inst_tac [("z",x)] int_cases; 
02261e6880d1 Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
diff changeset
   399
6866
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   400
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   401
(*** Monotonicity of Multiplication ***)
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   402
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   403
Goal "i <= (j::int) ==> i * int k <= j * int k";
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   404
by (induct_tac "k" 1);
11868
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   405
by (stac int_Suc 2);
6866
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   406
by (ALLGOALS 
11868
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   407
    (asm_simp_tac (simpset() addsimps [zadd_zmult_distrib2, zadd_zle_mono, 
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   408
                                       int_Suc0_eq_1])));
6866
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   409
val lemma = result();
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   410
11868
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   411
Goal "[| i <= j;  (0::int) <= k |] ==> i*k <= j*k";
6866
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   412
by (res_inst_tac [("t", "k")] (not_neg_nat RS subst) 1);
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   413
by (etac lemma 2);
11868
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   414
by (full_simp_tac (simpset() addsimps [not_neg_eq_ge_0]) 1);
6866
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   415
qed "zmult_zle_mono1";
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   416
11868
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   417
Goal "[| i <= j;  k <= (0::int) |] ==> j*k <= i*k";
6866
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   418
by (rtac (zminus_zle_zminus RS iffD1) 1);
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   419
by (asm_simp_tac (simpset() addsimps [zmult_zminus_right RS sym,
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   420
				      zmult_zle_mono1, zle_zminus]) 1);
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   421
qed "zmult_zle_mono1_neg";
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   422
11868
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   423
Goal "[| i <= j;  (0::int) <= k |] ==> k*i <= k*j";
6942
f291292d727c more monotonicity laws for times
paulson
parents: 6917
diff changeset
   424
by (dtac zmult_zle_mono1 1);
f291292d727c more monotonicity laws for times
paulson
parents: 6917
diff changeset
   425
by (ALLGOALS (asm_full_simp_tac (simpset() addsimps [zmult_commute])));
f291292d727c more monotonicity laws for times
paulson
parents: 6917
diff changeset
   426
qed "zmult_zle_mono2";
f291292d727c more monotonicity laws for times
paulson
parents: 6917
diff changeset
   427
11868
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   428
Goal "[| i <= j;  k <= (0::int) |] ==> k*j <= k*i";
6942
f291292d727c more monotonicity laws for times
paulson
parents: 6917
diff changeset
   429
by (dtac zmult_zle_mono1_neg 1);
f291292d727c more monotonicity laws for times
paulson
parents: 6917
diff changeset
   430
by (ALLGOALS (asm_full_simp_tac (simpset() addsimps [zmult_commute])));
f291292d727c more monotonicity laws for times
paulson
parents: 6917
diff changeset
   431
qed "zmult_zle_mono2_neg";
f291292d727c more monotonicity laws for times
paulson
parents: 6917
diff changeset
   432
6990
cac1e4e9c821 new monotonicity theorems
paulson
parents: 6942
diff changeset
   433
(* <= monotonicity, BOTH arguments*)
11868
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   434
Goal "[| i <= j;  k <= l;  (0::int) <= j;  (0::int) <= k |] ==> i*k <= j*l";
6866
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   435
by (etac (zmult_zle_mono1 RS order_trans) 1);
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   436
by (assume_tac 1);
6990
cac1e4e9c821 new monotonicity theorems
paulson
parents: 6942
diff changeset
   437
by (etac zmult_zle_mono2 1);
cac1e4e9c821 new monotonicity theorems
paulson
parents: 6942
diff changeset
   438
by (assume_tac 1);
6866
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   439
qed "zmult_zle_mono";
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   440
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   441
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   442
(** strict, in 1st argument; proof is by induction on k>0 **)
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   443
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   444
Goal "i<j ==> 0<k --> int k * i < int k * j";
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   445
by (induct_tac "k" 1);
11868
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   446
by (stac int_Suc 2);
6866
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   447
by (case_tac "n=0" 2);
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   448
by (ALLGOALS (asm_full_simp_tac
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   449
	      (simpset() addsimps [zadd_zmult_distrib, zadd_zless_mono, 
11868
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   450
				   int_Suc0_eq_1, order_le_less])));
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   451
val lemma = result();
6866
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   452
11868
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   453
Goal "[| i<j;  (0::int) < k |] ==> k*i < k*j";
6866
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   454
by (res_inst_tac [("t", "k")] (not_neg_nat RS subst) 1);
11868
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   455
by (etac (lemma RS mp) 2);
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   456
by (asm_simp_tac (simpset() addsimps [not_neg_eq_ge_0, 
6866
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   457
				      order_le_less]) 1);
6917
eba301caceea Introduction of integer division algorithm
paulson
parents: 6866
diff changeset
   458
by (forward_tac [conjI RS (zless_nat_conj RS iffD2)] 1);
6866
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   459
by Auto_tac;
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   460
qed "zmult_zless_mono2";
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   461
11868
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   462
Goal "[| i<j;  (0::int) < k |] ==> i*k < j*k";
6866
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   463
by (dtac zmult_zless_mono2 1);
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   464
by (ALLGOALS (asm_full_simp_tac (simpset() addsimps [zmult_commute])));
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   465
qed "zmult_zless_mono1";
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   466
6990
cac1e4e9c821 new monotonicity theorems
paulson
parents: 6942
diff changeset
   467
(* < monotonicity, BOTH arguments*)
11868
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   468
Goal "[| i < j;  k < l;  (0::int) < j;  (0::int) < k |] ==> i*k < j*l";
6990
cac1e4e9c821 new monotonicity theorems
paulson
parents: 6942
diff changeset
   469
by (etac (zmult_zless_mono1 RS order_less_trans) 1);
cac1e4e9c821 new monotonicity theorems
paulson
parents: 6942
diff changeset
   470
by (assume_tac 1);
cac1e4e9c821 new monotonicity theorems
paulson
parents: 6942
diff changeset
   471
by (etac zmult_zless_mono2 1);
cac1e4e9c821 new monotonicity theorems
paulson
parents: 6942
diff changeset
   472
by (assume_tac 1);
cac1e4e9c821 new monotonicity theorems
paulson
parents: 6942
diff changeset
   473
qed "zmult_zless_mono";
cac1e4e9c821 new monotonicity theorems
paulson
parents: 6942
diff changeset
   474
11868
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   475
Goal "[| i<j;  k < (0::int) |] ==> j*k < i*k";
6866
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   476
by (rtac (zminus_zless_zminus RS iffD1) 1);
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   477
by (asm_simp_tac (simpset() addsimps [zmult_zminus_right RS sym,
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   478
				      zmult_zless_mono1, zless_zminus]) 1);
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   479
qed "zmult_zless_mono1_neg";
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   480
11868
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   481
Goal "[| i<j;  k < (0::int) |] ==> k*j < k*i";
6866
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   482
by (rtac (zminus_zless_zminus RS iffD1) 1);
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   483
by (asm_simp_tac (simpset() addsimps [zmult_zminus RS sym,
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   484
				      zmult_zless_mono2, zless_zminus]) 1);
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   485
qed "zmult_zless_mono2_neg";
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   486
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   487
11868
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   488
Goal "(m*n = (0::int)) = (m = 0 | n = 0)";
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   489
by (case_tac "m < (0::int)" 1);
6866
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   490
by (auto_tac (claset(), 
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   491
	      simpset() addsimps [linorder_not_less, order_le_less, 
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   492
				  linorder_neq_iff])); 
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   493
by (REPEAT 
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   494
    (force_tac (claset() addDs [zmult_zless_mono1_neg, zmult_zless_mono1], 
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   495
		simpset()) 1));
11868
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   496
qed "zmult_eq_0_iff";
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   497
AddIffs [zmult_eq_0_iff];
6866
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   498
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   499
9633
a71a83253997 better rules for cancellation of common factors across comparisons
paulson
parents: 9582
diff changeset
   500
(** Cancellation laws for k*m < k*n and m*k < n*k, also for <= and =,
a71a83253997 better rules for cancellation of common factors across comparisons
paulson
parents: 9582
diff changeset
   501
    but not (yet?) for k*m < n*k. **)
a71a83253997 better rules for cancellation of common factors across comparisons
paulson
parents: 9582
diff changeset
   502
11868
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   503
Goal "(m*k < n*k) = (((0::int) < k & m<n) | (k < 0 & n<m))";
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   504
by (case_tac "k = (0::int)" 1);
9633
a71a83253997 better rules for cancellation of common factors across comparisons
paulson
parents: 9582
diff changeset
   505
by (auto_tac (claset(), simpset() addsimps [linorder_neq_iff, 
a71a83253997 better rules for cancellation of common factors across comparisons
paulson
parents: 9582
diff changeset
   506
                              zmult_zless_mono1, zmult_zless_mono1_neg]));  
a71a83253997 better rules for cancellation of common factors across comparisons
paulson
parents: 9582
diff changeset
   507
by (auto_tac (claset(), 
a71a83253997 better rules for cancellation of common factors across comparisons
paulson
parents: 9582
diff changeset
   508
              simpset() addsimps [linorder_not_less,
a71a83253997 better rules for cancellation of common factors across comparisons
paulson
parents: 9582
diff changeset
   509
				  inst "y1" "m*k" (linorder_not_le RS sym),
a71a83253997 better rules for cancellation of common factors across comparisons
paulson
parents: 9582
diff changeset
   510
                                  inst "y1" "m" (linorder_not_le RS sym)]));
a71a83253997 better rules for cancellation of common factors across comparisons
paulson
parents: 9582
diff changeset
   511
by (ALLGOALS (etac notE));
10646
37b9897dbf3a greater use of overloaded rules (order_less_imp_le not zless_imp_zle, ...)
paulson
parents: 10472
diff changeset
   512
by (auto_tac (claset(), simpset() addsimps [order_less_imp_le, zmult_zle_mono1,
9633
a71a83253997 better rules for cancellation of common factors across comparisons
paulson
parents: 9582
diff changeset
   513
                                            zmult_zle_mono1_neg]));  
6866
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   514
qed "zmult_zless_cancel2";
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   515
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   516
11868
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   517
Goal "(k*m < k*n) = (((0::int) < k & m<n) | (k < 0 & n<m))";
9633
a71a83253997 better rules for cancellation of common factors across comparisons
paulson
parents: 9582
diff changeset
   518
by (simp_tac (simpset() addsimps [inst "z" "k" zmult_commute, 
a71a83253997 better rules for cancellation of common factors across comparisons
paulson
parents: 9582
diff changeset
   519
                                  zmult_zless_cancel2]) 1);
a71a83253997 better rules for cancellation of common factors across comparisons
paulson
parents: 9582
diff changeset
   520
qed "zmult_zless_cancel1";
6866
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   521
11868
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   522
Goal "(m*k <= n*k) = (((0::int) < k --> m<=n) & (k < 0 --> n<=m))";
9633
a71a83253997 better rules for cancellation of common factors across comparisons
paulson
parents: 9582
diff changeset
   523
by (simp_tac (simpset() addsimps [linorder_not_less RS sym, 
a71a83253997 better rules for cancellation of common factors across comparisons
paulson
parents: 9582
diff changeset
   524
                                  zmult_zless_cancel2]) 1);
6866
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   525
qed "zmult_zle_cancel2";
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   526
11868
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   527
Goal "(k*m <= k*n) = (((0::int) < k --> m<=n) & (k < 0 --> n<=m))";
9633
a71a83253997 better rules for cancellation of common factors across comparisons
paulson
parents: 9582
diff changeset
   528
by (simp_tac (simpset() addsimps [linorder_not_less RS sym, 
a71a83253997 better rules for cancellation of common factors across comparisons
paulson
parents: 9582
diff changeset
   529
                                  zmult_zless_cancel1]) 1);
6866
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   530
qed "zmult_zle_cancel1";
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   531
11868
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   532
Goal "(m*k = n*k) = (k = (0::int) | m=n)";
6866
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   533
by (cut_facts_tac [linorder_less_linear] 1);
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   534
by Safe_tac;
9633
a71a83253997 better rules for cancellation of common factors across comparisons
paulson
parents: 9582
diff changeset
   535
by Auto_tac;  
6866
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   536
by (REPEAT 
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   537
    (force_tac (claset() addD2 ("mono_neg", zmult_zless_mono1_neg)
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   538
                         addD2 ("mono_pos", zmult_zless_mono1), 
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   539
		simpset() addsimps [linorder_neq_iff]) 1));
9633
a71a83253997 better rules for cancellation of common factors across comparisons
paulson
parents: 9582
diff changeset
   540
6866
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   541
qed "zmult_cancel2";
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   542
11868
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   543
Goal "(k*m = k*n) = (k = (0::int) | m=n)";
9633
a71a83253997 better rules for cancellation of common factors across comparisons
paulson
parents: 9582
diff changeset
   544
by (simp_tac (simpset() addsimps [inst "z" "k" zmult_commute, 
a71a83253997 better rules for cancellation of common factors across comparisons
paulson
parents: 9582
diff changeset
   545
                                  zmult_cancel2]) 1);
6866
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   546
qed "zmult_cancel1";
f795b63139ec many new theorems concerning multiplication and (in)equations
paulson
parents: 6717
diff changeset
   547
Addsimps [zmult_cancel1, zmult_cancel2];
11868
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   548
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   549
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   550
(*Analogous to zadd_int*)
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   551
Goal "n<=m --> int m - int n = int (m-n)";
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   552
by (induct_thm_tac diff_induct "m n" 1);
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   553
by (auto_tac (claset(), simpset() addsimps [int_Suc, symmetric zdiff_def])); 
56db9f3a6b3e Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
paulson
parents: 11701
diff changeset
   554
qed_spec_mp "zdiff_int";