1.1 --- a/src/HOL/Integ/Bin.ML Mon Oct 22 11:01:30 2001 +0200
1.2 +++ b/src/HOL/Integ/Bin.ML Mon Oct 22 11:54:22 2001 +0200
1.3 @@ -98,7 +98,7 @@
1.4 (**** The carry/borrow functions, bin_succ and bin_pred ****)
1.5
1.6
1.7 -(**** number_of ****)
1.8 +(** number_of **)
1.9
1.10 Goal "number_of(NCons w b) = (number_of(w BIT b)::int)";
1.11 by (induct_tac "w" 1);
1.12 @@ -107,12 +107,12 @@
1.13
1.14 Addsimps [number_of_NCons];
1.15
1.16 -Goal "number_of(bin_succ w) = int 1 + number_of w";
1.17 +Goal "number_of(bin_succ w) = (1 + number_of w :: int)";
1.18 by (induct_tac "w" 1);
1.19 by (ALLGOALS (asm_simp_tac (simpset() addsimps zadd_ac)));
1.20 qed "number_of_succ";
1.21
1.22 -Goal "number_of(bin_pred w) = - (int 1) + number_of w";
1.23 +Goal "number_of(bin_pred w) = (- 1 + number_of w :: int)";
1.24 by (induct_tac "w" 1);
1.25 by (ALLGOALS (asm_simp_tac (simpset() addsimps zadd_ac)));
1.26 qed "number_of_pred";
1.27 @@ -127,17 +127,15 @@
1.28 zadd_assoc]) 1);
1.29 qed "number_of_minus";
1.30
1.31 -
1.32 -bind_thms ("bin_add_simps", [bin_add_BIT_BIT, number_of_succ, number_of_pred]);
1.33 -
1.34 (*This proof is complicated by the mutual recursion*)
1.35 Goal "! w. number_of(bin_add v w) = (number_of v + number_of w::int)";
1.36 -by (induct_tac "v" 1);
1.37 -by (simp_tac (simpset() addsimps bin_add_simps) 1);
1.38 -by (simp_tac (simpset() addsimps bin_add_simps) 1);
1.39 +by (induct_tac "v" 1);
1.40 +by (Simp_tac 1);
1.41 +by (simp_tac (simpset() addsimps [number_of_pred]) 1);
1.42 by (rtac allI 1);
1.43 by (induct_tac "w" 1);
1.44 -by (ALLGOALS (asm_simp_tac (simpset() addsimps bin_add_simps @ zadd_ac)));
1.45 +by (ALLGOALS (asm_simp_tac (simpset() addsimps
1.46 + [bin_add_BIT_BIT, number_of_succ, number_of_pred] @ zadd_ac)));
1.47 qed_spec_mp "number_of_add";
1.48
1.49
1.50 @@ -147,7 +145,8 @@
1.51 by (simp_tac (simpset() addsimps [number_of_add, number_of_minus]) 1);
1.52 qed "diff_number_of_eq";
1.53
1.54 -bind_thms ("bin_mult_simps", [zmult_zminus, number_of_minus, number_of_add]);
1.55 +bind_thms ("bin_mult_simps",
1.56 + [int_Suc0_eq_1, zmult_zminus, number_of_minus, number_of_add]);
1.57
1.58 Goal "number_of(bin_mult v w) = (number_of v * number_of w::int)";
1.59 by (induct_tac "v" 1);
1.60 @@ -167,54 +166,15 @@
1.61 qed "double_number_of_BIT";
1.62
1.63
1.64 -(** Simplification rules with integer constants **)
1.65 +(** Converting numerals 0 and 1 to their abstract versions **)
1.66
1.67 -Goal "Numeral0 + z = (z::int)";
1.68 +Goal "Numeral0 = (0::int)";
1.69 by (Simp_tac 1);
1.70 -qed "zadd_0";
1.71 +qed "int_numeral_0_eq_0";
1.72
1.73 -Goal "z + Numeral0 = (z::int)";
1.74 -by (Simp_tac 1);
1.75 -qed "zadd_0_right";
1.76 -
1.77 -Addsimps [zadd_0, zadd_0_right];
1.78 -
1.79 -
1.80 -(** Converting simple cases of (int n) to numerals **)
1.81 -
1.82 -Goal "int 0 = Numeral0";
1.83 -by (rtac sym 1);
1.84 -by (rtac number_of_Pls 1);
1.85 -qed "int_0";
1.86 -
1.87 -Goal "int 1 = Numeral1";
1.88 -by (Simp_tac 1);
1.89 -qed "int_1";
1.90 -
1.91 -Goal "int (Suc n) = Numeral1 + int n";
1.92 -by (simp_tac (simpset() addsimps [zadd_int]) 1);
1.93 -qed "int_Suc";
1.94 -
1.95 -Goal "- (Numeral0) = (Numeral0::int)";
1.96 -by (Simp_tac 1);
1.97 -qed "zminus_0";
1.98 -
1.99 -Addsimps [zminus_0];
1.100 -
1.101 -
1.102 -Goal "(Numeral0::int) - x = -x";
1.103 -by (simp_tac (simpset() addsimps [zdiff_def]) 1);
1.104 -qed "zdiff0";
1.105 -
1.106 -Goal "x - (Numeral0::int) = x";
1.107 -by (simp_tac (simpset() addsimps [zdiff_def]) 1);
1.108 -qed "zdiff0_right";
1.109 -
1.110 -Goal "x - x = (Numeral0::int)";
1.111 -by (simp_tac (simpset() addsimps [zdiff_def]) 1);
1.112 -qed "zdiff_self";
1.113 -
1.114 -Addsimps [zdiff0, zdiff0_right, zdiff_self];
1.115 +Goal "Numeral1 = (1::int)";
1.116 +by (simp_tac (simpset() addsimps [int_1, int_Suc0_eq_1]) 1);
1.117 +qed "int_numeral_1_eq_1";
1.118
1.119
1.120 (** Special simplification, for constants only **)
1.121 @@ -240,99 +200,30 @@
1.122
1.123 (** Special-case simplification for small constants **)
1.124
1.125 -Goal "Numeral0 * z = (Numeral0::int)";
1.126 -by (Simp_tac 1);
1.127 -qed "zmult_0";
1.128 -
1.129 -Goal "z * Numeral0 = (Numeral0::int)";
1.130 -by (Simp_tac 1);
1.131 -qed "zmult_0_right";
1.132 -
1.133 -Goal "Numeral1 * z = (z::int)";
1.134 -by (Simp_tac 1);
1.135 -qed "zmult_1";
1.136 -
1.137 -Goal "z * Numeral1 = (z::int)";
1.138 -by (Simp_tac 1);
1.139 -qed "zmult_1_right";
1.140 -
1.141 Goal "-1 * z = -(z::int)";
1.142 -by (simp_tac (simpset() addsimps zcompare_rls@[zmult_zminus]) 1);
1.143 +by (simp_tac (simpset() addsimps zcompare_rls@[int_Suc0_eq_1, zmult_zminus]) 1);
1.144 qed "zmult_minus1";
1.145
1.146 Goal "z * -1 = -(z::int)";
1.147 -by (simp_tac (simpset() addsimps zcompare_rls@[zmult_zminus_right]) 1);
1.148 +by (stac zmult_commute 1 THEN rtac zmult_minus1 1);
1.149 qed "zmult_minus1_right";
1.150
1.151 -Addsimps [zmult_0, zmult_0_right,
1.152 - zmult_1, zmult_1_right,
1.153 - zmult_minus1, zmult_minus1_right];
1.154 +Addsimps [zmult_minus1, zmult_minus1_right];
1.155
1.156 (*Negation of a coefficient*)
1.157 Goal "- (number_of w) * z = number_of(bin_minus w) * (z::int)";
1.158 by (simp_tac (simpset() addsimps [number_of_minus, zmult_zminus]) 1);
1.159 qed "zminus_number_of_zmult";
1.160 -
1.161 Addsimps [zminus_number_of_zmult];
1.162
1.163 +(*Integer unary minus for the abstract constant 1. Cannot be inserted
1.164 + as a simprule until later: it is number_of_Min re-oriented!*)
1.165 +Goal "- 1 = (-1::int)";
1.166 +by (Simp_tac 1);
1.167 +qed "zminus_1_eq_m1";
1.168
1.169 -(** Inequality reasoning **)
1.170 -
1.171 -Goal "(m*n = (Numeral0::int)) = (m = Numeral0 | n = Numeral0)";
1.172 -by (stac (int_0 RS sym) 1 THEN rtac zmult_eq_int0_iff 1);
1.173 -qed "zmult_eq_0_iff";
1.174 -AddIffs [zmult_eq_0_iff];
1.175 -
1.176 -Goal "(w < z + (Numeral1::int)) = (w<z | w=z)";
1.177 -by (simp_tac (simpset() addsimps [zless_add_int_Suc_eq]) 1);
1.178 -qed "zless_add1_eq";
1.179 -
1.180 -Goal "(w + (Numeral1::int) <= z) = (w<z)";
1.181 -by (simp_tac (simpset() addsimps [add_int_Suc_zle_eq]) 1);
1.182 -qed "add1_zle_eq";
1.183 -
1.184 -Goal "((Numeral1::int) + w <= z) = (w<z)";
1.185 -by (stac zadd_commute 1);
1.186 -by (rtac add1_zle_eq 1);
1.187 -qed "add1_left_zle_eq";
1.188 -
1.189 -Goal "neg x = (x < Numeral0)";
1.190 -by (simp_tac (simpset() addsimps [neg_eq_less_int0]) 1);
1.191 -qed "neg_eq_less_0";
1.192 -
1.193 -Goal "(~neg x) = (Numeral0 <= x)";
1.194 -by (simp_tac (simpset() addsimps [not_neg_eq_ge_int0]) 1);
1.195 -qed "not_neg_eq_ge_0";
1.196 -
1.197 -Goal "Numeral0 <= int m";
1.198 -by (Simp_tac 1);
1.199 -qed "zero_zle_int";
1.200 -AddIffs [zero_zle_int];
1.201 -
1.202 -
1.203 -(** Needed because (int 0) rewrites to Numeral0. (* FIXME !? *)
1.204 - Can these be generalized without evaluating large numbers?**)
1.205 -
1.206 -Goal "~ (int k < Numeral0)";
1.207 -by (Simp_tac 1);
1.208 -qed "int_less_0_conv";
1.209 -
1.210 -Goal "(int k <= Numeral0) = (k=0)";
1.211 -by (Simp_tac 1);
1.212 -qed "int_le_0_conv";
1.213 -
1.214 -Goal "(int k = Numeral0) = (k=0)";
1.215 -by (Simp_tac 1);
1.216 -qed "int_eq_0_conv";
1.217 -
1.218 -Goal "(Numeral0 < int k) = (0<k)";
1.219 -by (Simp_tac 1);
1.220 -qed "zero_less_int_conv";
1.221 -
1.222 -Addsimps [int_less_0_conv, int_le_0_conv, int_eq_0_conv, zero_less_int_conv];
1.223 -
1.224 -Goal "(0 < nat z) = (Numeral0 < z)";
1.225 -by (cut_inst_tac [("w","Numeral0")] zless_nat_conj 1);
1.226 +Goal "(0 < nat z) = (0 < z)";
1.227 +by (cut_inst_tac [("w","0")] zless_nat_conj 1);
1.228 by Auto_tac;
1.229 qed "zero_less_nat_eq";
1.230 Addsimps [zero_less_nat_eq];
1.231 @@ -345,7 +236,7 @@
1.232 Goalw [iszero_def]
1.233 "((number_of x::int) = number_of y) = \
1.234 \ iszero (number_of (bin_add x (bin_minus y)))";
1.235 -by (simp_tac (simpset() delsimps [thm "number_of_reorient"]
1.236 +by (simp_tac (simpset()
1.237 addsimps zcompare_rls @ [number_of_add, number_of_minus]) 1);
1.238 qed "eq_number_of_eq";
1.239
1.240 @@ -360,9 +251,11 @@
1.241 Goalw [iszero_def]
1.242 "iszero (number_of (w BIT x)) = (~x & iszero (number_of w::int))";
1.243 by (int_case_tac "number_of w" 1);
1.244 -by (ALLGOALS (asm_simp_tac
1.245 - (simpset() addsimps zcompare_rls @
1.246 - [zminus_zadd_distrib RS sym, zadd_int])));
1.247 +by (ALLGOALS
1.248 + (asm_simp_tac
1.249 + (simpset() addsimps zcompare_rls @
1.250 + [zero_reorient, zminus_zadd_distrib RS sym,
1.251 + int_Suc0_eq_1 RS sym, zadd_int])));
1.252 qed "iszero_number_of_BIT";
1.253
1.254 Goal "iszero (number_of (w BIT False)) = iszero (number_of w::int)";
1.255 @@ -383,20 +276,22 @@
1.256 by (simp_tac (simpset() addsimps bin_mult_simps) 1);
1.257 qed "less_number_of_eq_neg";
1.258
1.259 -Goal "~ neg (number_of Pls)";
1.260 -by (Simp_tac 1);
1.261 +(*But if Numeral0 is rewritten to 0 then this rule can't be applied:
1.262 + Numeral0 IS (number_of Pls) *)
1.263 +Goal "~ neg (number_of Pls)";
1.264 +by (simp_tac (simpset() addsimps [neg_eq_less_0]) 1);
1.265 qed "not_neg_number_of_Pls";
1.266
1.267 Goal "neg (number_of Min)";
1.268 -by (Simp_tac 1);
1.269 +by (simp_tac (simpset() addsimps [neg_eq_less_0, int_0_less_1]) 1);
1.270 qed "neg_number_of_Min";
1.271
1.272 Goal "neg (number_of (w BIT x)) = neg (number_of w)";
1.273 by (Asm_simp_tac 1);
1.274 by (int_case_tac "number_of w" 1);
1.275 by (ALLGOALS (asm_simp_tac
1.276 - (simpset() addsimps [zadd_int, neg_eq_less_int0,
1.277 - symmetric zdiff_def] @ zcompare_rls)));
1.278 + (simpset() addsimps [int_Suc0_eq_1 RS sym, zadd_int,
1.279 + neg_eq_less_0, symmetric zdiff_def] @ zcompare_rls)));
1.280 qed "neg_number_of_BIT";
1.281
1.282
1.283 @@ -413,7 +308,114 @@
1.284 "abs(number_of x::int) = \
1.285 \ (if number_of x < (0::int) then -number_of x else number_of x)";
1.286 by(rtac refl 1);
1.287 -qed "abs_number_of";
1.288 +qed "zabs_number_of";
1.289 +
1.290 +(*0 and 1 require special rewrites because they aren't numerals*)
1.291 +Goal "abs (0::int) = 0";
1.292 +by (simp_tac (simpset() addsimps [zabs_def]) 1);
1.293 +qed "zabs_0";
1.294 +
1.295 +Goal "abs (1::int) = 1";
1.296 +by (simp_tac (simpset() delsimps [int_0, int_1]
1.297 + addsimps [int_0 RS sym, int_1 RS sym, zabs_def]) 1);
1.298 +qed "zabs_1";
1.299 +
1.300 +(*Re-orientation of the equation nnn=x*)
1.301 +Goal "(number_of w = x) = (x = number_of w)";
1.302 +by Auto_tac;
1.303 +qed "number_of_reorient";
1.304 +
1.305 +
1.306 +structure Bin_Simprocs =
1.307 + struct
1.308 + fun prove_conv name tacs sg (hyps: thm list) (t,u) =
1.309 + if t aconv u then None
1.310 + else
1.311 + let val ct = cterm_of sg (HOLogic.mk_Trueprop (HOLogic.mk_eq (t, u)))
1.312 + in Some
1.313 + (prove_goalw_cterm [] ct (K tacs)
1.314 + handle ERROR => error
1.315 + ("The error(s) above occurred while trying to prove " ^
1.316 + string_of_cterm ct ^ "\nInternal failure of simproc " ^ name))
1.317 + end
1.318 +
1.319 + (*version without the hyps argument*)
1.320 + fun prove_conv_nohyps name tacs sg = prove_conv name tacs sg []
1.321 +
1.322 + fun prep_simproc (name, pats, proc) = Simplifier.mk_simproc name pats proc
1.323 + fun prep_pat s = Thm.read_cterm (Theory.sign_of (the_context())) (s, HOLogic.termT)
1.324 + val prep_pats = map prep_pat
1.325 +
1.326 + fun is_numeral (Const("Numeral.number_of", _) $ w) = true
1.327 + | is_numeral _ = false
1.328 +
1.329 + fun simplify_meta_eq f_number_of_eq f_eq =
1.330 + mk_meta_eq ([f_eq, f_number_of_eq] MRS trans)
1.331 +
1.332 + structure IntAbstractNumeralsData =
1.333 + struct
1.334 + val dest_eq = HOLogic.dest_eq o HOLogic.dest_Trueprop o concl_of
1.335 + val is_numeral = is_numeral
1.336 + val numeral_0_eq_0 = int_numeral_0_eq_0
1.337 + val numeral_1_eq_1 = int_numeral_1_eq_1
1.338 + val prove_conv = prove_conv_nohyps "int_abstract_numerals"
1.339 + fun norm_tac simps = ALLGOALS (simp_tac (HOL_ss addsimps simps))
1.340 + val simplify_meta_eq = simplify_meta_eq
1.341 + end
1.342 +
1.343 + structure IntAbstractNumerals = AbstractNumeralsFun (IntAbstractNumeralsData)
1.344 +
1.345 +
1.346 + (*For addition, we already have rules for the operand 0.
1.347 + Multiplication is omitted because there are already special rules for
1.348 + both 0 and 1 as operands. Unary minus is trivial, just have - 1 = -1.
1.349 + For the others, having three patterns is a compromise between just having
1.350 + one (many spurious calls) and having nine (just too many!) *)
1.351 + val eval_numerals =
1.352 + map prep_simproc
1.353 + [("int_add_eval_numerals",
1.354 + prep_pats ["(m::int) + 1", "(m::int) + number_of v"],
1.355 + IntAbstractNumerals.proc (number_of_add RS sym)),
1.356 + ("int_diff_eval_numerals",
1.357 + prep_pats ["(m::int) - 1", "(m::int) - number_of v"],
1.358 + IntAbstractNumerals.proc diff_number_of_eq),
1.359 + ("int_eq_eval_numerals",
1.360 + prep_pats ["(m::int) = 0", "(m::int) = 1", "(m::int) = number_of v"],
1.361 + IntAbstractNumerals.proc eq_number_of_eq),
1.362 + ("int_less_eval_numerals",
1.363 + prep_pats ["(m::int) < 0", "(m::int) < 1", "(m::int) < number_of v"],
1.364 + IntAbstractNumerals.proc less_number_of_eq_neg),
1.365 + ("int_le_eval_numerals",
1.366 + prep_pats ["(m::int) <= 0", "(m::int) <= 1", "(m::int) <= number_of v"],
1.367 + IntAbstractNumerals.proc le_number_of_eq_not_less)]
1.368 +
1.369 + (*reorientation simprules using ==, for the following simproc*)
1.370 + val meta_zero_reorient = zero_reorient RS eq_reflection
1.371 + val meta_one_reorient = one_reorient RS eq_reflection
1.372 + val meta_number_of_reorient = number_of_reorient RS eq_reflection
1.373 +
1.374 + (*reorientation simplification procedure: reorients (polymorphic)
1.375 + 0 = x, 1 = x, nnn = x provided x isn't 0, 1 or a numeral.*)
1.376 + fun reorient_proc sg _ (_ $ t $ u) =
1.377 + case u of
1.378 + Const("0", _) => None
1.379 + | Const("1", _) => None
1.380 + | Const("Numeral.number_of", _) $ _ => None
1.381 + | _ => Some (case t of
1.382 + Const("0", _) => meta_zero_reorient
1.383 + | Const("1", _) => meta_one_reorient
1.384 + | Const("Numeral.number_of", _) $ _ => meta_number_of_reorient)
1.385 +
1.386 + val reorient_simproc =
1.387 + prep_simproc ("reorient_simproc",
1.388 + prep_pats ["0=x", "1=x", "number_of w = x"],
1.389 + reorient_proc)
1.390 +
1.391 + end;
1.392 +
1.393 +
1.394 +Addsimprocs Bin_Simprocs.eval_numerals;
1.395 +Addsimprocs [Bin_Simprocs.reorient_simproc];
1.396
1.397
1.398 (*Delete the original rewrites, with their clumsy conditional expressions*)
1.399 @@ -423,21 +425,24 @@
1.400 (*Hide the binary representation of integer constants*)
1.401 Delsimps [number_of_Pls, number_of_Min, number_of_BIT];
1.402
1.403 +
1.404 +
1.405 (*Simplification of arithmetic operations on integer constants.
1.406 Note that bin_pred_Pls, etc. were added to the simpset by primrec.*)
1.407
1.408 -bind_thms ("NCons_simps", [NCons_Pls_0, NCons_Pls_1, NCons_Min_0, NCons_Min_1, NCons_BIT]);
1.409 +bind_thms ("NCons_simps",
1.410 + [NCons_Pls_0, NCons_Pls_1, NCons_Min_0, NCons_Min_1, NCons_BIT]);
1.411
1.412 bind_thms ("bin_arith_extra_simps",
1.413 [number_of_add RS sym,
1.414 - number_of_minus RS sym,
1.415 + number_of_minus RS sym, zminus_1_eq_m1,
1.416 number_of_mult RS sym,
1.417 bin_succ_1, bin_succ_0,
1.418 bin_pred_1, bin_pred_0,
1.419 bin_minus_1, bin_minus_0,
1.420 bin_add_Pls_right, bin_add_Min_right,
1.421 bin_add_BIT_0, bin_add_BIT_10, bin_add_BIT_11,
1.422 - diff_number_of_eq, abs_number_of,
1.423 + diff_number_of_eq, zabs_number_of, zabs_0, zabs_1,
1.424 bin_mult_1, bin_mult_0] @ NCons_simps);
1.425
1.426 (*For making a minimal simpset, one must include these default simprules
1.427 @@ -454,7 +459,8 @@
1.428 [eq_number_of_eq, iszero_number_of_Pls, nonzero_number_of_Min,
1.429 iszero_number_of_0, iszero_number_of_1,
1.430 less_number_of_eq_neg,
1.431 - not_neg_number_of_Pls, neg_number_of_Min, neg_number_of_BIT,
1.432 + not_neg_number_of_Pls, not_neg_0, not_neg_1, not_iszero_1,
1.433 + neg_number_of_Min, neg_number_of_BIT,
1.434 le_number_of_eq_not_less]);
1.435
1.436 Addsimps bin_arith_extra_simps;
1.437 @@ -484,3 +490,14 @@
1.438
1.439 Addsimps [add_number_of_left, mult_number_of_left,
1.440 add_number_of_diff1, add_number_of_diff2];
1.441 +
1.442 +
1.443 +(** Inserting these natural simprules earlier would break many proofs! **)
1.444 +
1.445 +(* int (Suc n) = 1 + int n *)
1.446 +Addsimps [int_Suc];
1.447 +
1.448 +(* Numeral0 -> 0 and Numeral1 -> 1 *)
1.449 +Addsimps [int_numeral_0_eq_0, int_numeral_1_eq_1];
1.450 +
1.451 +
2.1 --- a/src/HOL/Integ/Bin.thy Mon Oct 22 11:01:30 2001 +0200
2.2 +++ b/src/HOL/Integ/Bin.thy Mon Oct 22 11:54:22 2001 +0200
2.3 @@ -15,12 +15,7 @@
2.4 for the numerical interpretation.
2.5
2.6 The representation expects that (m mod 2) is 0 or 1, even if m is negative;
2.7 -For instance, ~5 div 2 = ~3 and ~5 mod 2 = 1; thus ~5 = (~3)*2 + 1
2.8 -
2.9 -Division is not defined yet! To do it efficiently requires computing the
2.10 -quotient and remainder using ML and checking the answer using multiplication
2.11 -by proof. Then uniqueness of the quotient and remainder yields theorems
2.12 -quoting the previously computed values. (Or code an oracle...)
2.13 +For instance, -5 div 2 = -3 and -5 mod 2 = 1; thus -5 = (-3)*2 + 1
2.14 *)
2.15
2.16 Bin = Int + Numeral +
2.17 @@ -41,11 +36,11 @@
2.18 instance
2.19 int :: number
2.20
2.21 -primrec
2.22 - number_of_Pls "number_of Pls = int 0"
2.23 - number_of_Min "number_of Min = - (int 1)"
2.24 - number_of_BIT "number_of(w BIT x) = (if x then int 1 else int 0) +
2.25 - (number_of w) + (number_of w)"
2.26 +primrec (*the type constraint is essential!*)
2.27 + number_of_Pls "number_of Pls = 0"
2.28 + number_of_Min "number_of Min = - (1::int)"
2.29 + number_of_BIT "number_of(w BIT x) = (if x then 1 else 0) +
2.30 + (number_of w) + (number_of w)"
2.31
2.32 primrec
2.33 bin_succ_Pls "bin_succ Pls = Pls BIT True"
2.34 @@ -86,5 +81,4 @@
2.35 (if x then (bin_add (NCons (bin_mult v w) False) w)
2.36 else (NCons (bin_mult v w) False))"
2.37
2.38 -
2.39 end
3.1 --- a/src/HOL/Integ/Int.ML Mon Oct 22 11:01:30 2001 +0200
3.2 +++ b/src/HOL/Integ/Int.ML Mon Oct 22 11:54:22 2001 +0200
3.3 @@ -9,6 +9,56 @@
3.4 *)
3.5
3.6
3.7 +Goal "int 0 = (0::int)";
3.8 +by (simp_tac (simpset() addsimps [Zero_int_def]) 1);
3.9 +qed "int_0";
3.10 +
3.11 +Goal "int 1 = 1";
3.12 +by (simp_tac (simpset() addsimps [One_int_def]) 1);
3.13 +qed "int_1";
3.14 +
3.15 +Goal "int (Suc 0) = 1";
3.16 +by (simp_tac (simpset() addsimps [One_int_def, One_nat_def]) 1);
3.17 +qed "int_Suc0_eq_1";
3.18 +
3.19 +Goalw [zdiff_def,zless_def] "neg x = (x < 0)";
3.20 +by Auto_tac;
3.21 +qed "neg_eq_less_0";
3.22 +
3.23 +Goalw [zle_def] "(~neg x) = (0 <= x)";
3.24 +by (simp_tac (simpset() addsimps [neg_eq_less_0]) 1);
3.25 +qed "not_neg_eq_ge_0";
3.26 +
3.27 +(** Needed to simplify inequalities when Numeral1 can get simplified to 1 **)
3.28 +
3.29 +Goal "~ neg 0";
3.30 +by (simp_tac (simpset() addsimps [One_int_def, neg_eq_less_0]) 1);
3.31 +qed "not_neg_0";
3.32 +
3.33 +Goal "~ neg 1";
3.34 +by (simp_tac (simpset() addsimps [One_int_def, neg_eq_less_0]) 1);
3.35 +qed "not_neg_1";
3.36 +
3.37 +Goal "iszero 0";
3.38 +by (simp_tac (simpset() addsimps [iszero_def]) 1);
3.39 +qed "iszero_0";
3.40 +
3.41 +Goal "~ iszero 1";
3.42 +by (simp_tac (simpset() addsimps [Zero_int_def, One_int_def, One_nat_def,
3.43 + iszero_def]) 1);
3.44 +qed "not_iszero_1";
3.45 +
3.46 +Goal "0 < (1::int)";
3.47 +by (simp_tac (simpset() addsimps [Zero_int_def, One_int_def, One_nat_def]) 1);
3.48 +qed "int_0_less_1";
3.49 +
3.50 +Goal "0 \\<noteq> (1::int)";
3.51 +by (simp_tac (simpset() addsimps [Zero_int_def, One_int_def, One_nat_def]) 1);
3.52 +qed "int_0_neq_1";
3.53 +
3.54 +Addsimps [int_0, int_1, int_0_neq_1];
3.55 +
3.56 +
3.57 (*** Abel_Cancel simproc on the integers ***)
3.58
3.59 (* Lemmas needed for the simprocs *)
3.60 @@ -23,7 +73,7 @@
3.61 everything gets cancelled on the right.*)
3.62 Goal "((x::int) + (y + z) = y) = (x = -z)";
3.63 by (stac zadd_left_commute 1);
3.64 -by (res_inst_tac [("t", "y")] (zadd_int0_right RS subst) 1
3.65 +by (res_inst_tac [("t", "y")] (zadd_0_right RS subst) 1
3.66 THEN stac zadd_left_cancel 1);
3.67 by (simp_tac (simpset() addsimps [eq_zdiff_eq RS sym]) 1);
3.68 qed "zadd_cancel_end";
3.69 @@ -36,7 +86,7 @@
3.70
3.71 val sg_ref = Sign.self_ref (Theory.sign_of (the_context ()))
3.72 val T = HOLogic.intT
3.73 - val zero = Const ("IntDef.int", HOLogic.natT --> T) $ HOLogic.zero
3.74 + val zero = Const ("0", HOLogic.intT)
3.75 val restrict_to_left = restrict_to_left
3.76 val add_cancel_21 = zadd_cancel_21
3.77 val add_cancel_end = zadd_cancel_end
3.78 @@ -44,8 +94,8 @@
3.79 val add_assoc = zadd_assoc
3.80 val add_commute = zadd_commute
3.81 val add_left_commute = zadd_left_commute
3.82 - val add_0 = zadd_int0
3.83 - val add_0_right = zadd_int0_right
3.84 + val add_0 = zadd_0
3.85 + val add_0_right = zadd_0_right
3.86
3.87 val eq_diff_eq = eq_zdiff_eq
3.88 val eqI_rules = [zless_eqI, zeq_eqI, zle_eqI]
3.89 @@ -56,8 +106,8 @@
3.90 val diff_def = zdiff_def
3.91 val minus_add_distrib = zminus_zadd_distrib
3.92 val minus_minus = zminus_zminus
3.93 - val minus_0 = zminus_int0
3.94 - val add_inverses = [zadd_zminus_inverse, zadd_zminus_inverse2];
3.95 + val minus_0 = zminus_0
3.96 + val add_inverses = [zadd_zminus_inverse, zadd_zminus_inverse2]
3.97 val cancel_simps = [zadd_zminus_cancel, zminus_zadd_cancel]
3.98 end;
3.99
3.100 @@ -86,29 +136,26 @@
3.101 by (simp_tac (simpset() addsimps [zle_def, zless_def]) 1);
3.102 qed "zle_eq_not_neg";
3.103
3.104 +(** Inequality reasoning **)
3.105
3.106 -(*** Inequality lemmas involving int (Suc m) ***)
3.107 +Goal "(w < z + (1::int)) = (w<z | w=z)";
3.108 +by (auto_tac (claset(),
3.109 + simpset() addsimps [zless_iff_Suc_zadd, int_Suc,
3.110 + gr0_conv_Suc, zero_reorient]));
3.111 +by (res_inst_tac [("x","Suc n")] exI 1);
3.112 +by (simp_tac (simpset() addsimps [int_Suc]) 1);
3.113 +qed "zless_add1_eq";
3.114
3.115 -Goal "(w < z + int (Suc m)) = (w < z + int m | w = z + int m)";
3.116 -by (auto_tac (claset(),
3.117 - simpset() addsimps [zless_iff_Suc_zadd, zadd_assoc, zadd_int]));
3.118 -by (cut_inst_tac [("m","m")] int_Suc_int_1 1);
3.119 -by (cut_inst_tac [("m","n")] int_Suc_int_1 1);
3.120 -by (Asm_full_simp_tac 1);
3.121 -by (case_tac "n" 1);
3.122 -by Auto_tac;
3.123 -by (cut_inst_tac [("m","m")] int_Suc_int_1 1);
3.124 -by (full_simp_tac (simpset() addsimps zadd_ac) 1);
3.125 -by (asm_full_simp_tac (simpset() addsimps [zadd_assoc RS sym]) 1);
3.126 -by (auto_tac (claset(),
3.127 - simpset() addsimps [zless_iff_Suc_zadd, zadd_assoc, zadd_int]));
3.128 -qed "zless_add_int_Suc_eq";
3.129 +Goal "(w + (1::int) <= z) = (w<z)";
3.130 +by (asm_full_simp_tac (simpset() addsimps [zle_def, zless_add1_eq]) 1);
3.131 +by (auto_tac (claset() addIs [zle_anti_sym],
3.132 + simpset() addsimps [order_less_imp_le, symmetric zle_def]));
3.133 +qed "add1_zle_eq";
3.134
3.135 -Goal "(w + int (Suc m) <= z) = (w + int m < z)";
3.136 -by (simp_tac (simpset() addsimps [zle_def, zless_add_int_Suc_eq]) 1);
3.137 -by (auto_tac (claset() addIs [zle_anti_sym] addEs [zless_asym],
3.138 - simpset() addsimps [order_less_imp_le, symmetric zle_def]));
3.139 -qed "add_int_Suc_zle_eq";
3.140 +Goal "((1::int) + w <= z) = (w<z)";
3.141 +by (stac zadd_commute 1);
3.142 +by (rtac add1_zle_eq 1);
3.143 +qed "add1_left_zle_eq";
3.144
3.145
3.146 (*** Monotonicity results ***)
3.147 @@ -194,7 +241,21 @@
3.148 by Auto_tac;
3.149 qed "zminus_equation";
3.150
3.151 -Goal "- (int (Suc n)) < int 0";
3.152 +
3.153 +(** Instances of the equations above, for zero **)
3.154 +
3.155 +(*instantiate a variable to zero and simplify*)
3.156 +fun zero_instance v th = simplify (simpset()) (inst v "0" th);
3.157 +
3.158 +Addsimps [zero_instance "x" zless_zminus,
3.159 + zero_instance "y" zminus_zless,
3.160 + zero_instance "x" zle_zminus,
3.161 + zero_instance "y" zminus_zle,
3.162 + zero_instance "x" equation_zminus,
3.163 + zero_instance "y" zminus_equation];
3.164 +
3.165 +
3.166 +Goal "- (int (Suc n)) < 0";
3.167 by (simp_tac (simpset() addsimps [zless_def]) 1);
3.168 qed "negative_zless_0";
3.169
3.170 @@ -204,7 +265,7 @@
3.171 qed "negative_zless";
3.172 AddIffs [negative_zless];
3.173
3.174 -Goal "- int n <= int 0";
3.175 +Goal "- int n <= 0";
3.176 by (simp_tac (simpset() addsimps [zminus_zle]) 1);
3.177 qed "negative_zle_0";
3.178
3.179 @@ -213,7 +274,7 @@
3.180 qed "negative_zle";
3.181 AddIffs [negative_zle];
3.182
3.183 -Goal "~(int 0 <= - (int (Suc n)))";
3.184 +Goal "~(0 <= - (int (Suc n)))";
3.185 by (stac zle_zminus 1);
3.186 by (Simp_tac 1);
3.187 qed "not_zle_0_negative";
3.188 @@ -242,19 +303,11 @@
3.189
3.190
3.191 Goal "(w <= z) = (EX n. z = w + int n)";
3.192 -by (auto_tac (claset() addSIs [not_sym RS not0_implies_Suc],
3.193 +by (auto_tac (claset() addIs [inst "x" "0::nat" exI]
3.194 + addSIs [not_sym RS not0_implies_Suc],
3.195 simpset() addsimps [zless_iff_Suc_zadd, int_le_less]));
3.196 qed "zle_iff_zadd";
3.197
3.198 -
3.199 -Goalw [zdiff_def,zless_def] "neg x = (x < int 0)";
3.200 -by Auto_tac;
3.201 -qed "neg_eq_less_int0";
3.202 -
3.203 -Goalw [zle_def] "(~neg x) = (int 0 <= x)";
3.204 -by (simp_tac (simpset() addsimps [neg_eq_less_int0]) 1);
3.205 -qed "not_neg_eq_ge_int0";
3.206 -
3.207 Goal "abs (int m) = int m";
3.208 by (simp_tac (simpset() addsimps [zabs_def]) 1);
3.209 qed "abs_int_eq";
3.210 @@ -266,23 +319,28 @@
3.211 Goalw [nat_def] "nat(int n) = n";
3.212 by Auto_tac;
3.213 qed "nat_int";
3.214 +Addsimps [nat_int];
3.215
3.216 -Goalw [nat_def] "nat(- int n) = 0";
3.217 +Goalw [nat_def] "nat(- (int n)) = 0";
3.218 by (auto_tac (claset(),
3.219 - simpset() addsimps [neg_eq_less_int0, zminus_zless]));
3.220 + simpset() addsimps [neg_eq_less_0, zero_reorient, zminus_zless]));
3.221 qed "nat_zminus_int";
3.222 +Addsimps [nat_zminus_int];
3.223
3.224 -Addsimps [nat_int, nat_zminus_int];
3.225 +Goalw [Zero_int_def] "nat 0 = 0";
3.226 +by (rtac nat_int 1);
3.227 +qed "nat_zero";
3.228 +Addsimps [nat_zero];
3.229
3.230 Goal "~ neg z ==> int (nat z) = z";
3.231 -by (dtac (not_neg_eq_ge_int0 RS iffD1) 1);
3.232 +by (dtac (not_neg_eq_ge_0 RS iffD1) 1);
3.233 by (dtac zle_imp_zless_or_eq 1);
3.234 by (auto_tac (claset(), simpset() addsimps [zless_iff_Suc_zadd]));
3.235 qed "not_neg_nat";
3.236
3.237 Goal "neg x ==> EX n. x = - (int (Suc n))";
3.238 by (auto_tac (claset(),
3.239 - simpset() addsimps [neg_eq_less_int0, zless_iff_Suc_zadd,
3.240 + simpset() addsimps [neg_eq_less_0, zless_iff_Suc_zadd,
3.241 zdiff_eq_eq RS sym, zdiff_def]));
3.242 qed "negD";
3.243
3.244 @@ -295,28 +353,28 @@
3.245 by (etac (not_neg_nat RS subst) 2);
3.246 by (auto_tac (claset(), simpset() addsimps [neg_nat]));
3.247 by (auto_tac (claset() addDs [order_less_trans],
3.248 - simpset() addsimps [neg_eq_less_int0]));
3.249 + simpset() addsimps [neg_eq_less_0]));
3.250 qed "zless_nat_eq_int_zless";
3.251
3.252 -Goal "z <= int 0 ==> nat z = 0";
3.253 +Goal "z <= 0 ==> nat z = 0";
3.254 by (auto_tac (claset(),
3.255 - simpset() addsimps [order_le_less, neg_eq_less_int0,
3.256 + simpset() addsimps [order_le_less, neg_eq_less_0,
3.257 zle_def, neg_nat]));
3.258 qed "nat_le_int0";
3.259
3.260 -(*An alternative condition is int 0 <= w *)
3.261 -Goal "int 0 < z ==> (nat w < nat z) = (w < z)";
3.262 +(*An alternative condition is 0 <= w *)
3.263 +Goal "0 < z ==> (nat w < nat z) = (w < z)";
3.264 by (stac (zless_int RS sym) 1);
3.265 -by (asm_simp_tac (simpset() addsimps [not_neg_nat, not_neg_eq_ge_int0,
3.266 +by (asm_simp_tac (simpset() addsimps [not_neg_nat, not_neg_eq_ge_0,
3.267 order_le_less]) 1);
3.268 by (case_tac "neg w" 1);
3.269 by (asm_simp_tac (simpset() addsimps [not_neg_nat]) 2);
3.270 -by (asm_full_simp_tac (simpset() addsimps [neg_eq_less_int0, neg_nat]) 1);
3.271 +by (asm_full_simp_tac (simpset() addsimps [neg_eq_less_0, neg_nat]) 1);
3.272 by (blast_tac (claset() addIs [order_less_trans]) 1);
3.273 val lemma = result();
3.274
3.275 -Goal "(nat w < nat z) = (int 0 < z & w < z)";
3.276 -by (case_tac "int 0 < z" 1);
3.277 +Goal "(nat w < nat z) = (0 < z & w < z)";
3.278 +by (case_tac "0 < z" 1);
3.279 by (auto_tac (claset(),
3.280 simpset() addsimps [lemma, nat_le_int0, linorder_not_less]));
3.281 qed "zless_nat_conj";
3.282 @@ -339,35 +397,36 @@
3.283
3.284 Goal "i <= (j::int) ==> i * int k <= j * int k";
3.285 by (induct_tac "k" 1);
3.286 -by (stac int_Suc_int_1 2);
3.287 +by (stac int_Suc 2);
3.288 by (ALLGOALS
3.289 - (asm_simp_tac (simpset() addsimps [zadd_zmult_distrib2, zadd_zle_mono])));
3.290 + (asm_simp_tac (simpset() addsimps [zadd_zmult_distrib2, zadd_zle_mono,
3.291 + int_Suc0_eq_1])));
3.292 val lemma = result();
3.293
3.294 -Goal "[| i <= j; int 0 <= k |] ==> i*k <= j*k";
3.295 +Goal "[| i <= j; (0::int) <= k |] ==> i*k <= j*k";
3.296 by (res_inst_tac [("t", "k")] (not_neg_nat RS subst) 1);
3.297 by (etac lemma 2);
3.298 -by (full_simp_tac (simpset() addsimps [not_neg_eq_ge_int0]) 1);
3.299 +by (full_simp_tac (simpset() addsimps [not_neg_eq_ge_0]) 1);
3.300 qed "zmult_zle_mono1";
3.301
3.302 -Goal "[| i <= j; k <= int 0 |] ==> j*k <= i*k";
3.303 +Goal "[| i <= j; k <= (0::int) |] ==> j*k <= i*k";
3.304 by (rtac (zminus_zle_zminus RS iffD1) 1);
3.305 by (asm_simp_tac (simpset() addsimps [zmult_zminus_right RS sym,
3.306 zmult_zle_mono1, zle_zminus]) 1);
3.307 qed "zmult_zle_mono1_neg";
3.308
3.309 -Goal "[| i <= j; int 0 <= k |] ==> k*i <= k*j";
3.310 +Goal "[| i <= j; (0::int) <= k |] ==> k*i <= k*j";
3.311 by (dtac zmult_zle_mono1 1);
3.312 by (ALLGOALS (asm_full_simp_tac (simpset() addsimps [zmult_commute])));
3.313 qed "zmult_zle_mono2";
3.314
3.315 -Goal "[| i <= j; k <= int 0 |] ==> k*j <= k*i";
3.316 +Goal "[| i <= j; k <= (0::int) |] ==> k*j <= k*i";
3.317 by (dtac zmult_zle_mono1_neg 1);
3.318 by (ALLGOALS (asm_full_simp_tac (simpset() addsimps [zmult_commute])));
3.319 qed "zmult_zle_mono2_neg";
3.320
3.321 (* <= monotonicity, BOTH arguments*)
3.322 -Goal "[| i <= j; k <= l; int 0 <= j; int 0 <= k |] ==> i*k <= j*l";
3.323 +Goal "[| i <= j; k <= l; (0::int) <= j; (0::int) <= k |] ==> i*k <= j*l";
3.324 by (etac (zmult_zle_mono1 RS order_trans) 1);
3.325 by (assume_tac 1);
3.326 by (etac zmult_zle_mono2 1);
3.327 @@ -379,64 +438,65 @@
3.328
3.329 Goal "i<j ==> 0<k --> int k * i < int k * j";
3.330 by (induct_tac "k" 1);
3.331 -by (stac int_Suc_int_1 2);
3.332 +by (stac int_Suc 2);
3.333 by (case_tac "n=0" 2);
3.334 by (ALLGOALS (asm_full_simp_tac
3.335 (simpset() addsimps [zadd_zmult_distrib, zadd_zless_mono,
3.336 - order_le_less])));
3.337 -val lemma = result() RS mp;
3.338 + int_Suc0_eq_1, order_le_less])));
3.339 +val lemma = result();
3.340
3.341 -Goal "[| i<j; int 0 < k |] ==> k*i < k*j";
3.342 +Goal "[| i<j; (0::int) < k |] ==> k*i < k*j";
3.343 by (res_inst_tac [("t", "k")] (not_neg_nat RS subst) 1);
3.344 -by (etac lemma 2);
3.345 -by (asm_simp_tac (simpset() addsimps [not_neg_eq_ge_int0,
3.346 +by (etac (lemma RS mp) 2);
3.347 +by (asm_simp_tac (simpset() addsimps [not_neg_eq_ge_0,
3.348 order_le_less]) 1);
3.349 by (forward_tac [conjI RS (zless_nat_conj RS iffD2)] 1);
3.350 by Auto_tac;
3.351 qed "zmult_zless_mono2";
3.352
3.353 -Goal "[| i<j; int 0 < k |] ==> i*k < j*k";
3.354 +Goal "[| i<j; (0::int) < k |] ==> i*k < j*k";
3.355 by (dtac zmult_zless_mono2 1);
3.356 by (ALLGOALS (asm_full_simp_tac (simpset() addsimps [zmult_commute])));
3.357 qed "zmult_zless_mono1";
3.358
3.359 (* < monotonicity, BOTH arguments*)
3.360 -Goal "[| i < j; k < l; int 0 < j; int 0 < k |] ==> i*k < j*l";
3.361 +Goal "[| i < j; k < l; (0::int) < j; (0::int) < k |] ==> i*k < j*l";
3.362 by (etac (zmult_zless_mono1 RS order_less_trans) 1);
3.363 by (assume_tac 1);
3.364 by (etac zmult_zless_mono2 1);
3.365 by (assume_tac 1);
3.366 qed "zmult_zless_mono";
3.367
3.368 -Goal "[| i<j; k < int 0 |] ==> j*k < i*k";
3.369 +Goal "[| i<j; k < (0::int) |] ==> j*k < i*k";
3.370 by (rtac (zminus_zless_zminus RS iffD1) 1);
3.371 by (asm_simp_tac (simpset() addsimps [zmult_zminus_right RS sym,
3.372 zmult_zless_mono1, zless_zminus]) 1);
3.373 qed "zmult_zless_mono1_neg";
3.374
3.375 -Goal "[| i<j; k < int 0 |] ==> k*j < k*i";
3.376 +Goal "[| i<j; k < (0::int) |] ==> k*j < k*i";
3.377 by (rtac (zminus_zless_zminus RS iffD1) 1);
3.378 by (asm_simp_tac (simpset() addsimps [zmult_zminus RS sym,
3.379 zmult_zless_mono2, zless_zminus]) 1);
3.380 qed "zmult_zless_mono2_neg";
3.381
3.382
3.383 -Goal "(m*n = int 0) = (m = int 0 | n = int 0)";
3.384 -by (case_tac "m < int 0" 1);
3.385 +Goal "(m*n = (0::int)) = (m = 0 | n = 0)";
3.386 +by (case_tac "m < (0::int)" 1);
3.387 by (auto_tac (claset(),
3.388 simpset() addsimps [linorder_not_less, order_le_less,
3.389 linorder_neq_iff]));
3.390 by (REPEAT
3.391 (force_tac (claset() addDs [zmult_zless_mono1_neg, zmult_zless_mono1],
3.392 simpset()) 1));
3.393 -qed "zmult_eq_int0_iff";
3.394 +qed "zmult_eq_0_iff";
3.395 +AddIffs [zmult_eq_0_iff];
3.396
3.397
3.398 (** Cancellation laws for k*m < k*n and m*k < n*k, also for <= and =,
3.399 but not (yet?) for k*m < n*k. **)
3.400
3.401 -Goal "(m*k < n*k) = ((int 0 < k & m<n) | (k < int 0 & n<m))";
3.402 -by (case_tac "k = int 0" 1);
3.403 +Goal "(m*k < n*k) = (((0::int) < k & m<n) | (k < 0 & n<m))";
3.404 +by (case_tac "k = (0::int)" 1);
3.405 by (auto_tac (claset(), simpset() addsimps [linorder_neq_iff,
3.406 zmult_zless_mono1, zmult_zless_mono1_neg]));
3.407 by (auto_tac (claset(),
3.408 @@ -449,22 +509,22 @@
3.409 qed "zmult_zless_cancel2";
3.410
3.411
3.412 -Goal "(k*m < k*n) = ((int 0 < k & m<n) | (k < int 0 & n<m))";
3.413 +Goal "(k*m < k*n) = (((0::int) < k & m<n) | (k < 0 & n<m))";
3.414 by (simp_tac (simpset() addsimps [inst "z" "k" zmult_commute,
3.415 zmult_zless_cancel2]) 1);
3.416 qed "zmult_zless_cancel1";
3.417
3.418 -Goal "(m*k <= n*k) = ((int 0 < k --> m<=n) & (k < int 0 --> n<=m))";
3.419 +Goal "(m*k <= n*k) = (((0::int) < k --> m<=n) & (k < 0 --> n<=m))";
3.420 by (simp_tac (simpset() addsimps [linorder_not_less RS sym,
3.421 zmult_zless_cancel2]) 1);
3.422 qed "zmult_zle_cancel2";
3.423
3.424 -Goal "(k*m <= k*n) = ((int 0 < k --> m<=n) & (k < int 0 --> n<=m))";
3.425 +Goal "(k*m <= k*n) = (((0::int) < k --> m<=n) & (k < 0 --> n<=m))";
3.426 by (simp_tac (simpset() addsimps [linorder_not_less RS sym,
3.427 zmult_zless_cancel1]) 1);
3.428 qed "zmult_zle_cancel1";
3.429
3.430 -Goal "(m*k = n*k) = (k = int 0 | m=n)";
3.431 +Goal "(m*k = n*k) = (k = (0::int) | m=n)";
3.432 by (cut_facts_tac [linorder_less_linear] 1);
3.433 by Safe_tac;
3.434 by Auto_tac;
3.435 @@ -475,8 +535,15 @@
3.436
3.437 qed "zmult_cancel2";
3.438
3.439 -Goal "(k*m = k*n) = (k = int 0 | m=n)";
3.440 +Goal "(k*m = k*n) = (k = (0::int) | m=n)";
3.441 by (simp_tac (simpset() addsimps [inst "z" "k" zmult_commute,
3.442 zmult_cancel2]) 1);
3.443 qed "zmult_cancel1";
3.444 Addsimps [zmult_cancel1, zmult_cancel2];
3.445 +
3.446 +
3.447 +(*Analogous to zadd_int*)
3.448 +Goal "n<=m --> int m - int n = int (m-n)";
3.449 +by (induct_thm_tac diff_induct "m n" 1);
3.450 +by (auto_tac (claset(), simpset() addsimps [int_Suc, symmetric zdiff_def]));
3.451 +qed_spec_mp "zdiff_int";
4.1 --- a/src/HOL/Integ/Int.thy Mon Oct 22 11:01:30 2001 +0200
4.2 +++ b/src/HOL/Integ/Int.thy Mon Oct 22 11:54:22 2001 +0200
4.3 @@ -9,7 +9,7 @@
4.4 Int = IntDef +
4.5
4.6 instance int :: order (zle_refl,zle_trans,zle_anti_sym,int_less_le)
4.7 -instance int :: plus_ac0 (zadd_commute,zadd_assoc,zadd_zero)
4.8 +instance int :: plus_ac0 (zadd_commute,zadd_assoc,zadd_0)
4.9 instance int :: linorder (zle_linear)
4.10
4.11 constdefs
5.1 --- a/src/HOL/Integ/IntArith.ML Mon Oct 22 11:01:30 2001 +0200
5.2 +++ b/src/HOL/Integ/IntArith.ML Mon Oct 22 11:54:22 2001 +0200
5.3 @@ -3,6 +3,7 @@
5.4 Authors: Larry Paulson and Tobias Nipkow
5.5 *)
5.6
5.7 +
5.8 Goal "abs(abs(x::int)) = abs(x)";
5.9 by(arith_tac 1);
5.10 qed "abs_abs";
5.11 @@ -20,7 +21,7 @@
5.12
5.13 (*** Intermediate value theorems ***)
5.14
5.15 -Goal "(ALL i<n::nat. abs(f(i+1) - f i) <= Numeral1) --> \
5.16 +Goal "(ALL i<n::nat. abs(f(i+1) - f i) <= 1) --> \
5.17 \ f 0 <= k --> k <= f n --> (EX i <= n. f i = (k::int))";
5.18 by(induct_tac "n" 1);
5.19 by(Asm_simp_tac 1);
5.20 @@ -40,7 +41,7 @@
5.21
5.22 bind_thm("nat0_intermed_int_val", ObjectLogic.rulify_no_asm lemma);
5.23
5.24 -Goal "[| !i. m <= i & i < n --> abs(f(i + 1::nat) - f i) <= Numeral1; m < n; \
5.25 +Goal "[| !i. m <= i & i < n --> abs(f(i + 1::nat) - f i) <= 1; m < n; \
5.26 \ f m <= k; k <= f n |] ==> ? i. m <= i & i <= n & f i = (k::int)";
5.27 by(cut_inst_tac [("n","n-m"),("f", "%i. f(i+m)"),("k","k")]lemma 1);
5.28 by(Asm_full_simp_tac 1);
5.29 @@ -56,22 +57,22 @@
5.30
5.31 (*** Some convenient biconditionals for products of signs ***)
5.32
5.33 -Goal "[| (Numeral0::int) < i; Numeral0 < j |] ==> Numeral0 < i*j";
5.34 +Goal "[| (0::int) < i; 0 < j |] ==> 0 < i*j";
5.35 by (dtac zmult_zless_mono1 1);
5.36 by Auto_tac;
5.37 qed "zmult_pos";
5.38
5.39 -Goal "[| i < (Numeral0::int); j < Numeral0 |] ==> Numeral0 < i*j";
5.40 +Goal "[| i < (0::int); j < 0 |] ==> 0 < i*j";
5.41 by (dtac zmult_zless_mono1_neg 1);
5.42 by Auto_tac;
5.43 qed "zmult_neg";
5.44
5.45 -Goal "[| (Numeral0::int) < i; j < Numeral0 |] ==> i*j < Numeral0";
5.46 +Goal "[| (0::int) < i; j < 0 |] ==> i*j < 0";
5.47 by (dtac zmult_zless_mono1_neg 1);
5.48 by Auto_tac;
5.49 qed "zmult_pos_neg";
5.50
5.51 -Goal "((Numeral0::int) < x*y) = (Numeral0 < x & Numeral0 < y | x < Numeral0 & y < Numeral0)";
5.52 +Goal "((0::int) < x*y) = (0 < x & 0 < y | x < 0 & y < 0)";
5.53 by (auto_tac (claset(),
5.54 simpset() addsimps [order_le_less, linorder_not_less,
5.55 zmult_pos, zmult_neg]));
5.56 @@ -84,13 +85,13 @@
5.57 simpset() addsimps [zmult_commute]));
5.58 qed "int_0_less_mult_iff";
5.59
5.60 -Goal "((Numeral0::int) <= x*y) = (Numeral0 <= x & Numeral0 <= y | x <= Numeral0 & y <= Numeral0)";
5.61 +Goal "((0::int) <= x*y) = (0 <= x & 0 <= y | x <= 0 & y <= 0)";
5.62 by (auto_tac (claset(),
5.63 simpset() addsimps [order_le_less, linorder_not_less,
5.64 int_0_less_mult_iff]));
5.65 qed "int_0_le_mult_iff";
5.66
5.67 -Goal "(x*y < (Numeral0::int)) = (Numeral0 < x & y < Numeral0 | x < Numeral0 & Numeral0 < y)";
5.68 +Goal "(x*y < (0::int)) = (0 < x & y < 0 | x < 0 & 0 < y)";
5.69 by (auto_tac (claset(),
5.70 simpset() addsimps [int_0_le_mult_iff,
5.71 linorder_not_le RS sym]));
5.72 @@ -98,30 +99,31 @@
5.73 simpset() addsimps [linorder_not_le]));
5.74 qed "zmult_less_0_iff";
5.75
5.76 -Goal "(x*y <= (Numeral0::int)) = (Numeral0 <= x & y <= Numeral0 | x <= Numeral0 & Numeral0 <= y)";
5.77 +Goal "(x*y <= (0::int)) = (0 <= x & y <= 0 | x <= 0 & 0 <= y)";
5.78 by (auto_tac (claset() addDs [order_less_not_sym],
5.79 simpset() addsimps [int_0_less_mult_iff,
5.80 linorder_not_less RS sym]));
5.81 qed "zmult_le_0_iff";
5.82
5.83 Goal "abs (x * y) = abs x * abs (y::int)";
5.84 -by (simp_tac (simpset () addsplits [zabs_split]
5.85 +by (simp_tac (simpset () delsimps [thm "number_of_reorient"] addsplits [zabs_split]
5.86 + addsplits [zabs_split]
5.87 addsimps [zmult_less_0_iff, zle_def]) 1);
5.88 qed "abs_mult";
5.89
5.90 -Goal "(abs x = Numeral0) = (x = (Numeral0::int))";
5.91 +Goal "(abs x = 0) = (x = (0::int))";
5.92 by (simp_tac (simpset () addsplits [zabs_split]) 1);
5.93 qed "abs_eq_0";
5.94 AddIffs [abs_eq_0];
5.95
5.96 -Goal "(Numeral0 < abs x) = (x ~= (Numeral0::int))";
5.97 +Goal "(0 < abs x) = (x ~= (0::int))";
5.98 by (simp_tac (simpset () addsplits [zabs_split]) 1);
5.99 by (arith_tac 1);
5.100 qed "zero_less_abs_iff";
5.101 AddIffs [zero_less_abs_iff];
5.102
5.103 -Goal "Numeral0 <= x * (x::int)";
5.104 -by (subgoal_tac "(- x) * x <= Numeral0" 1);
5.105 +Goal "0 <= x * (x::int)";
5.106 +by (subgoal_tac "(- x) * x <= 0" 1);
5.107 by (Asm_full_simp_tac 1);
5.108 by (simp_tac (HOL_basic_ss addsimps [zmult_le_0_iff]) 1);
5.109 by Auto_tac;
5.110 @@ -132,48 +134,48 @@
5.111
5.112 (*** Products and 1, by T. M. Rasmussen ***)
5.113
5.114 -Goal "(m = m*(n::int)) = (n = Numeral1 | m = Numeral0)";
5.115 +Goal "(m = m*(n::int)) = (n = 1 | m = 0)";
5.116 by Auto_tac;
5.117 -by (subgoal_tac "m*Numeral1 = m*n" 1);
5.118 +by (subgoal_tac "m*1 = m*n" 1);
5.119 by (dtac (zmult_cancel1 RS iffD1) 1);
5.120 by Auto_tac;
5.121 qed "zmult_eq_self_iff";
5.122
5.123 -Goal "[| Numeral1 < m; Numeral1 < n |] ==> Numeral1 < m*(n::int)";
5.124 -by (res_inst_tac [("y","Numeral1*n")] order_less_trans 1);
5.125 +Goal "[| 1 < m; 1 < n |] ==> 1 < m*(n::int)";
5.126 +by (res_inst_tac [("y","1*n")] order_less_trans 1);
5.127 by (rtac zmult_zless_mono1 2);
5.128 by (ALLGOALS Asm_simp_tac);
5.129 qed "zless_1_zmult";
5.130
5.131 -Goal "[| Numeral0 < n; n ~= Numeral1 |] ==> Numeral1 < (n::int)";
5.132 +Goal "[| 0 < n; n ~= 1 |] ==> 1 < (n::int)";
5.133 by (arith_tac 1);
5.134 val lemma = result();
5.135
5.136 -Goal "Numeral0 < (m::int) ==> (m * n = Numeral1) = (m = Numeral1 & n = Numeral1)";
5.137 +Goal "0 < (m::int) ==> (m * n = 1) = (m = 1 & n = 1)";
5.138 by Auto_tac;
5.139 -by (case_tac "m=Numeral1" 1);
5.140 -by (case_tac "n=Numeral1" 2);
5.141 -by (case_tac "m=Numeral1" 4);
5.142 -by (case_tac "n=Numeral1" 5);
5.143 +by (case_tac "m=1" 1);
5.144 +by (case_tac "n=1" 2);
5.145 +by (case_tac "m=1" 4);
5.146 +by (case_tac "n=1" 5);
5.147 by Auto_tac;
5.148 by distinct_subgoals_tac;
5.149 -by (subgoal_tac "Numeral1<m*n" 1);
5.150 +by (subgoal_tac "1<m*n" 1);
5.151 by (Asm_full_simp_tac 1);
5.152 by (rtac zless_1_zmult 1);
5.153 by (ALLGOALS (rtac lemma));
5.154 by Auto_tac;
5.155 -by (subgoal_tac "Numeral0<m*n" 1);
5.156 +by (subgoal_tac "0<m*n" 1);
5.157 by (Asm_simp_tac 2);
5.158 by (dtac (int_0_less_mult_iff RS iffD1) 1);
5.159 by Auto_tac;
5.160 qed "pos_zmult_eq_1_iff";
5.161
5.162 -Goal "(m*n = (Numeral1::int)) = ((m = Numeral1 & n = Numeral1) | (m = -1 & n = -1))";
5.163 -by (case_tac "Numeral0<m" 1);
5.164 +Goal "(m*n = (1::int)) = ((m = 1 & n = 1) | (m = -1 & n = -1))";
5.165 +by (case_tac "0<m" 1);
5.166 by (asm_simp_tac (simpset() addsimps [pos_zmult_eq_1_iff]) 1);
5.167 -by (case_tac "m=Numeral0" 1);
5.168 -by (Asm_simp_tac 1);
5.169 -by (subgoal_tac "Numeral0 < -m" 1);
5.170 +by (case_tac "m=0" 1);
5.171 +by (asm_simp_tac (simpset () delsimps [thm "number_of_reorient"]) 1);
5.172 +by (subgoal_tac "0 < -m" 1);
5.173 by (arith_tac 2);
5.174 by (dres_inst_tac [("n","-n")] pos_zmult_eq_1_iff 1);
5.175 by Auto_tac;
6.1 --- a/src/HOL/Integ/IntArith.thy Mon Oct 22 11:01:30 2001 +0200
6.2 +++ b/src/HOL/Integ/IntArith.thy Mon Oct 22 11:54:22 2001 +0200
6.3 @@ -3,5 +3,4 @@
6.4
6.5 use "int_arith1.ML" setup int_arith_setup
6.6 use "int_arith2.ML" lemmas [arith_split] = zabs_split
6.7 -
6.8 end
7.1 --- a/src/HOL/Integ/IntDef.ML Mon Oct 22 11:01:30 2001 +0200
7.2 +++ b/src/HOL/Integ/IntDef.ML Mon Oct 22 11:54:22 2001 +0200
7.3 @@ -7,9 +7,6 @@
7.4 *)
7.5
7.6
7.7 -(*Rewrite the overloaded 0::int and 1::int*) (* FIXME *)
7.8 -Addsimps [Zero_int_def, One_int_def];
7.9 -
7.10 Goalw [intrel_def] "(((x1,y1),(x2,y2)): intrel) = (x1+y2 = x2+y1)";
7.11 by (Blast_tac 1);
7.12 qed "intrel_iff";
7.13 @@ -90,11 +87,10 @@
7.14 by (Asm_full_simp_tac 1);
7.15 qed "inj_zminus";
7.16
7.17 -Goalw [int_def] "- (int 0) = int 0";
7.18 +Goalw [int_def, Zero_int_def] "- 0 = (0::int)";
7.19 by (simp_tac (simpset() addsimps [zminus]) 1);
7.20 -qed "zminus_int0";
7.21 -
7.22 -Addsimps [zminus_int0];
7.23 +qed "zminus_0";
7.24 +Addsimps [zminus_0];
7.25
7.26
7.27 (**** neg: the test for negative integers ****)
7.28 @@ -159,61 +155,57 @@
7.29 by (simp_tac (simpset() addsimps [zadd_int, zadd_assoc RS sym]) 1);
7.30 qed "zadd_int_left";
7.31
7.32 -Goal "int (Suc m) = int 1 + (int m)";
7.33 -by (simp_tac (simpset() addsimps [zadd_int]) 1);
7.34 -qed "int_Suc_int_1";
7.35 +Goal "int (Suc m) = 1 + (int m)";
7.36 +by (simp_tac (simpset() addsimps [One_int_def, zadd_int]) 1);
7.37 +qed "int_Suc";
7.38
7.39 -Goalw [int_def] "int 0 + z = z";
7.40 +(*also for the instance declaration int :: plus_ac0*)
7.41 +Goalw [Zero_int_def, int_def] "(0::int) + z = z";
7.42 by (res_inst_tac [("z","z")] eq_Abs_Integ 1);
7.43 by (asm_simp_tac (simpset() addsimps [zadd]) 1);
7.44 -qed "zadd_int0";
7.45 +qed "zadd_0";
7.46 +Addsimps [zadd_0];
7.47
7.48 -Goal "z + int 0 = z";
7.49 -by (rtac (zadd_commute RS trans) 1);
7.50 -by (rtac zadd_int0 1);
7.51 -qed "zadd_int0_right";
7.52 +Goal "z + (0::int) = z";
7.53 +by (rtac ([zadd_commute, zadd_0] MRS trans) 1);
7.54 +qed "zadd_0_right";
7.55 +Addsimps [zadd_0_right];
7.56
7.57 -Goalw [int_def] "z + (- z) = int 0";
7.58 +Goalw [int_def, Zero_int_def] "z + (- z) = (0::int)";
7.59 by (res_inst_tac [("z","z")] eq_Abs_Integ 1);
7.60 by (asm_simp_tac (simpset() addsimps [zminus, zadd, add_commute]) 1);
7.61 qed "zadd_zminus_inverse";
7.62
7.63 -Goal "(- z) + z = int 0";
7.64 +Goal "(- z) + z = (0::int)";
7.65 by (rtac (zadd_commute RS trans) 1);
7.66 by (rtac zadd_zminus_inverse 1);
7.67 qed "zadd_zminus_inverse2";
7.68
7.69 -Addsimps [zadd_int0, zadd_int0_right,
7.70 - zadd_zminus_inverse, zadd_zminus_inverse2];
7.71 -
7.72 -(*for the instance declaration int :: plus_ac0*)
7.73 -Goal "0 + z = (z::int)";
7.74 -by (Simp_tac 1);
7.75 -qed "zadd_zero";
7.76 +Addsimps [zadd_zminus_inverse, zadd_zminus_inverse2];
7.77
7.78 Goal "z + (- z + w) = (w::int)";
7.79 -by (simp_tac (simpset() addsimps [zadd_assoc RS sym]) 1);
7.80 +by (simp_tac (simpset() addsimps [zadd_assoc RS sym, zadd_0]) 1);
7.81 qed "zadd_zminus_cancel";
7.82
7.83 Goal "(-z) + (z + w) = (w::int)";
7.84 -by (simp_tac (simpset() addsimps [zadd_assoc RS sym]) 1);
7.85 +by (simp_tac (simpset() addsimps [zadd_assoc RS sym, zadd_0]) 1);
7.86 qed "zminus_zadd_cancel";
7.87
7.88 Addsimps [zadd_zminus_cancel, zminus_zadd_cancel];
7.89
7.90 -Goal "int 0 - x = -x";
7.91 +Goal "(0::int) - x = -x";
7.92 by (simp_tac (simpset() addsimps [zdiff_def]) 1);
7.93 -qed "zdiff_int0";
7.94 +qed "zdiff0";
7.95
7.96 -Goal "x - int 0 = x";
7.97 +Goal "x - (0::int) = x";
7.98 by (simp_tac (simpset() addsimps [zdiff_def]) 1);
7.99 -qed "zdiff_int0_right";
7.100 +qed "zdiff0_right";
7.101
7.102 -Goal "x - x = int 0";
7.103 -by (simp_tac (simpset() addsimps [zdiff_def]) 1);
7.104 +Goal "x - x = (0::int)";
7.105 +by (simp_tac (simpset() addsimps [zdiff_def, Zero_int_def]) 1);
7.106 qed "zdiff_self";
7.107
7.108 -Addsimps [zdiff_int0, zdiff_int0_right, zdiff_self];
7.109 +Addsimps [zdiff0, zdiff0_right, zdiff_self];
7.110
7.111
7.112 (** Lemmas **)
7.113 @@ -321,25 +313,27 @@
7.114 by (simp_tac (simpset() addsimps [zmult]) 1);
7.115 qed "zmult_int";
7.116
7.117 -Goalw [int_def] "int 0 * z = int 0";
7.118 +Goalw [Zero_int_def, int_def] "0 * z = (0::int)";
7.119 by (res_inst_tac [("z","z")] eq_Abs_Integ 1);
7.120 by (asm_simp_tac (simpset() addsimps [zmult]) 1);
7.121 -qed "zmult_int0";
7.122 +qed "zmult_0";
7.123 +Addsimps [zmult_0];
7.124
7.125 -Goalw [int_def] "int (Suc 0) * z = z";
7.126 +Goalw [One_int_def, int_def] "(1::int) * z = z";
7.127 by (res_inst_tac [("z","z")] eq_Abs_Integ 1);
7.128 by (asm_simp_tac (simpset() addsimps [zmult]) 1);
7.129 -qed "zmult_int1";
7.130 +qed "zmult_1";
7.131 +Addsimps [zmult_1];
7.132
7.133 -Goal "z * int 0 = int 0";
7.134 -by (rtac ([zmult_commute, zmult_int0] MRS trans) 1);
7.135 -qed "zmult_int0_right";
7.136 +Goal "z * 0 = (0::int)";
7.137 +by (rtac ([zmult_commute, zmult_0] MRS trans) 1);
7.138 +qed "zmult_0_right";
7.139 +Addsimps [zmult_0_right];
7.140
7.141 -Goal "z * int (Suc 0) = z";
7.142 -by (rtac ([zmult_commute, zmult_int1] MRS trans) 1);
7.143 -qed "zmult_int1_right";
7.144 -
7.145 -Addsimps [zmult_int0, zmult_int0_right, zmult_int1, zmult_int1_right];
7.146 +Goal "z * (1::int) = z";
7.147 +by (rtac ([zmult_commute, zmult_1] MRS trans) 1);
7.148 +qed "zmult_1_right";
7.149 +Addsimps [zmult_1_right];
7.150
7.151
7.152 (* Theorems about less and less_equal *)
7.153 @@ -413,12 +407,27 @@
7.154 qed "int_int_eq";
7.155 AddIffs [int_int_eq];
7.156
7.157 +Goal "(int n = 0) = (n = 0)";
7.158 +by (simp_tac (simpset() addsimps [Zero_int_def]) 1);
7.159 +qed "int_eq_0_conv";
7.160 +Addsimps [int_eq_0_conv];
7.161 +
7.162 Goal "(int m < int n) = (m<n)";
7.163 by (simp_tac (simpset() addsimps [less_iff_Suc_add, zless_iff_Suc_zadd,
7.164 zadd_int]) 1);
7.165 qed "zless_int";
7.166 Addsimps [zless_int];
7.167
7.168 +Goal "~ (int k < 0)";
7.169 +by (simp_tac (simpset() addsimps [Zero_int_def]) 1);
7.170 +qed "int_less_0_conv";
7.171 +Addsimps [int_less_0_conv];
7.172 +
7.173 +Goal "(0 < int n) = (0 < n)";
7.174 +by (simp_tac (simpset() addsimps [Zero_int_def]) 1);
7.175 +qed "zero_less_int_conv";
7.176 +Addsimps [zero_less_int_conv];
7.177 +
7.178
7.179 (*** Properties of <= ***)
7.180
7.181 @@ -427,6 +436,16 @@
7.182 qed "zle_int";
7.183 Addsimps [zle_int];
7.184
7.185 +Goal "(0 <= int n)";
7.186 +by (simp_tac (simpset() addsimps [Zero_int_def]) 1);
7.187 +qed "zero_zle_int";
7.188 +Addsimps [zero_zle_int];
7.189 +
7.190 +Goal "(int n <= 0) = (n = 0)";
7.191 +by (simp_tac (simpset() addsimps [Zero_int_def]) 1);
7.192 +qed "int_le_0_conv";
7.193 +Addsimps [int_le_0_conv];
7.194 +
7.195 Goalw [zle_def] "z <= w ==> z < w | z=(w::int)";
7.196 by (cut_facts_tac [zless_linear] 1);
7.197 by (blast_tac (claset() addEs [zless_asym]) 1);
7.198 @@ -506,11 +525,13 @@
7.199 qed "zle_zdiff_eq";
7.200
7.201 Goalw [zdiff_def] "(x-y = z) = (x = z + (y::int))";
7.202 -by (auto_tac (claset(), simpset() addsimps [zadd_assoc]));
7.203 +by (auto_tac (claset(),
7.204 + simpset() addsimps [zadd_assoc, symmetric Zero_int_def]));
7.205 qed "zdiff_eq_eq";
7.206
7.207 Goalw [zdiff_def] "(x = z-y) = (x + (y::int) = z)";
7.208 -by (auto_tac (claset(), simpset() addsimps [zadd_assoc]));
7.209 +by (auto_tac (claset(),
7.210 + simpset() addsimps [zadd_assoc, symmetric Zero_int_def]));
7.211 qed "eq_zdiff_eq";
7.212
7.213 (*This list of rewrites simplifies (in)equalities by bringing subtractions
7.214 @@ -528,7 +549,8 @@
7.215 Goal "!!w::int. (z + w' = z + w) = (w' = w)";
7.216 by Safe_tac;
7.217 by (dres_inst_tac [("f", "%x. x + (-z)")] arg_cong 1);
7.218 -by (asm_full_simp_tac (simpset() addsimps zadd_ac) 1);
7.219 +by (asm_full_simp_tac (simpset() addsimps symmetric Zero_int_def ::
7.220 + zadd_ac) 1);
7.221 qed "zadd_left_cancel";
7.222
7.223 Addsimps [zadd_left_cancel];
8.1 --- a/src/HOL/Integ/IntDef.thy Mon Oct 22 11:01:30 2001 +0200
8.2 +++ b/src/HOL/Integ/IntDef.thy Mon Oct 22 11:54:22 2001 +0200
8.3 @@ -31,7 +31,7 @@
8.4
8.5 (*For simplifying equalities*)
8.6 iszero :: int => bool
8.7 - "iszero z == z = int 0"
8.8 + "iszero z == z = (0::int)"
8.9
8.10 defs (*of overloaded constants*)
8.11
9.1 --- a/src/HOL/Integ/IntDiv.ML Mon Oct 22 11:01:30 2001 +0200
9.2 +++ b/src/HOL/Integ/IntDiv.ML Mon Oct 22 11:54:22 2001 +0200
9.3 @@ -34,21 +34,21 @@
9.4
9.5 (*** Uniqueness and monotonicity of quotients and remainders ***)
9.6
9.7 -Goal "[| b*q' + r' <= b*q + r; Numeral0 <= r'; Numeral0 < b; r < b |] \
9.8 +Goal "[| b*q' + r' <= b*q + r; 0 <= r'; 0 < b; r < b |] \
9.9 \ ==> q' <= (q::int)";
9.10 by (subgoal_tac "r' + b * (q'-q) <= r" 1);
9.11 by (simp_tac (simpset() addsimps [zdiff_zmult_distrib2]) 2);
9.12 -by (subgoal_tac "Numeral0 < b * (Numeral1 + q - q')" 1);
9.13 +by (subgoal_tac "0 < b * (1 + q - q')" 1);
9.14 by (etac order_le_less_trans 2);
9.15 by (full_simp_tac (simpset() addsimps [zdiff_zmult_distrib2,
9.16 zadd_zmult_distrib2]) 2);
9.17 -by (subgoal_tac "b * q' < b * (Numeral1 + q)" 1);
9.18 +by (subgoal_tac "b * q' < b * (1 + q)" 1);
9.19 by (full_simp_tac (simpset() addsimps [zdiff_zmult_distrib2,
9.20 zadd_zmult_distrib2]) 2);
9.21 by (asm_full_simp_tac (simpset() addsimps [zmult_zless_cancel1]) 1);
9.22 qed "unique_quotient_lemma";
9.23
9.24 -Goal "[| b*q' + r' <= b*q + r; r <= Numeral0; b < Numeral0; b < r' |] \
9.25 +Goal "[| b*q' + r' <= b*q + r; r <= 0; b < 0; b < r' |] \
9.26 \ ==> q <= (q'::int)";
9.27 by (res_inst_tac [("b", "-b"), ("r", "-r'"), ("r'", "-r")]
9.28 unique_quotient_lemma 1);
9.29 @@ -57,7 +57,7 @@
9.30 qed "unique_quotient_lemma_neg";
9.31
9.32
9.33 -Goal "[| quorem ((a,b), (q,r)); quorem ((a,b), (q',r')); b ~= Numeral0 |] \
9.34 +Goal "[| quorem ((a,b), (q,r)); quorem ((a,b), (q',r')); b ~= 0 |] \
9.35 \ ==> q = q'";
9.36 by (asm_full_simp_tac
9.37 (simpset() addsimps split_ifs@
9.38 @@ -72,7 +72,7 @@
9.39 qed "unique_quotient";
9.40
9.41
9.42 -Goal "[| quorem ((a,b), (q,r)); quorem ((a,b), (q',r')); b ~= Numeral0 |] \
9.43 +Goal "[| quorem ((a,b), (q,r)); quorem ((a,b), (q',r')); b ~= 0 |] \
9.44 \ ==> r = r'";
9.45 by (subgoal_tac "q = q'" 1);
9.46 by (blast_tac (claset() addIs [unique_quotient]) 2);
9.47 @@ -83,9 +83,9 @@
9.48 (*** Correctness of posDivAlg, the division algorithm for a>=0 and b>0 ***)
9.49
9.50
9.51 -Goal "adjust a b (q,r) = (let diff = r-b in \
9.52 -\ if Numeral0 <= diff then (2*q + Numeral1, diff) \
9.53 -\ else (2*q, r))";
9.54 +Goal "adjust b (q,r) = (let diff = r-b in \
9.55 +\ if 0 <= diff then (2*q + 1, diff) \
9.56 +\ else (2*q, r))";
9.57 by (simp_tac (simpset() addsimps [Let_def,adjust_def]) 1);
9.58 qed "adjust_eq";
9.59 Addsimps [adjust_eq];
9.60 @@ -101,9 +101,9 @@
9.61 bind_thm ("posDivAlg_raw_eqn", lemma RS hd posDivAlg.simps);
9.62
9.63 (**use with simproc to avoid re-proving the premise*)
9.64 -Goal "Numeral0 < b ==> \
9.65 +Goal "0 < b ==> \
9.66 \ posDivAlg (a,b) = \
9.67 -\ (if a<b then (Numeral0,a) else adjust a b (posDivAlg(a, 2*b)))";
9.68 +\ (if a<b then (0,a) else adjust b (posDivAlg(a, 2*b)))";
9.69 by (rtac (posDivAlg_raw_eqn RS trans) 1);
9.70 by (Asm_simp_tac 1);
9.71 qed "posDivAlg_eqn";
9.72 @@ -112,7 +112,7 @@
9.73
9.74
9.75 (*Correctness of posDivAlg: it computes quotients correctly*)
9.76 -Goal "Numeral0 <= a --> Numeral0 < b --> quorem ((a, b), posDivAlg (a, b))";
9.77 +Goal "0 <= a --> 0 < b --> quorem ((a, b), posDivAlg (a, b))";
9.78 by (induct_thm_tac posDivAlg_induct "a b" 1);
9.79 by Auto_tac;
9.80 by (ALLGOALS (asm_full_simp_tac (simpset() addsimps [quorem_def])));
9.81 @@ -139,9 +139,9 @@
9.82 bind_thm ("negDivAlg_raw_eqn", lemma RS hd negDivAlg.simps);
9.83
9.84 (**use with simproc to avoid re-proving the premise*)
9.85 -Goal "Numeral0 < b ==> \
9.86 +Goal "0 < b ==> \
9.87 \ negDivAlg (a,b) = \
9.88 -\ (if Numeral0<=a+b then (-1,a+b) else adjust a b (negDivAlg(a, 2*b)))";
9.89 +\ (if 0<=a+b then (-1,a+b) else adjust b (negDivAlg(a, 2*b)))";
9.90 by (rtac (negDivAlg_raw_eqn RS trans) 1);
9.91 by (Asm_simp_tac 1);
9.92 qed "negDivAlg_eqn";
9.93 @@ -151,7 +151,7 @@
9.94
9.95 (*Correctness of negDivAlg: it computes quotients correctly
9.96 It doesn't work if a=0 because the 0/b=0 rather than -1*)
9.97 -Goal "a < Numeral0 --> Numeral0 < b --> quorem ((a, b), negDivAlg (a, b))";
9.98 +Goal "a < 0 --> 0 < b --> quorem ((a, b), negDivAlg (a, b))";
9.99 by (induct_thm_tac negDivAlg_induct "a b" 1);
9.100 by Auto_tac;
9.101 by (ALLGOALS (asm_full_simp_tac (simpset() addsimps [quorem_def])));
9.102 @@ -168,18 +168,18 @@
9.103 (*** Existence shown by proving the division algorithm to be correct ***)
9.104
9.105 (*the case a=0*)
9.106 -Goal "b ~= Numeral0 ==> quorem ((Numeral0,b), (Numeral0,Numeral0))";
9.107 +Goal "b ~= 0 ==> quorem ((0,b), (0,0))";
9.108 by (auto_tac (claset(),
9.109 simpset() addsimps [quorem_def, linorder_neq_iff]));
9.110 qed "quorem_0";
9.111
9.112 -Goal "posDivAlg (Numeral0, b) = (Numeral0, Numeral0)";
9.113 +Goal "posDivAlg (0, b) = (0, 0)";
9.114 by (stac posDivAlg_raw_eqn 1);
9.115 by Auto_tac;
9.116 qed "posDivAlg_0";
9.117 Addsimps [posDivAlg_0];
9.118
9.119 -Goal "negDivAlg (-1, b) = (-1, b-Numeral1)";
9.120 +Goal "negDivAlg (-1, b) = (-1, b - 1)";
9.121 by (stac negDivAlg_raw_eqn 1);
9.122 by Auto_tac;
9.123 qed "negDivAlg_minus1";
9.124 @@ -194,7 +194,7 @@
9.125 by (auto_tac (claset(), simpset() addsimps split_ifs@[quorem_def]));
9.126 qed "quorem_neg";
9.127
9.128 -Goal "b ~= Numeral0 ==> quorem ((a,b), divAlg(a,b))";
9.129 +Goal "b ~= 0 ==> quorem ((a,b), divAlg(a,b))";
9.130 by (auto_tac (claset(),
9.131 simpset() addsimps [quorem_0, divAlg_def]));
9.132 by (REPEAT_FIRST (resolve_tac [quorem_neg, posDivAlg_correct,
9.133 @@ -206,11 +206,11 @@
9.134 (** Arbitrary definitions for division by zero. Useful to simplify
9.135 certain equations **)
9.136
9.137 -Goal "a div (Numeral0::int) = Numeral0";
9.138 +Goal "a div (0::int) = 0";
9.139 by (simp_tac (simpset() addsimps [div_def, divAlg_def, posDivAlg_raw_eqn]) 1);
9.140 qed "DIVISION_BY_ZERO_ZDIV"; (*NOT for adding to default simpset*)
9.141
9.142 -Goal "a mod (Numeral0::int) = a";
9.143 +Goal "a mod (0::int) = a";
9.144 by (simp_tac (simpset() addsimps [mod_def, divAlg_def, posDivAlg_raw_eqn]) 1);
9.145 qed "DIVISION_BY_ZERO_ZMOD"; (*NOT for adding to default simpset*)
9.146
9.147 @@ -222,20 +222,20 @@
9.148 (** Basic laws about division and remainder **)
9.149
9.150 Goal "(a::int) = b * (a div b) + (a mod b)";
9.151 -by (zdiv_undefined_case_tac "b = Numeral0" 1);
9.152 +by (zdiv_undefined_case_tac "b = 0" 1);
9.153 by (cut_inst_tac [("a","a"),("b","b")] divAlg_correct 1);
9.154 by (auto_tac (claset(),
9.155 simpset() addsimps [quorem_def, div_def, mod_def]));
9.156 qed "zmod_zdiv_equality";
9.157
9.158 -Goal "(Numeral0::int) < b ==> Numeral0 <= a mod b & a mod b < b";
9.159 +Goal "(0::int) < b ==> 0 <= a mod b & a mod b < b";
9.160 by (cut_inst_tac [("a","a"),("b","b")] divAlg_correct 1);
9.161 by (auto_tac (claset(),
9.162 simpset() addsimps [quorem_def, mod_def]));
9.163 bind_thm ("pos_mod_sign", result() RS conjunct1);
9.164 bind_thm ("pos_mod_bound", result() RS conjunct2);
9.165
9.166 -Goal "b < (Numeral0::int) ==> a mod b <= Numeral0 & b < a mod b";
9.167 +Goal "b < (0::int) ==> a mod b <= 0 & b < a mod b";
9.168 by (cut_inst_tac [("a","a"),("b","b")] divAlg_correct 1);
9.169 by (auto_tac (claset(),
9.170 simpset() addsimps [quorem_def, div_def, mod_def]));
9.171 @@ -245,7 +245,7 @@
9.172
9.173 (** proving general properties of div and mod **)
9.174
9.175 -Goal "b ~= Numeral0 ==> quorem ((a, b), (a div b, a mod b))";
9.176 +Goal "b ~= 0 ==> quorem ((a, b), (a div b, a mod b))";
9.177 by (cut_inst_tac [("a","a"),("b","b")] zmod_zdiv_equality 1);
9.178 by (auto_tac
9.179 (claset(),
9.180 @@ -254,42 +254,42 @@
9.181 neg_mod_sign, neg_mod_bound]));
9.182 qed "quorem_div_mod";
9.183
9.184 -Goal "[| quorem((a,b),(q,r)); b ~= Numeral0 |] ==> a div b = q";
9.185 +Goal "[| quorem((a,b),(q,r)); b ~= 0 |] ==> a div b = q";
9.186 by (asm_simp_tac (simpset() addsimps [quorem_div_mod RS unique_quotient]) 1);
9.187 qed "quorem_div";
9.188
9.189 -Goal "[| quorem((a,b),(q,r)); b ~= Numeral0 |] ==> a mod b = r";
9.190 +Goal "[| quorem((a,b),(q,r)); b ~= 0 |] ==> a mod b = r";
9.191 by (asm_simp_tac (simpset() addsimps [quorem_div_mod RS unique_remainder]) 1);
9.192 qed "quorem_mod";
9.193
9.194 -Goal "[| (Numeral0::int) <= a; a < b |] ==> a div b = Numeral0";
9.195 +Goal "[| (0::int) <= a; a < b |] ==> a div b = 0";
9.196 by (rtac quorem_div 1);
9.197 by (auto_tac (claset(), simpset() addsimps [quorem_def]));
9.198 qed "div_pos_pos_trivial";
9.199
9.200 -Goal "[| a <= (Numeral0::int); b < a |] ==> a div b = Numeral0";
9.201 +Goal "[| a <= (0::int); b < a |] ==> a div b = 0";
9.202 by (rtac quorem_div 1);
9.203 by (auto_tac (claset(), simpset() addsimps [quorem_def]));
9.204 qed "div_neg_neg_trivial";
9.205
9.206 -Goal "[| (Numeral0::int) < a; a+b <= Numeral0 |] ==> a div b = -1";
9.207 +Goal "[| (0::int) < a; a+b <= 0 |] ==> a div b = -1";
9.208 by (rtac quorem_div 1);
9.209 by (auto_tac (claset(), simpset() addsimps [quorem_def]));
9.210 qed "div_pos_neg_trivial";
9.211
9.212 -(*There is no div_neg_pos_trivial because Numeral0 div b = Numeral0 would supersede it*)
9.213 +(*There is no div_neg_pos_trivial because 0 div b = 0 would supersede it*)
9.214
9.215 -Goal "[| (Numeral0::int) <= a; a < b |] ==> a mod b = a";
9.216 -by (res_inst_tac [("q","Numeral0")] quorem_mod 1);
9.217 +Goal "[| (0::int) <= a; a < b |] ==> a mod b = a";
9.218 +by (res_inst_tac [("q","0")] quorem_mod 1);
9.219 by (auto_tac (claset(), simpset() addsimps [quorem_def]));
9.220 qed "mod_pos_pos_trivial";
9.221
9.222 -Goal "[| a <= (Numeral0::int); b < a |] ==> a mod b = a";
9.223 -by (res_inst_tac [("q","Numeral0")] quorem_mod 1);
9.224 +Goal "[| a <= (0::int); b < a |] ==> a mod b = a";
9.225 +by (res_inst_tac [("q","0")] quorem_mod 1);
9.226 by (auto_tac (claset(), simpset() addsimps [quorem_def]));
9.227 qed "mod_neg_neg_trivial";
9.228
9.229 -Goal "[| (Numeral0::int) < a; a+b <= Numeral0 |] ==> a mod b = a+b";
9.230 +Goal "[| (0::int) < a; a+b <= 0 |] ==> a mod b = a+b";
9.231 by (res_inst_tac [("q","-1")] quorem_mod 1);
9.232 by (auto_tac (claset(), simpset() addsimps [quorem_def]));
9.233 qed "mod_pos_neg_trivial";
9.234 @@ -299,7 +299,7 @@
9.235
9.236 (*Simpler laws such as -a div b = -(a div b) FAIL, but see just below*)
9.237 Goal "(-a) div (-b) = a div (b::int)";
9.238 -by (zdiv_undefined_case_tac "b = Numeral0" 1);
9.239 +by (zdiv_undefined_case_tac "b = 0" 1);
9.240 by (stac ((simplify(simpset()) (quorem_div_mod RS quorem_neg))
9.241 RS quorem_div) 1);
9.242 by Auto_tac;
9.243 @@ -308,7 +308,7 @@
9.244
9.245 (*Simpler laws such as -a mod b = -(a mod b) FAIL, but see just below*)
9.246 Goal "(-a) mod (-b) = - (a mod (b::int))";
9.247 -by (zdiv_undefined_case_tac "b = Numeral0" 1);
9.248 +by (zdiv_undefined_case_tac "b = 0" 1);
9.249 by (stac ((simplify(simpset()) (quorem_div_mod RS quorem_neg))
9.250 RS quorem_mod) 1);
9.251 by Auto_tac;
9.252 @@ -319,8 +319,8 @@
9.253 (*** div, mod and unary minus ***)
9.254
9.255 Goal "quorem((a,b),(q,r)) \
9.256 -\ ==> quorem ((-a,b), (if r=Numeral0 then -q else -q-Numeral1), \
9.257 -\ (if r=Numeral0 then Numeral0 else b-r))";
9.258 +\ ==> quorem ((-a,b), (if r=0 then -q else -q - 1), \
9.259 +\ (if r=0 then 0 else b-r))";
9.260 by (auto_tac
9.261 (claset(),
9.262 simpset() addsimps split_ifs@
9.263 @@ -328,14 +328,14 @@
9.264 zdiff_zmult_distrib2]));
9.265 val lemma = result();
9.266
9.267 -Goal "b ~= (Numeral0::int) \
9.268 +Goal "b ~= (0::int) \
9.269 \ ==> (-a) div b = \
9.270 -\ (if a mod b = Numeral0 then - (a div b) else - (a div b) - Numeral1)";
9.271 +\ (if a mod b = 0 then - (a div b) else - (a div b) - 1)";
9.272 by (blast_tac (claset() addIs [quorem_div_mod RS lemma RS quorem_div]) 1);
9.273 qed "zdiv_zminus1_eq_if";
9.274
9.275 -Goal "(-a::int) mod b = (if a mod b = Numeral0 then Numeral0 else b - (a mod b))";
9.276 -by (zdiv_undefined_case_tac "b = Numeral0" 1);
9.277 +Goal "(-a::int) mod b = (if a mod b = 0 then 0 else b - (a mod b))";
9.278 +by (zdiv_undefined_case_tac "b = 0" 1);
9.279 by (blast_tac (claset() addIs [quorem_div_mod RS lemma RS quorem_mod]) 1);
9.280 qed "zmod_zminus1_eq_if";
9.281
9.282 @@ -349,32 +349,32 @@
9.283 by Auto_tac;
9.284 qed "zmod_zminus2";
9.285
9.286 -Goal "b ~= (Numeral0::int) \
9.287 +Goal "b ~= (0::int) \
9.288 \ ==> a div (-b) = \
9.289 -\ (if a mod b = Numeral0 then - (a div b) else - (a div b) - Numeral1)";
9.290 +\ (if a mod b = 0 then - (a div b) else - (a div b) - 1)";
9.291 by (asm_simp_tac (simpset() addsimps [zdiv_zminus1_eq_if, zdiv_zminus2]) 1);
9.292 qed "zdiv_zminus2_eq_if";
9.293
9.294 -Goal "a mod (-b::int) = (if a mod b = Numeral0 then Numeral0 else (a mod b) - b)";
9.295 +Goal "a mod (-b::int) = (if a mod b = 0 then 0 else (a mod b) - b)";
9.296 by (asm_simp_tac (simpset() addsimps [zmod_zminus1_eq_if, zmod_zminus2]) 1);
9.297 qed "zmod_zminus2_eq_if";
9.298
9.299
9.300 (*** division of a number by itself ***)
9.301
9.302 -Goal "[| (Numeral0::int) < a; a = r + a*q; r < a |] ==> Numeral1 <= q";
9.303 -by (subgoal_tac "Numeral0 < a*q" 1);
9.304 +Goal "[| (0::int) < a; a = r + a*q; r < a |] ==> 1 <= q";
9.305 +by (subgoal_tac "0 < a*q" 1);
9.306 by (arith_tac 2);
9.307 by (asm_full_simp_tac (simpset() addsimps [int_0_less_mult_iff]) 1);
9.308 val lemma1 = result();
9.309
9.310 -Goal "[| (Numeral0::int) < a; a = r + a*q; Numeral0 <= r |] ==> q <= Numeral1";
9.311 -by (subgoal_tac "Numeral0 <= a*(Numeral1-q)" 1);
9.312 +Goal "[| (0::int) < a; a = r + a*q; 0 <= r |] ==> q <= 1";
9.313 +by (subgoal_tac "0 <= a*(1-q)" 1);
9.314 by (asm_simp_tac (simpset() addsimps [zdiff_zmult_distrib2]) 2);
9.315 by (asm_full_simp_tac (simpset() addsimps [int_0_le_mult_iff]) 1);
9.316 val lemma2 = result();
9.317
9.318 -Goal "[| quorem((a,a),(q,r)); a ~= (Numeral0::int) |] ==> q = Numeral1";
9.319 +Goal "[| quorem((a,a),(q,r)); a ~= (0::int) |] ==> q = 1";
9.320 by (asm_full_simp_tac
9.321 (simpset() addsimps split_ifs@[quorem_def, linorder_neq_iff]) 1);
9.322 by (rtac order_antisym 1);
9.323 @@ -386,20 +386,20 @@
9.324 simpset() addsimps [zadd_commute, zmult_zminus]) 1));
9.325 qed "self_quotient";
9.326
9.327 -Goal "[| quorem((a,a),(q,r)); a ~= (Numeral0::int) |] ==> r = Numeral0";
9.328 +Goal "[| quorem((a,a),(q,r)); a ~= (0::int) |] ==> r = 0";
9.329 by (ftac self_quotient 1);
9.330 by (assume_tac 1);
9.331 by (asm_full_simp_tac (simpset() addsimps [quorem_def]) 1);
9.332 qed "self_remainder";
9.333
9.334 -Goal "a ~= Numeral0 ==> a div a = (Numeral1::int)";
9.335 +Goal "a ~= 0 ==> a div a = (1::int)";
9.336 by (asm_simp_tac (simpset() addsimps [quorem_div_mod RS self_quotient]) 1);
9.337 qed "zdiv_self";
9.338 Addsimps [zdiv_self];
9.339
9.340 (*Here we have 0 mod 0 = 0, also assumed by Knuth (who puts m mod 0 = 0) *)
9.341 -Goal "a mod a = (Numeral0::int)";
9.342 -by (zdiv_undefined_case_tac "a = Numeral0" 1);
9.343 +Goal "a mod a = (0::int)";
9.344 +by (zdiv_undefined_case_tac "a = 0" 1);
9.345 by (asm_simp_tac (simpset() addsimps [quorem_div_mod RS self_remainder]) 1);
9.346 qed "zmod_self";
9.347 Addsimps [zmod_self];
9.348 @@ -407,65 +407,65 @@
9.349
9.350 (*** Computation of division and remainder ***)
9.351
9.352 -Goal "(Numeral0::int) div b = Numeral0";
9.353 +Goal "(0::int) div b = 0";
9.354 by (simp_tac (simpset() addsimps [div_def, divAlg_def]) 1);
9.355 qed "zdiv_zero";
9.356
9.357 -Goal "(Numeral0::int) < b ==> -1 div b = -1";
9.358 +Goal "(0::int) < b ==> -1 div b = -1";
9.359 by (asm_simp_tac (simpset() addsimps [div_def, divAlg_def]) 1);
9.360 qed "div_eq_minus1";
9.361
9.362 -Goal "(Numeral0::int) mod b = Numeral0";
9.363 +Goal "(0::int) mod b = 0";
9.364 by (simp_tac (simpset() addsimps [mod_def, divAlg_def]) 1);
9.365 qed "zmod_zero";
9.366
9.367 Addsimps [zdiv_zero, zmod_zero];
9.368
9.369 -Goal "(Numeral0::int) < b ==> -1 div b = -1";
9.370 +Goal "(0::int) < b ==> -1 div b = -1";
9.371 by (asm_simp_tac (simpset() addsimps [div_def, divAlg_def]) 1);
9.372 qed "zdiv_minus1";
9.373
9.374 -Goal "(Numeral0::int) < b ==> -1 mod b = b-Numeral1";
9.375 +Goal "(0::int) < b ==> -1 mod b = b - 1";
9.376 by (asm_simp_tac (simpset() addsimps [mod_def, divAlg_def]) 1);
9.377 qed "zmod_minus1";
9.378
9.379 (** a positive, b positive **)
9.380
9.381 -Goal "[| Numeral0 < a; Numeral0 <= b |] ==> a div b = fst (posDivAlg(a,b))";
9.382 +Goal "[| 0 < a; 0 <= b |] ==> a div b = fst (posDivAlg(a,b))";
9.383 by (asm_simp_tac (simpset() addsimps [div_def, divAlg_def]) 1);
9.384 qed "div_pos_pos";
9.385
9.386 -Goal "[| Numeral0 < a; Numeral0 <= b |] ==> a mod b = snd (posDivAlg(a,b))";
9.387 +Goal "[| 0 < a; 0 <= b |] ==> a mod b = snd (posDivAlg(a,b))";
9.388 by (asm_simp_tac (simpset() addsimps [mod_def, divAlg_def]) 1);
9.389 qed "mod_pos_pos";
9.390
9.391 (** a negative, b positive **)
9.392
9.393 -Goal "[| a < Numeral0; Numeral0 < b |] ==> a div b = fst (negDivAlg(a,b))";
9.394 +Goal "[| a < 0; 0 < b |] ==> a div b = fst (negDivAlg(a,b))";
9.395 by (asm_simp_tac (simpset() addsimps [div_def, divAlg_def]) 1);
9.396 qed "div_neg_pos";
9.397
9.398 -Goal "[| a < Numeral0; Numeral0 < b |] ==> a mod b = snd (negDivAlg(a,b))";
9.399 +Goal "[| a < 0; 0 < b |] ==> a mod b = snd (negDivAlg(a,b))";
9.400 by (asm_simp_tac (simpset() addsimps [mod_def, divAlg_def]) 1);
9.401 qed "mod_neg_pos";
9.402
9.403 (** a positive, b negative **)
9.404
9.405 -Goal "[| Numeral0 < a; b < Numeral0 |] ==> a div b = fst (negateSnd(negDivAlg(-a,-b)))";
9.406 +Goal "[| 0 < a; b < 0 |] ==> a div b = fst (negateSnd(negDivAlg(-a,-b)))";
9.407 by (asm_simp_tac (simpset() addsimps [div_def, divAlg_def]) 1);
9.408 qed "div_pos_neg";
9.409
9.410 -Goal "[| Numeral0 < a; b < Numeral0 |] ==> a mod b = snd (negateSnd(negDivAlg(-a,-b)))";
9.411 +Goal "[| 0 < a; b < 0 |] ==> a mod b = snd (negateSnd(negDivAlg(-a,-b)))";
9.412 by (asm_simp_tac (simpset() addsimps [mod_def, divAlg_def]) 1);
9.413 qed "mod_pos_neg";
9.414
9.415 (** a negative, b negative **)
9.416
9.417 -Goal "[| a < Numeral0; b <= Numeral0 |] ==> a div b = fst (negateSnd(posDivAlg(-a,-b)))";
9.418 +Goal "[| a < 0; b <= 0 |] ==> a div b = fst (negateSnd(posDivAlg(-a,-b)))";
9.419 by (asm_simp_tac (simpset() addsimps [div_def, divAlg_def]) 1);
9.420 qed "div_neg_neg";
9.421
9.422 -Goal "[| a < Numeral0; b <= Numeral0 |] ==> a mod b = snd (negateSnd(posDivAlg(-a,-b)))";
9.423 +Goal "[| a < 0; b <= 0 |] ==> a mod b = snd (negateSnd(posDivAlg(-a,-b)))";
9.424 by (asm_simp_tac (simpset() addsimps [mod_def, divAlg_def]) 1);
9.425 qed "mod_neg_neg";
9.426
9.427 @@ -478,20 +478,20 @@
9.428
9.429 (** Special-case simplification **)
9.430
9.431 -Goal "a mod (Numeral1::int) = Numeral0";
9.432 -by (cut_inst_tac [("a","a"),("b","Numeral1")] pos_mod_sign 1);
9.433 -by (cut_inst_tac [("a","a"),("b","Numeral1")] pos_mod_bound 2);
9.434 +Goal "a mod (1::int) = 0";
9.435 +by (cut_inst_tac [("a","a"),("b","1")] pos_mod_sign 1);
9.436 +by (cut_inst_tac [("a","a"),("b","1")] pos_mod_bound 2);
9.437 by Auto_tac;
9.438 qed "zmod_1";
9.439 Addsimps [zmod_1];
9.440
9.441 -Goal "a div (Numeral1::int) = a";
9.442 -by (cut_inst_tac [("a","a"),("b","Numeral1")] zmod_zdiv_equality 1);
9.443 +Goal "a div (1::int) = a";
9.444 +by (cut_inst_tac [("a","a"),("b","1")] zmod_zdiv_equality 1);
9.445 by Auto_tac;
9.446 qed "zdiv_1";
9.447 Addsimps [zdiv_1];
9.448
9.449 -Goal "a mod (-1::int) = Numeral0";
9.450 +Goal "a mod (-1::int) = 0";
9.451 by (cut_inst_tac [("a","a"),("b","-1")] neg_mod_sign 1);
9.452 by (cut_inst_tac [("a","a"),("b","-1")] neg_mod_bound 2);
9.453 by Auto_tac;
9.454 @@ -504,10 +504,19 @@
9.455 qed "zdiv_minus1_right";
9.456 Addsimps [zdiv_minus1_right];
9.457
9.458 +(** The last remaining cases: 1 div z and 1 mod z **)
9.459 +
9.460 +Addsimps (map (fn th => int_0_less_1 RS inst "b" "number_of ?w" th)
9.461 + [div_pos_pos, div_pos_neg, mod_pos_pos, mod_pos_neg]);
9.462 +
9.463 +Addsimps (map (read_instantiate_sg (sign_of (the_context ()))
9.464 + [("a", "1"), ("b", "number_of ?w")])
9.465 + [posDivAlg_eqn, negDivAlg_eqn]);
9.466 +
9.467
9.468 (*** Monotonicity in the first argument (divisor) ***)
9.469
9.470 -Goal "[| a <= a'; Numeral0 < (b::int) |] ==> a div b <= a' div b";
9.471 +Goal "[| a <= a'; 0 < (b::int) |] ==> a div b <= a' div b";
9.472 by (cut_inst_tac [("a","a"),("b","b")] zmod_zdiv_equality 1);
9.473 by (cut_inst_tac [("a","a'"),("b","b")] zmod_zdiv_equality 1);
9.474 by (rtac unique_quotient_lemma 1);
9.475 @@ -516,7 +525,7 @@
9.476 by (ALLGOALS (asm_simp_tac (simpset() addsimps [pos_mod_sign,pos_mod_bound])));
9.477 qed "zdiv_mono1";
9.478
9.479 -Goal "[| a <= a'; (b::int) < Numeral0 |] ==> a' div b <= a div b";
9.480 +Goal "[| a <= a'; (b::int) < 0 |] ==> a' div b <= a div b";
9.481 by (cut_inst_tac [("a","a"),("b","b")] zmod_zdiv_equality 1);
9.482 by (cut_inst_tac [("a","a'"),("b","b")] zmod_zdiv_equality 1);
9.483 by (rtac unique_quotient_lemma_neg 1);
9.484 @@ -528,14 +537,14 @@
9.485
9.486 (*** Monotonicity in the second argument (dividend) ***)
9.487
9.488 -Goal "[| b*q + r = b'*q' + r'; Numeral0 <= b'*q' + r'; \
9.489 -\ r' < b'; Numeral0 <= r; Numeral0 < b'; b' <= b |] \
9.490 +Goal "[| b*q + r = b'*q' + r'; 0 <= b'*q' + r'; \
9.491 +\ r' < b'; 0 <= r; 0 < b'; b' <= b |] \
9.492 \ ==> q <= (q'::int)";
9.493 -by (subgoal_tac "Numeral0 <= q'" 1);
9.494 - by (subgoal_tac "Numeral0 < b'*(q' + Numeral1)" 2);
9.495 +by (subgoal_tac "0 <= q'" 1);
9.496 + by (subgoal_tac "0 < b'*(q' + 1)" 2);
9.497 by (asm_simp_tac (simpset() addsimps [zadd_zmult_distrib2]) 3);
9.498 by (asm_full_simp_tac (simpset() addsimps [int_0_less_mult_iff]) 2);
9.499 -by (subgoal_tac "b*q < b*(q' + Numeral1)" 1);
9.500 +by (subgoal_tac "b*q < b*(q' + 1)" 1);
9.501 by (asm_full_simp_tac (simpset() addsimps [zmult_zless_cancel1]) 1);
9.502 by (subgoal_tac "b*q = r' - r + b'*q'" 1);
9.503 by (Simp_tac 2);
9.504 @@ -545,9 +554,9 @@
9.505 by Auto_tac;
9.506 qed "zdiv_mono2_lemma";
9.507
9.508 -Goal "[| (Numeral0::int) <= a; Numeral0 < b'; b' <= b |] \
9.509 +Goal "[| (0::int) <= a; 0 < b'; b' <= b |] \
9.510 \ ==> a div b <= a div b'";
9.511 -by (subgoal_tac "b ~= Numeral0" 1);
9.512 +by (subgoal_tac "b ~= 0" 1);
9.513 by (arith_tac 2);
9.514 by (cut_inst_tac [("a","a"),("b","b")] zmod_zdiv_equality 1);
9.515 by (cut_inst_tac [("a","a"),("b","b'")] zmod_zdiv_equality 1);
9.516 @@ -557,14 +566,14 @@
9.517 by (ALLGOALS (asm_simp_tac (simpset() addsimps [pos_mod_sign,pos_mod_bound])));
9.518 qed "zdiv_mono2";
9.519
9.520 -Goal "[| b*q + r = b'*q' + r'; b'*q' + r' < Numeral0; \
9.521 -\ r < b; Numeral0 <= r'; Numeral0 < b'; b' <= b |] \
9.522 +Goal "[| b*q + r = b'*q' + r'; b'*q' + r' < 0; \
9.523 +\ r < b; 0 <= r'; 0 < b'; b' <= b |] \
9.524 \ ==> q' <= (q::int)";
9.525 -by (subgoal_tac "q' < Numeral0" 1);
9.526 - by (subgoal_tac "b'*q' < Numeral0" 2);
9.527 +by (subgoal_tac "q' < 0" 1);
9.528 + by (subgoal_tac "b'*q' < 0" 2);
9.529 by (arith_tac 3);
9.530 by (asm_full_simp_tac (simpset() addsimps [zmult_less_0_iff]) 2);
9.531 -by (subgoal_tac "b*q' < b*(q + Numeral1)" 1);
9.532 +by (subgoal_tac "b*q' < b*(q + 1)" 1);
9.533 by (asm_full_simp_tac (simpset() addsimps [zmult_zless_cancel1]) 1);
9.534 by (asm_simp_tac (simpset() addsimps [zadd_zmult_distrib2]) 1);
9.535 by (subgoal_tac "b*q' <= b'*q'" 1);
9.536 @@ -574,7 +583,7 @@
9.537 by (arith_tac 1);
9.538 qed "zdiv_mono2_neg_lemma";
9.539
9.540 -Goal "[| a < (Numeral0::int); Numeral0 < b'; b' <= b |] \
9.541 +Goal "[| a < (0::int); 0 < b'; b' <= b |] \
9.542 \ ==> a div b' <= a div b";
9.543 by (cut_inst_tac [("a","a"),("b","b")] zmod_zdiv_equality 1);
9.544 by (cut_inst_tac [("a","a"),("b","b'")] zmod_zdiv_equality 1);
9.545 @@ -589,7 +598,7 @@
9.546
9.547 (** proving (a*b) div c = a * (b div c) + a * (b mod c) **)
9.548
9.549 -Goal "[| quorem((b,c),(q,r)); c ~= Numeral0 |] \
9.550 +Goal "[| quorem((b,c),(q,r)); c ~= 0 |] \
9.551 \ ==> quorem ((a*b, c), (a*q + a*r div c, a*r mod c))";
9.552 by (auto_tac
9.553 (claset(),
9.554 @@ -602,12 +611,12 @@
9.555 val lemma = result();
9.556
9.557 Goal "(a*b) div c = a*(b div c) + a*(b mod c) div (c::int)";
9.558 -by (zdiv_undefined_case_tac "c = Numeral0" 1);
9.559 +by (zdiv_undefined_case_tac "c = 0" 1);
9.560 by (blast_tac (claset() addIs [quorem_div_mod RS lemma RS quorem_div]) 1);
9.561 qed "zdiv_zmult1_eq";
9.562
9.563 Goal "(a*b) mod c = a*(b mod c) mod (c::int)";
9.564 -by (zdiv_undefined_case_tac "c = Numeral0" 1);
9.565 +by (zdiv_undefined_case_tac "c = 0" 1);
9.566 by (blast_tac (claset() addIs [quorem_div_mod RS lemma RS quorem_mod]) 1);
9.567 qed "zmod_zmult1_eq";
9.568
9.569 @@ -623,27 +632,27 @@
9.570 by (rtac zmod_zmult1_eq 1);
9.571 qed "zmod_zmult_distrib";
9.572
9.573 -Goal "b ~= (Numeral0::int) ==> (a*b) div b = a";
9.574 +Goal "b ~= (0::int) ==> (a*b) div b = a";
9.575 by (asm_simp_tac (simpset() addsimps [zdiv_zmult1_eq]) 1);
9.576 qed "zdiv_zmult_self1";
9.577
9.578 -Goal "b ~= (Numeral0::int) ==> (b*a) div b = a";
9.579 +Goal "b ~= (0::int) ==> (b*a) div b = a";
9.580 by (stac zmult_commute 1 THEN etac zdiv_zmult_self1 1);
9.581 qed "zdiv_zmult_self2";
9.582
9.583 Addsimps [zdiv_zmult_self1, zdiv_zmult_self2];
9.584
9.585 -Goal "(a*b) mod b = (Numeral0::int)";
9.586 +Goal "(a*b) mod b = (0::int)";
9.587 by (simp_tac (simpset() addsimps [zmod_zmult1_eq]) 1);
9.588 qed "zmod_zmult_self1";
9.589
9.590 -Goal "(b*a) mod b = (Numeral0::int)";
9.591 +Goal "(b*a) mod b = (0::int)";
9.592 by (simp_tac (simpset() addsimps [zmult_commute, zmod_zmult1_eq]) 1);
9.593 qed "zmod_zmult_self2";
9.594
9.595 Addsimps [zmod_zmult_self1, zmod_zmult_self2];
9.596
9.597 -Goal "(m mod d = Numeral0) = (EX q::int. m = d*q)";
9.598 +Goal "(m mod d = 0) = (EX q::int. m = d*q)";
9.599 by (cut_inst_tac [("a","m"),("b","d")] zmod_zdiv_equality 1);
9.600 by Auto_tac;
9.601 qed "zmod_eq_0_iff";
9.602 @@ -652,7 +661,7 @@
9.603
9.604 (** proving (a+b) div c = a div c + b div c + ((a mod c + b mod c) div c) **)
9.605
9.606 -Goal "[| quorem((a,c),(aq,ar)); quorem((b,c),(bq,br)); c ~= Numeral0 |] \
9.607 +Goal "[| quorem((a,c),(aq,ar)); quorem((b,c),(bq,br)); c ~= 0 |] \
9.608 \ ==> quorem ((a+b, c), (aq + bq + (ar+br) div c, (ar+br) mod c))";
9.609 by (auto_tac
9.610 (claset(),
9.611 @@ -666,19 +675,19 @@
9.612
9.613 (*NOT suitable for rewriting: the RHS has an instance of the LHS*)
9.614 Goal "(a+b) div (c::int) = a div c + b div c + ((a mod c + b mod c) div c)";
9.615 -by (zdiv_undefined_case_tac "c = Numeral0" 1);
9.616 +by (zdiv_undefined_case_tac "c = 0" 1);
9.617 by (blast_tac (claset() addIs [[quorem_div_mod,quorem_div_mod]
9.618 MRS lemma RS quorem_div]) 1);
9.619 qed "zdiv_zadd1_eq";
9.620
9.621 Goal "(a+b) mod (c::int) = (a mod c + b mod c) mod c";
9.622 -by (zdiv_undefined_case_tac "c = Numeral0" 1);
9.623 +by (zdiv_undefined_case_tac "c = 0" 1);
9.624 by (blast_tac (claset() addIs [[quorem_div_mod,quorem_div_mod]
9.625 MRS lemma RS quorem_mod]) 1);
9.626 qed "zmod_zadd1_eq";
9.627
9.628 -Goal "(a mod b) div b = (Numeral0::int)";
9.629 -by (zdiv_undefined_case_tac "b = Numeral0" 1);
9.630 +Goal "(a mod b) div b = (0::int)";
9.631 +by (zdiv_undefined_case_tac "b = 0" 1);
9.632 by (auto_tac (claset(),
9.633 simpset() addsimps [linorder_neq_iff,
9.634 pos_mod_sign, pos_mod_bound, div_pos_pos_trivial,
9.635 @@ -687,7 +696,7 @@
9.636 Addsimps [mod_div_trivial];
9.637
9.638 Goal "(a mod b) mod b = a mod (b::int)";
9.639 -by (zdiv_undefined_case_tac "b = Numeral0" 1);
9.640 +by (zdiv_undefined_case_tac "b = 0" 1);
9.641 by (auto_tac (claset(),
9.642 simpset() addsimps [linorder_neq_iff,
9.643 pos_mod_sign, pos_mod_bound, mod_pos_pos_trivial,
9.644 @@ -710,22 +719,22 @@
9.645 qed "zmod_zadd_right_eq";
9.646
9.647
9.648 -Goal "a ~= (Numeral0::int) ==> (a+b) div a = b div a + Numeral1";
9.649 +Goal "a ~= (0::int) ==> (a+b) div a = b div a + 1";
9.650 by (asm_simp_tac (simpset() addsimps [zdiv_zadd1_eq]) 1);
9.651 qed "zdiv_zadd_self1";
9.652
9.653 -Goal "a ~= (Numeral0::int) ==> (b+a) div a = b div a + Numeral1";
9.654 +Goal "a ~= (0::int) ==> (b+a) div a = b div a + 1";
9.655 by (asm_simp_tac (simpset() addsimps [zdiv_zadd1_eq]) 1);
9.656 qed "zdiv_zadd_self2";
9.657 Addsimps [zdiv_zadd_self1, zdiv_zadd_self2];
9.658
9.659 Goal "(a+b) mod a = b mod (a::int)";
9.660 -by (zdiv_undefined_case_tac "a = Numeral0" 1);
9.661 +by (zdiv_undefined_case_tac "a = 0" 1);
9.662 by (asm_simp_tac (simpset() addsimps [zmod_zadd1_eq]) 1);
9.663 qed "zmod_zadd_self1";
9.664
9.665 Goal "(b+a) mod a = b mod (a::int)";
9.666 -by (zdiv_undefined_case_tac "a = Numeral0" 1);
9.667 +by (zdiv_undefined_case_tac "a = 0" 1);
9.668 by (asm_simp_tac (simpset() addsimps [zmod_zadd1_eq]) 1);
9.669 qed "zmod_zadd_self2";
9.670 Addsimps [zmod_zadd_self1, zmod_zadd_self2];
9.671 @@ -739,8 +748,8 @@
9.672
9.673 (** first, four lemmas to bound the remainder for the cases b<0 and b>0 **)
9.674
9.675 -Goal "[| (Numeral0::int) < c; b < r; r <= Numeral0 |] ==> b*c < b*(q mod c) + r";
9.676 -by (subgoal_tac "b * (c - q mod c) < r * Numeral1" 1);
9.677 +Goal "[| (0::int) < c; b < r; r <= 0 |] ==> b*c < b*(q mod c) + r";
9.678 +by (subgoal_tac "b * (c - q mod c) < r * 1" 1);
9.679 by (asm_full_simp_tac (simpset() addsimps [zdiff_zmult_distrib2]) 1);
9.680 by (rtac order_le_less_trans 1);
9.681 by (etac zmult_zless_mono1 2);
9.682 @@ -748,23 +757,24 @@
9.683 by (auto_tac
9.684 (claset(),
9.685 simpset() addsimps zcompare_rls@
9.686 - [zadd_commute, add1_zle_eq, pos_mod_bound]));
9.687 + [inst "z" "1" zadd_commute, add1_zle_eq,
9.688 + pos_mod_bound]));
9.689 val lemma1 = result();
9.690
9.691 -Goal "[| (Numeral0::int) < c; b < r; r <= Numeral0 |] ==> b * (q mod c) + r <= Numeral0";
9.692 -by (subgoal_tac "b * (q mod c) <= Numeral0" 1);
9.693 +Goal "[| (0::int) < c; b < r; r <= 0 |] ==> b * (q mod c) + r <= 0";
9.694 +by (subgoal_tac "b * (q mod c) <= 0" 1);
9.695 by (arith_tac 1);
9.696 by (asm_simp_tac (simpset() addsimps [zmult_le_0_iff, pos_mod_sign]) 1);
9.697 val lemma2 = result();
9.698
9.699 -Goal "[| (Numeral0::int) < c; Numeral0 <= r; r < b |] ==> Numeral0 <= b * (q mod c) + r";
9.700 -by (subgoal_tac "Numeral0 <= b * (q mod c)" 1);
9.701 +Goal "[| (0::int) < c; 0 <= r; r < b |] ==> 0 <= b * (q mod c) + r";
9.702 +by (subgoal_tac "0 <= b * (q mod c)" 1);
9.703 by (arith_tac 1);
9.704 by (asm_simp_tac (simpset() addsimps [int_0_le_mult_iff, pos_mod_sign]) 1);
9.705 val lemma3 = result();
9.706
9.707 -Goal "[| (Numeral0::int) < c; Numeral0 <= r; r < b |] ==> b * (q mod c) + r < b * c";
9.708 -by (subgoal_tac "r * Numeral1 < b * (c - q mod c)" 1);
9.709 +Goal "[| (0::int) < c; 0 <= r; r < b |] ==> b * (q mod c) + r < b * c";
9.710 +by (subgoal_tac "r * 1 < b * (c - q mod c)" 1);
9.711 by (asm_full_simp_tac (simpset() addsimps [zdiff_zmult_distrib2]) 1);
9.712 by (rtac order_less_le_trans 1);
9.713 by (etac zmult_zless_mono1 1);
9.714 @@ -772,10 +782,11 @@
9.715 by (auto_tac
9.716 (claset(),
9.717 simpset() addsimps zcompare_rls@
9.718 - [zadd_commute, add1_zle_eq, pos_mod_bound]));
9.719 + [inst "z" "1" zadd_commute, add1_zle_eq,
9.720 + pos_mod_bound]));
9.721 val lemma4 = result();
9.722
9.723 -Goal "[| quorem ((a,b), (q,r)); b ~= Numeral0; Numeral0 < c |] \
9.724 +Goal "[| quorem ((a,b), (q,r)); b ~= 0; 0 < c |] \
9.725 \ ==> quorem ((a, b*c), (q div c, b*(q mod c) + r))";
9.726 by (auto_tac
9.727 (claset(),
9.728 @@ -786,15 +797,15 @@
9.729 lemma1, lemma2, lemma3, lemma4]));
9.730 val lemma = result();
9.731
9.732 -Goal "(Numeral0::int) < c ==> a div (b*c) = (a div b) div c";
9.733 -by (zdiv_undefined_case_tac "b = Numeral0" 1);
9.734 +Goal "(0::int) < c ==> a div (b*c) = (a div b) div c";
9.735 +by (zdiv_undefined_case_tac "b = 0" 1);
9.736 by (force_tac (claset(),
9.737 simpset() addsimps [quorem_div_mod RS lemma RS quorem_div,
9.738 zmult_eq_0_iff]) 1);
9.739 qed "zdiv_zmult2_eq";
9.740
9.741 -Goal "(Numeral0::int) < c ==> a mod (b*c) = b*(a div b mod c) + a mod b";
9.742 -by (zdiv_undefined_case_tac "b = Numeral0" 1);
9.743 +Goal "(0::int) < c ==> a mod (b*c) = b*(a div b mod c) + a mod b";
9.744 +by (zdiv_undefined_case_tac "b = 0" 1);
9.745 by (force_tac (claset(),
9.746 simpset() addsimps [quorem_div_mod RS lemma RS quorem_mod,
9.747 zmult_eq_0_iff]) 1);
9.748 @@ -803,26 +814,26 @@
9.749
9.750 (*** Cancellation of common factors in "div" ***)
9.751
9.752 -Goal "[| (Numeral0::int) < b; c ~= Numeral0 |] ==> (c*a) div (c*b) = a div b";
9.753 +Goal "[| (0::int) < b; c ~= 0 |] ==> (c*a) div (c*b) = a div b";
9.754 by (stac zdiv_zmult2_eq 1);
9.755 by Auto_tac;
9.756 val lemma1 = result();
9.757
9.758 -Goal "[| b < (Numeral0::int); c ~= Numeral0 |] ==> (c*a) div (c*b) = a div b";
9.759 +Goal "[| b < (0::int); c ~= 0 |] ==> (c*a) div (c*b) = a div b";
9.760 by (subgoal_tac "(c * (-a)) div (c * (-b)) = (-a) div (-b)" 1);
9.761 by (rtac lemma1 2);
9.762 by Auto_tac;
9.763 val lemma2 = result();
9.764
9.765 -Goal "c ~= (Numeral0::int) ==> (c*a) div (c*b) = a div b";
9.766 -by (zdiv_undefined_case_tac "b = Numeral0" 1);
9.767 +Goal "c ~= (0::int) ==> (c*a) div (c*b) = a div b";
9.768 +by (zdiv_undefined_case_tac "b = 0" 1);
9.769 by (auto_tac
9.770 (claset(),
9.771 simpset() addsimps [read_instantiate [("x", "b")] linorder_neq_iff,
9.772 lemma1, lemma2]));
9.773 qed "zdiv_zmult_zmult1";
9.774
9.775 -Goal "c ~= (Numeral0::int) ==> (a*c) div (b*c) = a div b";
9.776 +Goal "c ~= (0::int) ==> (a*c) div (b*c) = a div b";
9.777 by (dtac zdiv_zmult_zmult1 1);
9.778 by (auto_tac (claset(), simpset() addsimps [zmult_commute]));
9.779 qed "zdiv_zmult_zmult2";
9.780 @@ -831,20 +842,20 @@
9.781
9.782 (*** Distribution of factors over "mod" ***)
9.783
9.784 -Goal "[| (Numeral0::int) < b; c ~= Numeral0 |] ==> (c*a) mod (c*b) = c * (a mod b)";
9.785 +Goal "[| (0::int) < b; c ~= 0 |] ==> (c*a) mod (c*b) = c * (a mod b)";
9.786 by (stac zmod_zmult2_eq 1);
9.787 by Auto_tac;
9.788 val lemma1 = result();
9.789
9.790 -Goal "[| b < (Numeral0::int); c ~= Numeral0 |] ==> (c*a) mod (c*b) = c * (a mod b)";
9.791 +Goal "[| b < (0::int); c ~= 0 |] ==> (c*a) mod (c*b) = c * (a mod b)";
9.792 by (subgoal_tac "(c * (-a)) mod (c * (-b)) = c * ((-a) mod (-b))" 1);
9.793 by (rtac lemma1 2);
9.794 by Auto_tac;
9.795 val lemma2 = result();
9.796
9.797 Goal "(c*a) mod (c*b) = (c::int) * (a mod b)";
9.798 -by (zdiv_undefined_case_tac "b = Numeral0" 1);
9.799 -by (zdiv_undefined_case_tac "c = Numeral0" 1);
9.800 +by (zdiv_undefined_case_tac "b = 0" 1);
9.801 +by (zdiv_undefined_case_tac "c = 0" 1);
9.802 by (auto_tac
9.803 (claset(),
9.804 simpset() addsimps [read_instantiate [("x", "b")] linorder_neq_iff,
9.805 @@ -861,16 +872,16 @@
9.806
9.807 (** computing "div" by shifting **)
9.808
9.809 -Goal "(Numeral0::int) <= a ==> (Numeral1 + 2*b) div (2*a) = b div a";
9.810 -by (zdiv_undefined_case_tac "a = Numeral0" 1);
9.811 -by (subgoal_tac "Numeral1 <= a" 1);
9.812 +Goal "(0::int) <= a ==> (1 + 2*b) div (2*a) = b div a";
9.813 +by (zdiv_undefined_case_tac "a = 0" 1);
9.814 +by (subgoal_tac "1 <= a" 1);
9.815 by (arith_tac 2);
9.816 -by (subgoal_tac "Numeral1 < a * 2" 1);
9.817 +by (subgoal_tac "1 < a * 2" 1);
9.818 by (arith_tac 2);
9.819 -by (subgoal_tac "2*(Numeral1 + b mod a) <= 2*a" 1);
9.820 +by (subgoal_tac "2*(1 + b mod a) <= 2*a" 1);
9.821 by (rtac zmult_zle_mono2 2);
9.822 by (auto_tac (claset(),
9.823 - simpset() addsimps [zadd_commute, zmult_commute,
9.824 + simpset() addsimps [inst "z" "1" zadd_commute, zmult_commute,
9.825 add1_zle_eq, pos_mod_bound]));
9.826 by (stac zdiv_zadd1_eq 1);
9.827 by (asm_simp_tac (simpset() addsimps [zdiv_zmult_zmult2, zmod_zmult_zmult2,
9.828 @@ -881,18 +892,18 @@
9.829 pos_mod_sign RS zadd_zle_mono1 RSN (2,order_trans)]) 1);
9.830 by (auto_tac (claset(),
9.831 simpset() addsimps [mod_pos_pos_trivial]));
9.832 -by (subgoal_tac "Numeral0 <= b mod a" 1);
9.833 +by (subgoal_tac "0 <= b mod a" 1);
9.834 by (asm_simp_tac (simpset() addsimps [pos_mod_sign]) 2);
9.835 by (arith_tac 1);
9.836 qed "pos_zdiv_mult_2";
9.837
9.838
9.839 -Goal "a <= (Numeral0::int) ==> (Numeral1 + 2*b) div (2*a) = (b+Numeral1) div a";
9.840 -by (subgoal_tac "(Numeral1 + 2*(-b-Numeral1)) div (2 * (-a)) = (-b-Numeral1) div (-a)" 1);
9.841 +Goal "a <= (0::int) ==> (1 + 2*b) div (2*a) = (b+1) div a";
9.842 +by (subgoal_tac "(1 + 2*(-b - 1)) div (2 * (-a)) = (-b - 1) div (-a)" 1);
9.843 by (rtac pos_zdiv_mult_2 2);
9.844 by (auto_tac (claset(),
9.845 simpset() addsimps [zmult_zminus_right]));
9.846 -by (subgoal_tac "(-1 - (2 * b)) = - (Numeral1 + (2 * b))" 1);
9.847 +by (subgoal_tac "(-1 - (2 * b)) = - (1 + (2 * b))" 1);
9.848 by (Simp_tac 2);
9.849 by (asm_full_simp_tac (HOL_ss
9.850 addsimps [zdiv_zminus_zminus, zdiff_def,
9.851 @@ -902,17 +913,19 @@
9.852
9.853 (*Not clear why this must be proved separately; probably number_of causes
9.854 simplification problems*)
9.855 -Goal "~ Numeral0 <= x ==> x <= (Numeral0::int)";
9.856 +Goal "~ 0 <= x ==> x <= (0::int)";
9.857 by Auto_tac;
9.858 val lemma = result();
9.859
9.860 Goal "number_of (v BIT b) div number_of (w BIT False) = \
9.861 -\ (if ~b | (Numeral0::int) <= number_of w \
9.862 +\ (if ~b | (0::int) <= number_of w \
9.863 \ then number_of v div (number_of w) \
9.864 -\ else (number_of v + (Numeral1::int)) div (number_of w))";
9.865 +\ else (number_of v + (1::int)) div (number_of w))";
9.866 by (simp_tac (simpset_of Int.thy addsimps [zadd_assoc, number_of_BIT]) 1);
9.867 +by (subgoal_tac "2 ~= (0::int)" 1);
9.868 + by (Simp_tac 2); (*we do this because the next step can't simplify numerals*)
9.869 by (asm_simp_tac (simpset()
9.870 - delsimps [thm "number_of_reorient"]@bin_arith_extra_simps@bin_rel_simps
9.871 + delsimps bin_arith_extra_simps
9.872 addsimps [zdiv_zmult_zmult1, pos_zdiv_mult_2, lemma,
9.873 neg_zdiv_mult_2]) 1);
9.874 qed "zdiv_number_of_BIT";
9.875 @@ -921,16 +934,16 @@
9.876
9.877 (** computing "mod" by shifting (proofs resemble those for "div") **)
9.878
9.879 -Goal "(Numeral0::int) <= a ==> (Numeral1 + 2*b) mod (2*a) = Numeral1 + 2 * (b mod a)";
9.880 -by (zdiv_undefined_case_tac "a = Numeral0" 1);
9.881 -by (subgoal_tac "Numeral1 <= a" 1);
9.882 +Goal "(0::int) <= a ==> (1 + 2*b) mod (2*a) = 1 + 2 * (b mod a)";
9.883 +by (zdiv_undefined_case_tac "a = 0" 1);
9.884 +by (subgoal_tac "1 <= a" 1);
9.885 by (arith_tac 2);
9.886 -by (subgoal_tac "Numeral1 < a * 2" 1);
9.887 +by (subgoal_tac "1 < a * 2" 1);
9.888 by (arith_tac 2);
9.889 -by (subgoal_tac "2*(Numeral1 + b mod a) <= 2*a" 1);
9.890 +by (subgoal_tac "2*(1 + b mod a) <= 2*a" 1);
9.891 by (rtac zmult_zle_mono2 2);
9.892 by (auto_tac (claset(),
9.893 - simpset() addsimps [zadd_commute, zmult_commute,
9.894 + simpset() addsimps [inst "z" "1" zadd_commute, zmult_commute,
9.895 add1_zle_eq, pos_mod_bound]));
9.896 by (stac zmod_zadd1_eq 1);
9.897 by (asm_simp_tac (simpset() addsimps [zmod_zmult_zmult2,
9.898 @@ -941,19 +954,18 @@
9.899 pos_mod_sign RS zadd_zle_mono1 RSN (2,order_trans)]) 1);
9.900 by (auto_tac (claset(),
9.901 simpset() addsimps [mod_pos_pos_trivial]));
9.902 -by (subgoal_tac "Numeral0 <= b mod a" 1);
9.903 +by (subgoal_tac "0 <= b mod a" 1);
9.904 by (asm_simp_tac (simpset() addsimps [pos_mod_sign]) 2);
9.905 by (arith_tac 1);
9.906 qed "pos_zmod_mult_2";
9.907
9.908
9.909 -Goal "a <= (Numeral0::int) ==> (Numeral1 + 2*b) mod (2*a) = 2 * ((b+Numeral1) mod a) - Numeral1";
9.910 +Goal "a <= (0::int) ==> (1 + 2*b) mod (2*a) = 2 * ((b+1) mod a) - 1";
9.911 by (subgoal_tac
9.912 - "(Numeral1 + 2*(-b-Numeral1)) mod (2*(-a)) = Numeral1 + 2*((-b-Numeral1) mod (-a))" 1);
9.913 + "(1 + 2*(-b - 1)) mod (2*(-a)) = 1 + 2*((-b - 1) mod (-a))" 1);
9.914 by (rtac pos_zmod_mult_2 2);
9.915 -by (auto_tac (claset(),
9.916 - simpset() addsimps [zmult_zminus_right]));
9.917 -by (subgoal_tac "(-1 - (2 * b)) = - (Numeral1 + (2 * b))" 1);
9.918 +by (auto_tac (claset(), simpset() addsimps [zmult_zminus_right]));
9.919 +by (subgoal_tac "(-1 - (2 * b)) = - (1 + (2 * b))" 1);
9.920 by (Simp_tac 2);
9.921 by (asm_full_simp_tac (HOL_ss
9.922 addsimps [zmod_zminus_zminus, zdiff_def,
9.923 @@ -964,15 +976,16 @@
9.924
9.925 Goal "number_of (v BIT b) mod number_of (w BIT False) = \
9.926 \ (if b then \
9.927 -\ if (Numeral0::int) <= number_of w \
9.928 -\ then 2 * (number_of v mod number_of w) + Numeral1 \
9.929 -\ else 2 * ((number_of v + (Numeral1::int)) mod number_of w) - Numeral1 \
9.930 +\ if (0::int) <= number_of w \
9.931 +\ then 2 * (number_of v mod number_of w) + 1 \
9.932 +\ else 2 * ((number_of v + (1::int)) mod number_of w) - 1 \
9.933 \ else 2 * (number_of v mod number_of w))";
9.934 by (simp_tac (simpset_of Int.thy addsimps [zadd_assoc, number_of_BIT]) 1);
9.935 by (asm_simp_tac (simpset()
9.936 delsimps bin_arith_extra_simps@bin_rel_simps
9.937 addsimps [zmod_zmult_zmult1,
9.938 pos_zmod_mult_2, lemma, neg_zmod_mult_2]) 1);
9.939 +by (Simp_tac 1);
9.940 qed "zmod_number_of_BIT";
9.941
9.942 Addsimps [zmod_number_of_BIT];
9.943 @@ -980,7 +993,7 @@
9.944
9.945 (** Quotients of signs **)
9.946
9.947 -Goal "[| a < (Numeral0::int); Numeral0 < b |] ==> a div b < Numeral0";
9.948 +Goal "[| a < (0::int); 0 < b |] ==> a div b < 0";
9.949 by (subgoal_tac "a div b <= -1" 1);
9.950 by (Force_tac 1);
9.951 by (rtac order_trans 1);
9.952 @@ -988,12 +1001,12 @@
9.953 by (auto_tac (claset(), simpset() addsimps [zdiv_minus1]));
9.954 qed "div_neg_pos_less0";
9.955
9.956 -Goal "[| (Numeral0::int) <= a; b < Numeral0 |] ==> a div b <= Numeral0";
9.957 +Goal "[| (0::int) <= a; b < 0 |] ==> a div b <= 0";
9.958 by (dtac zdiv_mono1_neg 1);
9.959 by Auto_tac;
9.960 qed "div_nonneg_neg_le0";
9.961
9.962 -Goal "(Numeral0::int) < b ==> (Numeral0 <= a div b) = (Numeral0 <= a)";
9.963 +Goal "(0::int) < b ==> (0 <= a div b) = (0 <= a)";
9.964 by Auto_tac;
9.965 by (dtac zdiv_mono1 2);
9.966 by (auto_tac (claset(), simpset() addsimps [linorder_neq_iff]));
9.967 @@ -1001,20 +1014,20 @@
9.968 by (blast_tac (claset() addIs [div_neg_pos_less0]) 1);
9.969 qed "pos_imp_zdiv_nonneg_iff";
9.970
9.971 -Goal "b < (Numeral0::int) ==> (Numeral0 <= a div b) = (a <= (Numeral0::int))";
9.972 +Goal "b < (0::int) ==> (0 <= a div b) = (a <= (0::int))";
9.973 by (stac (zdiv_zminus_zminus RS sym) 1);
9.974 by (stac pos_imp_zdiv_nonneg_iff 1);
9.975 by Auto_tac;
9.976 qed "neg_imp_zdiv_nonneg_iff";
9.977
9.978 (*But not (a div b <= 0 iff a<=0); consider a=1, b=2 when a div b = 0.*)
9.979 -Goal "(Numeral0::int) < b ==> (a div b < Numeral0) = (a < Numeral0)";
9.980 +Goal "(0::int) < b ==> (a div b < 0) = (a < 0)";
9.981 by (asm_simp_tac (simpset() addsimps [linorder_not_le RS sym,
9.982 pos_imp_zdiv_nonneg_iff]) 1);
9.983 qed "pos_imp_zdiv_neg_iff";
9.984
9.985 (*Again the law fails for <=: consider a = -1, b = -2 when a div b = 0*)
9.986 -Goal "b < (Numeral0::int) ==> (a div b < Numeral0) = (Numeral0 < a)";
9.987 +Goal "b < (0::int) ==> (a div b < 0) = (0 < a)";
9.988 by (asm_simp_tac (simpset() addsimps [linorder_not_le RS sym,
9.989 neg_imp_zdiv_nonneg_iff]) 1);
9.990 qed "neg_imp_zdiv_neg_iff";
10.1 --- a/src/HOL/Integ/IntDiv.thy Mon Oct 22 11:01:30 2001 +0200
10.2 +++ b/src/HOL/Integ/IntDiv.thy Mon Oct 22 11:54:22 2001 +0200
10.3 @@ -12,27 +12,27 @@
10.4 quorem :: "(int*int) * (int*int) => bool"
10.5 "quorem == %((a,b), (q,r)).
10.6 a = b*q + r &
10.7 - (if Numeral0 < b then Numeral0<=r & r<b else b<r & r <= Numeral0)"
10.8 + (if 0 < b then 0<=r & r<b else b<r & r <= 0)"
10.9
10.10 - adjust :: "[int, int, int*int] => int*int"
10.11 - "adjust a b == %(q,r). if Numeral0 <= r-b then (2*q + Numeral1, r-b)
10.12 - else (2*q, r)"
10.13 + adjust :: "[int, int*int] => int*int"
10.14 + "adjust b == %(q,r). if 0 <= r-b then (2*q + 1, r-b)
10.15 + else (2*q, r)"
10.16
10.17 (** the division algorithm **)
10.18
10.19 (*for the case a>=0, b>0*)
10.20 consts posDivAlg :: "int*int => int*int"
10.21 -recdef posDivAlg "inv_image less_than (%(a,b). nat(a - b + Numeral1))"
10.22 +recdef posDivAlg "inv_image less_than (%(a,b). nat(a - b + 1))"
10.23 "posDivAlg (a,b) =
10.24 - (if (a<b | b<=Numeral0) then (Numeral0,a)
10.25 - else adjust a b (posDivAlg(a, 2*b)))"
10.26 + (if (a<b | b<=0) then (0,a)
10.27 + else adjust b (posDivAlg(a, 2*b)))"
10.28
10.29 (*for the case a<0, b>0*)
10.30 consts negDivAlg :: "int*int => int*int"
10.31 recdef negDivAlg "inv_image less_than (%(a,b). nat(- a - b))"
10.32 "negDivAlg (a,b) =
10.33 - (if (Numeral0<=a+b | b<=Numeral0) then (-1,a+b)
10.34 - else adjust a b (negDivAlg(a, 2*b)))"
10.35 + (if (0<=a+b | b<=0) then (-1,a+b)
10.36 + else adjust b (negDivAlg(a, 2*b)))"
10.37
10.38 (*for the general case b~=0*)
10.39
10.40 @@ -44,12 +44,12 @@
10.41 including the special case a=0, b<0, because negDivAlg requires a<0*)
10.42 divAlg :: "int*int => int*int"
10.43 "divAlg ==
10.44 - %(a,b). if Numeral0<=a then
10.45 - if Numeral0<=b then posDivAlg (a,b)
10.46 - else if a=Numeral0 then (Numeral0,Numeral0)
10.47 + %(a,b). if 0<=a then
10.48 + if 0<=b then posDivAlg (a,b)
10.49 + else if a=0 then (0,0)
10.50 else negateSnd (negDivAlg (-a,-b))
10.51 else
10.52 - if Numeral0<b then negDivAlg (a,b)
10.53 + if 0<b then negDivAlg (a,b)
10.54 else negateSnd (posDivAlg (-a,-b))"
10.55
10.56 instance
11.1 --- a/src/HOL/Integ/IntPower.ML Mon Oct 22 11:01:30 2001 +0200
11.2 +++ b/src/HOL/Integ/IntPower.ML Mon Oct 22 11:54:22 2001 +0200
11.3 @@ -15,7 +15,7 @@
11.4 by (rtac (zmod_zmult_distrib RS sym) 1);
11.5 qed "zpower_zmod";
11.6
11.7 -Goal "Numeral1^y = (Numeral1::int)";
11.8 +Goal "1^y = (1::int)";
11.9 by (induct_tac "y" 1);
11.10 by Auto_tac;
11.11 qed "zpower_1";
12.1 --- a/src/HOL/Integ/IntPower.thy Mon Oct 22 11:01:30 2001 +0200
12.2 +++ b/src/HOL/Integ/IntPower.thy Mon Oct 22 11:54:22 2001 +0200
12.3 @@ -12,7 +12,7 @@
12.4 int :: {power}
12.5
12.6 primrec
12.7 - power_0 "p ^ 0 = Numeral1"
12.8 + power_0 "p ^ 0 = 1"
12.9 power_Suc "p ^ (Suc n) = (p::int) * (p ^ n)"
12.10
12.11 end
13.1 --- a/src/HOL/Integ/NatSimprocs.ML Mon Oct 22 11:01:30 2001 +0200
13.2 +++ b/src/HOL/Integ/NatSimprocs.ML Mon Oct 22 11:54:22 2001 +0200
13.3 @@ -6,10 +6,11 @@
13.4 Simprocs for nat numerals (see also nat_simprocs.ML).
13.5 *)
13.6
13.7 -(** For simplifying Suc m - # n **)
13.8 +(** For simplifying Suc m - #n **)
13.9
13.10 Goal "Numeral0 < n ==> Suc m - n = m - (n - Numeral1)";
13.11 -by (asm_simp_tac (simpset() addsplits [nat_diff_split]) 1);
13.12 +by (asm_simp_tac (simpset() addsimps [numeral_0_eq_0, numeral_1_eq_1]
13.13 + addsplits [nat_diff_split]) 1);
13.14 qed "Suc_diff_eq_diff_pred";
13.15
13.16 (*Now just instantiating n to (number_of v) does the right simplification,
13.17 @@ -48,8 +49,8 @@
13.18 by (stac add_eq_if 1);
13.19 by (asm_simp_tac
13.20 (simpset() addsplits [nat.split]
13.21 - addsimps [Let_def, neg_imp_number_of_eq_0,
13.22 - neg_number_of_bin_pred_iff_0]) 1);
13.23 + addsimps [numeral_1_eq_Suc_0 RS sym, Let_def,
13.24 + neg_imp_number_of_eq_0, neg_number_of_bin_pred_iff_0]) 1);
13.25 qed "nat_case_add_eq_if";
13.26
13.27 Addsimps [nat_case_number_of, nat_case_add_eq_if];
13.28 @@ -71,8 +72,8 @@
13.29 by (stac add_eq_if 1);
13.30 by (asm_simp_tac
13.31 (simpset() addsplits [nat.split]
13.32 - addsimps [Let_def, neg_imp_number_of_eq_0,
13.33 - neg_number_of_bin_pred_iff_0]) 1);
13.34 + addsimps [numeral_1_eq_Suc_0 RS sym, Let_def,
13.35 + neg_imp_number_of_eq_0, neg_number_of_bin_pred_iff_0]) 1);
13.36 qed "nat_rec_add_eq_if";
13.37
13.38 Addsimps [nat_rec_number_of, nat_rec_add_eq_if];
13.39 @@ -80,7 +81,7 @@
13.40
13.41 (** For simplifying # m - Suc n **)
13.42
13.43 -Goal "m - Suc n = (m - Numeral1) - n";
13.44 +Goal "m - Suc n = (m - 1) - n";
13.45 by (simp_tac (numeral_ss addsplits [nat_diff_split]) 1);
13.46 qed "diff_Suc_eq_diff_pred";
13.47
13.48 @@ -93,7 +94,7 @@
13.49 (** Evens and Odds, for Mutilated Chess Board **)
13.50
13.51 (*Case analysis on b<2*)
13.52 -Goal "(n::nat) < 2 ==> n = Numeral0 | n = Numeral1";
13.53 +Goal "(n::nat) < 2 ==> n = 0 | n = Suc 0";
13.54 by (arith_tac 1);
13.55 qed "less_2_cases";
13.56
13.57 @@ -101,16 +102,16 @@
13.58 by (subgoal_tac "m mod 2 < 2" 1);
13.59 by (Asm_simp_tac 2);
13.60 be (less_2_cases RS disjE) 1;
13.61 -by (ALLGOALS (asm_simp_tac (simpset() addsimps [mod_Suc])));
13.62 +by (ALLGOALS (asm_simp_tac (simpset() addsimps [Let_def, mod_Suc, nat_1])));
13.63 qed "mod2_Suc_Suc";
13.64 Addsimps [mod2_Suc_Suc];
13.65
13.66 -Goal "!!m::nat. (0 < m mod 2) = (m mod 2 = Numeral1)";
13.67 +Goal "!!m::nat. (0 < m mod 2) = (m mod 2 = 1)";
13.68 by (subgoal_tac "m mod 2 < 2" 1);
13.69 by (Asm_simp_tac 2);
13.70 by (auto_tac (claset(), simpset() delsimps [mod_less_divisor]));
13.71 qed "mod2_gr_0";
13.72 -Addsimps [mod2_gr_0, rename_numerals mod2_gr_0];
13.73 +Addsimps [mod2_gr_0];
13.74
13.75 (** Removal of small numerals: Numeral0, Numeral1 and (in additive positions) 2 **)
13.76
14.1 --- a/src/HOL/Integ/int_arith1.ML Mon Oct 22 11:01:30 2001 +0200
14.2 +++ b/src/HOL/Integ/int_arith1.ML Mon Oct 22 11:54:22 2001 +0200
14.3 @@ -5,19 +5,21 @@
14.4 Simprocs and decision procedure for linear arithmetic.
14.5 *)
14.6
14.7 +Addsimps [int_numeral_0_eq_0, int_numeral_1_eq_1];
14.8 +
14.9 (*** Simprocs for numeric literals ***)
14.10
14.11 (** Combining of literal coefficients in sums of products **)
14.12
14.13 -Goal "(x < y) = (x-y < (Numeral0::int))";
14.14 +Goal "(x < y) = (x-y < (0::int))";
14.15 by (simp_tac (simpset() addsimps zcompare_rls) 1);
14.16 qed "zless_iff_zdiff_zless_0";
14.17
14.18 -Goal "(x = y) = (x-y = (Numeral0::int))";
14.19 +Goal "(x = y) = (x-y = (0::int))";
14.20 by (simp_tac (simpset() addsimps zcompare_rls) 1);
14.21 qed "eq_iff_zdiff_eq_0";
14.22
14.23 -Goal "(x <= y) = (x-y <= (Numeral0::int))";
14.24 +Goal "(x <= y) = (x-y <= (0::int))";
14.25 by (simp_tac (simpset() addsimps zcompare_rls) 1);
14.26 qed "zle_iff_zdiff_zle_0";
14.27
14.28 @@ -77,12 +79,22 @@
14.29 structure Int_Numeral_Simprocs =
14.30 struct
14.31
14.32 +(*Maps 0 to Numeral0 and 1 to Numeral1 so that arithmetic in simprocs
14.33 + isn't complicated by the abstract 0 and 1.*)
14.34 +val numeral_syms = [int_numeral_0_eq_0 RS sym, int_numeral_1_eq_1 RS sym];
14.35 +val numeral_sym_ss = HOL_ss addsimps numeral_syms;
14.36 +
14.37 +fun rename_numerals th =
14.38 + simplify numeral_sym_ss (Thm.transfer (the_context ()) th);
14.39 +
14.40 (*Utilities*)
14.41
14.42 fun mk_numeral n = HOLogic.number_of_const HOLogic.intT $ HOLogic.mk_bin n;
14.43
14.44 (*Decodes a binary INTEGER*)
14.45 -fun dest_numeral (Const("Numeral.number_of", _) $ w) =
14.46 +fun dest_numeral (Const("0", _)) = 0
14.47 + | dest_numeral (Const("1", _)) = 1
14.48 + | dest_numeral (Const("Numeral.number_of", _) $ w) =
14.49 (HOLogic.dest_binum w
14.50 handle TERM _ => raise TERM("Int_Numeral_Simprocs.dest_numeral:1", [w]))
14.51 | dest_numeral t = raise TERM("Int_Numeral_Simprocs.dest_numeral:2", [t]);
14.52 @@ -97,7 +109,7 @@
14.53
14.54 val uminus_const = Const ("uminus", HOLogic.intT --> HOLogic.intT);
14.55
14.56 -(*Thus mk_sum[t] yields t+Numeral0; longer sums don't have a trailing zero*)
14.57 +(*Thus mk_sum[t] yields t+0; longer sums don't have a trailing zero*)
14.58 fun mk_sum [] = zero
14.59 | mk_sum [t,u] = mk_plus (t, u)
14.60 | mk_sum (t :: ts) = mk_plus (t, mk_sum ts);
14.61 @@ -157,16 +169,20 @@
14.62 handle TERM _ => find_first_coeff (t::past) u terms;
14.63
14.64
14.65 -(*Simplify Numeral1*n and n*Numeral1 to n*)
14.66 -val add_0s = [zadd_0, zadd_0_right];
14.67 -val mult_1s = [zmult_1, zmult_1_right, zmult_minus1, zmult_minus1_right];
14.68 +(*Simplify Numeral0+n, n+Numeral0, Numeral1*n, n*Numeral1*)
14.69 +val add_0s = map rename_numerals [zadd_0, zadd_0_right];
14.70 +val mult_1s = map rename_numerals [zmult_1, zmult_1_right] @
14.71 + [zmult_minus1, zmult_minus1_right];
14.72
14.73 -(*To perform binary arithmetic*)
14.74 -val bin_simps = [add_number_of_left] @ bin_arith_simps @ bin_rel_simps;
14.75 +(*To perform binary arithmetic. The "left" rewriting handles patterns
14.76 + created by the simprocs, such as 3 * (5 * x). *)
14.77 +val bin_simps = [int_numeral_0_eq_0 RS sym, int_numeral_1_eq_1 RS sym,
14.78 + add_number_of_left, mult_number_of_left] @
14.79 + bin_arith_simps @ bin_rel_simps;
14.80
14.81 (*To evaluate binary negations of coefficients*)
14.82 val zminus_simps = NCons_simps @
14.83 - [number_of_minus RS sym,
14.84 + [zminus_1_eq_m1, number_of_minus RS sym,
14.85 bin_minus_1, bin_minus_0, bin_minus_Pls, bin_minus_Min,
14.86 bin_pred_1, bin_pred_0, bin_pred_Pls, bin_pred_Min];
14.87
14.88 @@ -189,28 +205,10 @@
14.89 fun trans_tac None = all_tac
14.90 | trans_tac (Some th) = ALLGOALS (rtac (th RS trans));
14.91
14.92 -fun prove_conv name tacs sg (hyps: thm list) (t,u) =
14.93 - if t aconv u then None
14.94 - else
14.95 - let val ct = cterm_of sg (HOLogic.mk_Trueprop (HOLogic.mk_eq (t, u)))
14.96 - in Some
14.97 - (prove_goalw_cterm [] ct (K tacs)
14.98 - handle ERROR => error
14.99 - ("The error(s) above occurred while trying to prove " ^
14.100 - string_of_cterm ct ^ "\nInternal failure of simproc " ^ name))
14.101 - end;
14.102 -
14.103 -(*version without the hyps argument*)
14.104 -fun prove_conv_nohyps name tacs sg = prove_conv name tacs sg [];
14.105 -
14.106 fun simplify_meta_eq rules =
14.107 mk_meta_eq o
14.108 simplify (HOL_basic_ss addeqcongs[eq_cong2] addsimps rules)
14.109
14.110 -fun prep_simproc (name, pats, proc) = Simplifier.mk_simproc name pats proc;
14.111 -fun prep_pat s = Thm.read_cterm (Theory.sign_of (the_context())) (s, HOLogic.termT);
14.112 -val prep_pats = map prep_pat;
14.113 -
14.114 structure CancelNumeralsCommon =
14.115 struct
14.116 val mk_sum = mk_sum
14.117 @@ -220,8 +218,8 @@
14.118 val find_first_coeff = find_first_coeff []
14.119 val trans_tac = trans_tac
14.120 val norm_tac =
14.121 - ALLGOALS (simp_tac (HOL_ss addsimps add_0s@mult_1s@diff_simps@
14.122 - zminus_simps@zadd_ac))
14.123 + ALLGOALS (simp_tac (HOL_ss addsimps numeral_syms@add_0s@mult_1s@
14.124 + diff_simps@zminus_simps@zadd_ac))
14.125 THEN ALLGOALS (simp_tac (HOL_ss addsimps bin_simps@int_mult_minus_simps))
14.126 THEN ALLGOALS (simp_tac (HOL_ss addsimps int_minus_from_mult_simps@
14.127 zadd_ac@zmult_ac))
14.128 @@ -232,7 +230,7 @@
14.129
14.130 structure EqCancelNumerals = CancelNumeralsFun
14.131 (open CancelNumeralsCommon
14.132 - val prove_conv = prove_conv "inteq_cancel_numerals"
14.133 + val prove_conv = Bin_Simprocs.prove_conv "inteq_cancel_numerals"
14.134 val mk_bal = HOLogic.mk_eq
14.135 val dest_bal = HOLogic.dest_bin "op =" HOLogic.intT
14.136 val bal_add1 = eq_add_iff1 RS trans
14.137 @@ -241,7 +239,7 @@
14.138
14.139 structure LessCancelNumerals = CancelNumeralsFun
14.140 (open CancelNumeralsCommon
14.141 - val prove_conv = prove_conv "intless_cancel_numerals"
14.142 + val prove_conv = Bin_Simprocs.prove_conv "intless_cancel_numerals"
14.143 val mk_bal = HOLogic.mk_binrel "op <"
14.144 val dest_bal = HOLogic.dest_bin "op <" HOLogic.intT
14.145 val bal_add1 = less_add_iff1 RS trans
14.146 @@ -250,7 +248,7 @@
14.147
14.148 structure LeCancelNumerals = CancelNumeralsFun
14.149 (open CancelNumeralsCommon
14.150 - val prove_conv = prove_conv "intle_cancel_numerals"
14.151 + val prove_conv = Bin_Simprocs.prove_conv "intle_cancel_numerals"
14.152 val mk_bal = HOLogic.mk_binrel "op <="
14.153 val dest_bal = HOLogic.dest_bin "op <=" HOLogic.intT
14.154 val bal_add1 = le_add_iff1 RS trans
14.155 @@ -258,19 +256,22 @@
14.156 );
14.157
14.158 val cancel_numerals =
14.159 - map prep_simproc
14.160 + map Bin_Simprocs.prep_simproc
14.161 [("inteq_cancel_numerals",
14.162 - prep_pats ["(l::int) + m = n", "(l::int) = m + n",
14.163 + Bin_Simprocs.prep_pats
14.164 + ["(l::int) + m = n", "(l::int) = m + n",
14.165 "(l::int) - m = n", "(l::int) = m - n",
14.166 "(l::int) * m = n", "(l::int) = m * n"],
14.167 EqCancelNumerals.proc),
14.168 ("intless_cancel_numerals",
14.169 - prep_pats ["(l::int) + m < n", "(l::int) < m + n",
14.170 + Bin_Simprocs.prep_pats
14.171 + ["(l::int) + m < n", "(l::int) < m + n",
14.172 "(l::int) - m < n", "(l::int) < m - n",
14.173 "(l::int) * m < n", "(l::int) < m * n"],
14.174 LessCancelNumerals.proc),
14.175 ("intle_cancel_numerals",
14.176 - prep_pats ["(l::int) + m <= n", "(l::int) <= m + n",
14.177 + Bin_Simprocs.prep_pats
14.178 + ["(l::int) + m <= n", "(l::int) <= m + n",
14.179 "(l::int) - m <= n", "(l::int) <= m - n",
14.180 "(l::int) * m <= n", "(l::int) <= m * n"],
14.181 LeCancelNumerals.proc)];
14.182 @@ -284,11 +285,11 @@
14.183 val mk_coeff = mk_coeff
14.184 val dest_coeff = dest_coeff 1
14.185 val left_distrib = left_zadd_zmult_distrib RS trans
14.186 - val prove_conv = prove_conv_nohyps "int_combine_numerals"
14.187 + val prove_conv = Bin_Simprocs.prove_conv_nohyps "int_combine_numerals"
14.188 val trans_tac = trans_tac
14.189 val norm_tac =
14.190 - ALLGOALS (simp_tac (HOL_ss addsimps add_0s@mult_1s@diff_simps@
14.191 - zminus_simps@zadd_ac))
14.192 + ALLGOALS (simp_tac (HOL_ss addsimps numeral_syms@add_0s@mult_1s@
14.193 + diff_simps@zminus_simps@zadd_ac))
14.194 THEN ALLGOALS (simp_tac (HOL_ss addsimps bin_simps@int_mult_minus_simps))
14.195 THEN ALLGOALS (simp_tac (HOL_ss addsimps int_minus_from_mult_simps@
14.196 zadd_ac@zmult_ac))
14.197 @@ -299,9 +300,9 @@
14.198
14.199 structure CombineNumerals = CombineNumeralsFun(CombineNumeralsData);
14.200
14.201 -val combine_numerals =
14.202 - prep_simproc ("int_combine_numerals",
14.203 - prep_pats ["(i::int) + j", "(i::int) - j"],
14.204 +val combine_numerals = Bin_Simprocs.prep_simproc
14.205 + ("int_combine_numerals",
14.206 + Bin_Simprocs.prep_pats ["(i::int) + j", "(i::int) - j"],
14.207 CombineNumerals.proc);
14.208
14.209 end;
14.210 @@ -316,7 +317,7 @@
14.211 print_depth 22;
14.212 set timing;
14.213 set trace_simp;
14.214 -fun test s = (Goal s; by (Simp_tac 1));
14.215 +fun test s = (Goal s, by (Simp_tac 1));
14.216
14.217 test "l + 2 + 2 + 2 + (l + 2) + (oo + 2) = (uu::int)";
14.218
14.219 @@ -403,17 +404,20 @@
14.220 local
14.221
14.222 (* reduce contradictory <= to False *)
14.223 -val add_rules = simp_thms @ bin_arith_simps @ bin_rel_simps @
14.224 - [zadd_0, zadd_0_right, zdiff_def,
14.225 - zadd_zminus_inverse, zadd_zminus_inverse2,
14.226 - zmult_0, zmult_0_right,
14.227 - zmult_1, zmult_1_right,
14.228 - zmult_minus1, zmult_minus1_right,
14.229 - zminus_zadd_distrib, zminus_zminus, zmult_assoc,
14.230 - Zero_int_def, One_int_def, int_0, int_1, zadd_int RS sym, int_Suc];
14.231 +val add_rules =
14.232 + simp_thms @ bin_arith_simps @ bin_rel_simps @
14.233 + [int_numeral_0_eq_0, int_numeral_1_eq_1,
14.234 + zadd_0, zadd_0_right, zdiff_def,
14.235 + zadd_zminus_inverse, zadd_zminus_inverse2,
14.236 + zmult_0, zmult_0_right,
14.237 + zmult_1, zmult_1_right,
14.238 + zmult_minus1, zmult_minus1_right,
14.239 + zminus_zadd_distrib, zminus_zminus, zmult_assoc,
14.240 + int_0, int_1, zadd_int RS sym, int_Suc];
14.241
14.242 val simprocs = [Int_Times_Assoc.conv, Int_Numeral_Simprocs.combine_numerals]@
14.243 - Int_Numeral_Simprocs.cancel_numerals;
14.244 + Int_Numeral_Simprocs.cancel_numerals @
14.245 + Bin_Simprocs.eval_numerals;
14.246
14.247 val add_mono_thms_int =
14.248 map (fn s => prove_goal (the_context ()) s
14.249 @@ -457,7 +461,7 @@
14.250 by (fast_arith_tac 1);
14.251 Goal "!!a::int. [| a < b; c < d |] ==> a-d+ 2 <= b+(-c)";
14.252 by (fast_arith_tac 1);
14.253 -Goal "!!a::int. [| a < b; c < d |] ==> a+c+ Numeral1 < b+d";
14.254 +Goal "!!a::int. [| a < b; c < d |] ==> a+c+ 1 < b+d";
14.255 by (fast_arith_tac 1);
14.256 Goal "!!a::int. [| a <= b; b+b <= c |] ==> a+a <= c";
14.257 by (fast_arith_tac 1);
15.1 --- a/src/HOL/Integ/int_arith2.ML Mon Oct 22 11:01:30 2001 +0200
15.2 +++ b/src/HOL/Integ/int_arith2.ML Mon Oct 22 11:54:22 2001 +0200
15.3 @@ -3,19 +3,17 @@
15.4 Authors: Larry Paulson and Tobias Nipkow
15.5 *)
15.6
15.7 -(** Simplification of inequalities involving numerical constants **)
15.8 -
15.9 -Goal "(w <= z - (Numeral1::int)) = (w<(z::int))";
15.10 +Goal "(w <= z - (1::int)) = (w<(z::int))";
15.11 by (arith_tac 1);
15.12 qed "zle_diff1_eq";
15.13 Addsimps [zle_diff1_eq];
15.14
15.15 -Goal "(w < z + Numeral1) = (w<=(z::int))";
15.16 +Goal "(w < z + 1) = (w<=(z::int))";
15.17 by (arith_tac 1);
15.18 qed "zle_add1_eq_le";
15.19 Addsimps [zle_add1_eq_le];
15.20
15.21 -Goal "(z = z + w) = (w = (Numeral0::int))";
15.22 +Goal "(z = z + w) = (w = (0::int))";
15.23 by (arith_tac 1);
15.24 qed "zadd_left_cancel0";
15.25 Addsimps [zadd_left_cancel0];
15.26 @@ -23,13 +21,13 @@
15.27
15.28 (* nat *)
15.29
15.30 -Goal "Numeral0 <= z ==> int (nat z) = z";
15.31 +Goal "0 <= z ==> int (nat z) = z";
15.32 by (asm_full_simp_tac
15.33 (simpset() addsimps [neg_eq_less_0, zle_def, not_neg_nat]) 1);
15.34 qed "nat_0_le";
15.35
15.36 -Goal "z <= Numeral0 ==> nat z = 0";
15.37 -by (case_tac "z = Numeral0" 1);
15.38 +Goal "z <= 0 ==> nat z = 0";
15.39 +by (case_tac "z = 0" 1);
15.40 by (asm_simp_tac (simpset() addsimps [nat_le_int0]) 1);
15.41 by (asm_full_simp_tac
15.42 (simpset() addsimps [neg_eq_less_0, neg_nat, linorder_neq_iff]) 1);
15.43 @@ -37,19 +35,19 @@
15.44
15.45 Addsimps [nat_0_le, nat_le_0];
15.46
15.47 -val [major,minor] = Goal "[| Numeral0 <= z; !!m. z = int m ==> P |] ==> P";
15.48 +val [major,minor] = Goal "[| 0 <= z; !!m. z = int m ==> P |] ==> P";
15.49 by (rtac (major RS nat_0_le RS sym RS minor) 1);
15.50 qed "nonneg_eq_int";
15.51
15.52 -Goal "(nat w = m) = (if Numeral0 <= w then w = int m else m=0)";
15.53 +Goal "(nat w = m) = (if 0 <= w then w = int m else m=0)";
15.54 by Auto_tac;
15.55 qed "nat_eq_iff";
15.56
15.57 -Goal "(m = nat w) = (if Numeral0 <= w then w = int m else m=0)";
15.58 +Goal "(m = nat w) = (if 0 <= w then w = int m else m=0)";
15.59 by Auto_tac;
15.60 qed "nat_eq_iff2";
15.61
15.62 -Goal "Numeral0 <= w ==> (nat w < m) = (w < int m)";
15.63 +Goal "0 <= w ==> (nat w < m) = (w < int m)";
15.64 by (rtac iffI 1);
15.65 by (asm_full_simp_tac
15.66 (simpset() delsimps [zless_int] addsimps [zless_int RS sym]) 2);
15.67 @@ -57,48 +55,41 @@
15.68 by (Simp_tac 1);
15.69 qed "nat_less_iff";
15.70
15.71 -Goal "(int m = z) = (m = nat z & Numeral0 <= z)";
15.72 +Goal "(int m = z) = (m = nat z & 0 <= z)";
15.73 by (auto_tac (claset(), simpset() addsimps [nat_eq_iff2]));
15.74 qed "int_eq_iff";
15.75
15.76 -Addsimps [inst "z" "number_of ?v" int_eq_iff];
15.77 -
15.78
15.79 (*Users don't want to see (int 0), int(Suc 0) or w + - z*)
15.80 -Addsimps [int_0, int_Suc, symmetric zdiff_def];
15.81 +Addsimps (map symmetric [Zero_int_def, One_int_def, zdiff_def]);
15.82
15.83 -Goal "nat Numeral0 = 0";
15.84 +Goal "nat 0 = 0";
15.85 by (simp_tac (simpset() addsimps [nat_eq_iff]) 1);
15.86 qed "nat_0";
15.87
15.88 -Goal "nat Numeral1 = Suc 0";
15.89 -by (simp_tac (simpset() addsimps [nat_eq_iff]) 1);
15.90 +Goal "nat 1 = Suc 0";
15.91 +by (stac nat_eq_iff 1);
15.92 +by (Simp_tac 1);
15.93 qed "nat_1";
15.94
15.95 Goal "nat 2 = Suc (Suc 0)";
15.96 -by (simp_tac (simpset() addsimps [nat_eq_iff]) 1);
15.97 +by (stac nat_eq_iff 1);
15.98 +by (Simp_tac 1);
15.99 qed "nat_2";
15.100
15.101 -Goal "Numeral0 <= w ==> (nat w < nat z) = (w<z)";
15.102 +Goal "0 <= w ==> (nat w < nat z) = (w<z)";
15.103 by (case_tac "neg z" 1);
15.104 by (auto_tac (claset(), simpset() addsimps [nat_less_iff]));
15.105 by (auto_tac (claset() addIs [zless_trans],
15.106 simpset() addsimps [neg_eq_less_0, zle_def]));
15.107 qed "nat_less_eq_zless";
15.108
15.109 -Goal "Numeral0 < w | Numeral0 <= z ==> (nat w <= nat z) = (w<=z)";
15.110 +Goal "0 < w | 0 <= z ==> (nat w <= nat z) = (w<=z)";
15.111 by (auto_tac (claset(),
15.112 simpset() addsimps [linorder_not_less RS sym,
15.113 zless_nat_conj]));
15.114 qed "nat_le_eq_zle";
15.115
15.116 -(*Analogous to zadd_int, but more easily provable using the arithmetic in Bin*)
15.117 -Goal "n<=m --> int m - int n = int (m-n)";
15.118 -by (induct_thm_tac diff_induct "m n" 1);
15.119 -by Auto_tac;
15.120 -qed_spec_mp "zdiff_int";
15.121 -
15.122 -
15.123 (*** abs: absolute value, as an integer ****)
15.124
15.125 (* Simpler: use zabs_def as rewrite rule;
15.126 @@ -106,13 +97,17 @@
15.127 *)
15.128
15.129 Goalw [zabs_def]
15.130 - "P(abs(i::int)) = ((Numeral0 <= i --> P i) & (i < Numeral0 --> P(-i)))";
15.131 + "P(abs(i::int)) = ((0 <= i --> P i) & (i < 0 --> P(-i)))";
15.132 by(Simp_tac 1);
15.133 qed "zabs_split";
15.134
15.135 -Goal "Numeral0 <= abs (z::int)";
15.136 +Goal "0 <= abs (z::int)";
15.137 by (simp_tac (simpset() addsimps [zabs_def]) 1);
15.138 qed "zero_le_zabs";
15.139 AddIffs [zero_le_zabs];
15.140
15.141 +
15.142 +(*Not sure why this simprule is required!*)
15.143 +Addsimps [inst "z" "number_of ?v" int_eq_iff];
15.144 +
15.145 (*continued in IntArith.ML ...*)
16.1 --- a/src/HOL/Integ/int_factor_simprocs.ML Mon Oct 22 11:01:30 2001 +0200
16.2 +++ b/src/HOL/Integ/int_factor_simprocs.ML Mon Oct 22 11:54:22 2001 +0200
16.3 @@ -10,27 +10,27 @@
16.4
16.5 (** Factor cancellation theorems for "int" **)
16.6
16.7 -Goal "!!k::int. (k*m <= k*n) = ((Numeral0 < k --> m<=n) & (k < Numeral0 --> n<=m))";
16.8 +Goal "!!k::int. (k*m <= k*n) = ((0 < k --> m<=n) & (k < 0 --> n<=m))";
16.9 by (stac zmult_zle_cancel1 1);
16.10 by Auto_tac;
16.11 qed "int_mult_le_cancel1";
16.12
16.13 -Goal "!!k::int. (k*m < k*n) = ((Numeral0 < k & m<n) | (k < Numeral0 & n<m))";
16.14 +Goal "!!k::int. (k*m < k*n) = ((0 < k & m<n) | (k < 0 & n<m))";
16.15 by (stac zmult_zless_cancel1 1);
16.16 by Auto_tac;
16.17 qed "int_mult_less_cancel1";
16.18
16.19 -Goal "!!k::int. (k*m = k*n) = (k = Numeral0 | m=n)";
16.20 +Goal "!!k::int. (k*m = k*n) = (k = 0 | m=n)";
16.21 by Auto_tac;
16.22 qed "int_mult_eq_cancel1";
16.23
16.24 -Goal "!!k::int. k~=Numeral0 ==> (k*m) div (k*n) = (m div n)";
16.25 +Goal "!!k::int. k~=0 ==> (k*m) div (k*n) = (m div n)";
16.26 by (stac zdiv_zmult_zmult1 1);
16.27 by Auto_tac;
16.28 qed "int_mult_div_cancel1";
16.29
16.30 (*For ExtractCommonTermFun, cancelling common factors*)
16.31 -Goal "(k*m) div (k*n) = (if k = (Numeral0::int) then Numeral0 else m div n)";
16.32 +Goal "(k*m) div (k*n) = (if k = (0::int) then 0 else m div n)";
16.33 by (simp_tac (simpset() addsimps [int_mult_div_cancel1]) 1);
16.34 qed "int_mult_div_cancel_disj";
16.35
16.36 @@ -54,7 +54,7 @@
16.37
16.38 structure DivCancelNumeralFactor = CancelNumeralFactorFun
16.39 (open CancelNumeralFactorCommon
16.40 - val prove_conv = prove_conv "intdiv_cancel_numeral_factor"
16.41 + val prove_conv = Bin_Simprocs.prove_conv "intdiv_cancel_numeral_factor"
16.42 val mk_bal = HOLogic.mk_binop "Divides.op div"
16.43 val dest_bal = HOLogic.dest_bin "Divides.op div" HOLogic.intT
16.44 val cancel = int_mult_div_cancel1 RS trans
16.45 @@ -63,7 +63,7 @@
16.46
16.47 structure EqCancelNumeralFactor = CancelNumeralFactorFun
16.48 (open CancelNumeralFactorCommon
16.49 - val prove_conv = prove_conv "inteq_cancel_numeral_factor"
16.50 + val prove_conv = Bin_Simprocs.prove_conv "inteq_cancel_numeral_factor"
16.51 val mk_bal = HOLogic.mk_eq
16.52 val dest_bal = HOLogic.dest_bin "op =" HOLogic.intT
16.53 val cancel = int_mult_eq_cancel1 RS trans
16.54 @@ -72,7 +72,7 @@
16.55
16.56 structure LessCancelNumeralFactor = CancelNumeralFactorFun
16.57 (open CancelNumeralFactorCommon
16.58 - val prove_conv = prove_conv "intless_cancel_numeral_factor"
16.59 + val prove_conv = Bin_Simprocs.prove_conv "intless_cancel_numeral_factor"
16.60 val mk_bal = HOLogic.mk_binrel "op <"
16.61 val dest_bal = HOLogic.dest_bin "op <" HOLogic.intT
16.62 val cancel = int_mult_less_cancel1 RS trans
16.63 @@ -81,7 +81,7 @@
16.64
16.65 structure LeCancelNumeralFactor = CancelNumeralFactorFun
16.66 (open CancelNumeralFactorCommon
16.67 - val prove_conv = prove_conv "intle_cancel_numeral_factor"
16.68 + val prove_conv = Bin_Simprocs.prove_conv "intle_cancel_numeral_factor"
16.69 val mk_bal = HOLogic.mk_binrel "op <="
16.70 val dest_bal = HOLogic.dest_bin "op <=" HOLogic.intT
16.71 val cancel = int_mult_le_cancel1 RS trans
16.72 @@ -89,18 +89,18 @@
16.73 )
16.74
16.75 val int_cancel_numeral_factors =
16.76 - map prep_simproc
16.77 + map Bin_Simprocs.prep_simproc
16.78 [("inteq_cancel_numeral_factors",
16.79 - prep_pats ["(l::int) * m = n", "(l::int) = m * n"],
16.80 + Bin_Simprocs.prep_pats ["(l::int) * m = n", "(l::int) = m * n"],
16.81 EqCancelNumeralFactor.proc),
16.82 ("intless_cancel_numeral_factors",
16.83 - prep_pats ["(l::int) * m < n", "(l::int) < m * n"],
16.84 + Bin_Simprocs.prep_pats ["(l::int) * m < n", "(l::int) < m * n"],
16.85 LessCancelNumeralFactor.proc),
16.86 ("intle_cancel_numeral_factors",
16.87 - prep_pats ["(l::int) * m <= n", "(l::int) <= m * n"],
16.88 + Bin_Simprocs.prep_pats ["(l::int) * m <= n", "(l::int) <= m * n"],
16.89 LeCancelNumeralFactor.proc),
16.90 ("intdiv_cancel_numeral_factors",
16.91 - prep_pats ["((l::int) * m) div n", "(l::int) div (m * n)"],
16.92 + Bin_Simprocs.prep_pats ["((l::int) * m) div n", "(l::int) div (m * n)"],
16.93 DivCancelNumeralFactor.proc)];
16.94
16.95 end;
16.96 @@ -181,7 +181,7 @@
16.97
16.98 structure EqCancelFactor = ExtractCommonTermFun
16.99 (open CancelFactorCommon
16.100 - val prove_conv = prove_conv "int_eq_cancel_factor"
16.101 + val prove_conv = Bin_Simprocs.prove_conv "int_eq_cancel_factor"
16.102 val mk_bal = HOLogic.mk_eq
16.103 val dest_bal = HOLogic.dest_bin "op =" HOLogic.intT
16.104 val simplify_meta_eq = cancel_simplify_meta_eq int_mult_eq_cancel1
16.105 @@ -189,19 +189,19 @@
16.106
16.107 structure DivideCancelFactor = ExtractCommonTermFun
16.108 (open CancelFactorCommon
16.109 - val prove_conv = prove_conv "int_divide_cancel_factor"
16.110 + val prove_conv = Bin_Simprocs.prove_conv "int_divide_cancel_factor"
16.111 val mk_bal = HOLogic.mk_binop "Divides.op div"
16.112 val dest_bal = HOLogic.dest_bin "Divides.op div" HOLogic.intT
16.113 val simplify_meta_eq = cancel_simplify_meta_eq int_mult_div_cancel_disj
16.114 );
16.115
16.116 val int_cancel_factor =
16.117 - map prep_simproc
16.118 + map Bin_Simprocs.prep_simproc
16.119 [("int_eq_cancel_factor",
16.120 - prep_pats ["(l::int) * m = n", "(l::int) = m * n"],
16.121 + Bin_Simprocs.prep_pats ["(l::int) * m = n", "(l::int) = m * n"],
16.122 EqCancelFactor.proc),
16.123 ("int_divide_cancel_factor",
16.124 - prep_pats ["((l::int) * m) div n", "(l::int) div (m * n)"],
16.125 + Bin_Simprocs.prep_pats ["((l::int) * m) div n", "(l::int) div (m * n)"],
16.126 DivideCancelFactor.proc)];
16.127
16.128 end;
17.1 --- a/src/HOL/Integ/nat_bin.ML Mon Oct 22 11:01:30 2001 +0200
17.2 +++ b/src/HOL/Integ/nat_bin.ML Mon Oct 22 11:54:22 2001 +0200
17.3 @@ -13,29 +13,29 @@
17.4 Goal "nat (number_of w) = number_of w";
17.5 by (simp_tac (simpset() addsimps [nat_number_of_def]) 1);
17.6 qed "nat_number_of";
17.7 -Addsimps [nat_number_of];
17.8 -
17.9 -(*These rewrites should one day be re-oriented...*)
17.10 +Addsimps [nat_number_of, nat_0, nat_1];
17.11
17.12 Goal "Numeral0 = (0::nat)";
17.13 -by (simp_tac (HOL_basic_ss addsimps [nat_0, nat_number_of_def]) 1);
17.14 +by (simp_tac (simpset() addsimps [nat_number_of_def]) 1);
17.15 qed "numeral_0_eq_0";
17.16
17.17 Goal "Numeral1 = (1::nat)";
17.18 -by (simp_tac (HOL_basic_ss addsimps [nat_1, nat_number_of_def, One_nat_def]) 1);
17.19 +by (simp_tac (simpset() addsimps [nat_1, nat_number_of_def]) 1);
17.20 qed "numeral_1_eq_1";
17.21
17.22 -Goal "2 = Suc 1";
17.23 -by (simp_tac (HOL_basic_ss addsimps [nat_2, nat_number_of_def, One_nat_def]) 1);
17.24 +Goal "Numeral1 = Suc 0";
17.25 +by (simp_tac (simpset() addsimps [numeral_1_eq_1]) 1);
17.26 +qed "numeral_1_eq_Suc_0";
17.27 +
17.28 +Goalw [nat_number_of_def, One_nat_def] "2 = Suc 1";
17.29 +by (rtac nat_2 1);
17.30 qed "numeral_2_eq_2";
17.31
17.32 -bind_thm ("zero_eq_numeral_0", numeral_0_eq_0 RS sym);
17.33 -
17.34 (** int (coercion from nat to int) **)
17.35
17.36 (*"neg" is used in rewrite rules for binary comparisons*)
17.37 Goal "int (number_of v :: nat) = \
17.38 -\ (if neg (number_of v) then Numeral0 \
17.39 +\ (if neg (number_of v) then 0 \
17.40 \ else (number_of v :: int))";
17.41 by (simp_tac
17.42 (simpset_of Int.thy addsimps [neg_nat, nat_number_of_def,
17.43 @@ -45,45 +45,39 @@
17.44
17.45
17.46 val nat_bin_arith_setup =
17.47 - [Fast_Arith.map_data (fn {add_mono_thms, mult_mono_thms, inj_thms, lessD, simpset} =>
17.48 - {add_mono_thms = add_mono_thms, mult_mono_thms = mult_mono_thms,
17.49 - inj_thms = inj_thms,
17.50 - lessD = lessD,
17.51 - simpset = simpset addsimps [int_nat_number_of,
17.52 - not_neg_number_of_Pls,neg_number_of_Min,neg_number_of_BIT]})];
17.53 + [Fast_Arith.map_data
17.54 + (fn {add_mono_thms, mult_mono_thms, inj_thms, lessD, simpset} =>
17.55 + {add_mono_thms = add_mono_thms, mult_mono_thms = mult_mono_thms,
17.56 + inj_thms = inj_thms,
17.57 + lessD = lessD,
17.58 + simpset = simpset addsimps [int_nat_number_of, not_neg_number_of_Pls,
17.59 + neg_number_of_Min,neg_number_of_BIT]})];
17.60
17.61 (** Successor **)
17.62
17.63 -Goal "(Numeral0::int) <= z ==> Suc (nat z) = nat (Numeral1 + z)";
17.64 +Goal "(0::int) <= z ==> Suc (nat z) = nat (1 + z)";
17.65 by (rtac sym 1);
17.66 -by (asm_simp_tac (simpset() addsimps [nat_eq_iff]) 1);
17.67 +by (asm_simp_tac (simpset() addsimps [nat_eq_iff, int_Suc]) 1);
17.68 qed "Suc_nat_eq_nat_zadd1";
17.69
17.70 -Goal "Suc (number_of v) = \
17.71 -\ (if neg (number_of v) then Numeral1 else number_of (bin_succ v))";
17.72 +Goal "Suc (number_of v + n) = \
17.73 +\ (if neg (number_of v) then 1+n else number_of (bin_succ v) + n)";
17.74 by (simp_tac
17.75 (simpset_of Int.thy addsimps [neg_nat, nat_1, not_neg_eq_ge_0,
17.76 nat_number_of_def, int_Suc,
17.77 Suc_nat_eq_nat_zadd1, number_of_succ]) 1);
17.78 +qed "Suc_nat_number_of_add";
17.79 +
17.80 +Goal "Suc (number_of v) = \
17.81 +\ (if neg (number_of v) then 1 else number_of (bin_succ v))";
17.82 +by (cut_inst_tac [("n","0")] Suc_nat_number_of_add 1);
17.83 +by (asm_full_simp_tac (simpset() delcongs [if_weak_cong]) 1);
17.84 qed "Suc_nat_number_of";
17.85 Addsimps [Suc_nat_number_of];
17.86
17.87 -Goal "Suc (number_of v + n) = \
17.88 -\ (if neg (number_of v) then Numeral1+n else number_of (bin_succ v) + n)";
17.89 -by (Simp_tac 1);
17.90 -qed "Suc_nat_number_of_add";
17.91 -
17.92 -Goal "Suc Numeral0 = Numeral1";
17.93 -by (Simp_tac 1);
17.94 -qed "Suc_numeral_0_eq_1";
17.95 -
17.96 -Goal "Suc Numeral1 = 2";
17.97 -by (Simp_tac 1);
17.98 -qed "Suc_numeral_1_eq_2";
17.99 -
17.100 (** Addition **)
17.101
17.102 -Goal "[| (Numeral0::int) <= z; Numeral0 <= z' |] ==> nat (z+z') = nat z + nat z'";
17.103 +Goal "[| (0::int) <= z; 0 <= z' |] ==> nat (z+z') = nat z + nat z'";
17.104 by (rtac (inj_int RS injD) 1);
17.105 by (asm_simp_tac (simpset() addsimps [zadd_int RS sym]) 1);
17.106 qed "nat_add_distrib";
17.107 @@ -103,7 +97,7 @@
17.108
17.109 (** Subtraction **)
17.110
17.111 -Goal "[| (Numeral0::int) <= z'; z' <= z |] ==> nat (z-z') = nat z - nat z'";
17.112 +Goal "[| (0::int) <= z'; z' <= z |] ==> nat (z-z') = nat z - nat z'";
17.113 by (rtac (inj_int RS injD) 1);
17.114 by (asm_simp_tac (simpset() addsimps [zdiff_int RS sym, nat_le_eq_zle]) 1);
17.115 qed "nat_diff_distrib";
17.116 @@ -122,7 +116,7 @@
17.117 "(number_of v :: nat) - number_of v' = \
17.118 \ (if neg (number_of v') then number_of v \
17.119 \ else let d = number_of (bin_add v (bin_minus v')) in \
17.120 -\ if neg d then Numeral0 else nat d)";
17.121 +\ if neg d then 0 else nat d)";
17.122 by (simp_tac
17.123 (simpset_of Int.thy delcongs [if_weak_cong]
17.124 addsimps [not_neg_eq_ge_0, nat_0,
17.125 @@ -134,22 +128,22 @@
17.126
17.127 (** Multiplication **)
17.128
17.129 -Goal "(Numeral0::int) <= z ==> nat (z*z') = nat z * nat z'";
17.130 -by (case_tac "Numeral0 <= z'" 1);
17.131 +Goal "(0::int) <= z ==> nat (z*z') = nat z * nat z'";
17.132 +by (case_tac "0 <= z'" 1);
17.133 by (asm_full_simp_tac (simpset() addsimps [zmult_le_0_iff]) 2);
17.134 by (rtac (inj_int RS injD) 1);
17.135 by (asm_simp_tac (simpset() addsimps [zmult_int RS sym,
17.136 int_0_le_mult_iff]) 1);
17.137 qed "nat_mult_distrib";
17.138
17.139 -Goal "z <= (Numeral0::int) ==> nat(z*z') = nat(-z) * nat(-z')";
17.140 +Goal "z <= (0::int) ==> nat(z*z') = nat(-z) * nat(-z')";
17.141 by (rtac trans 1);
17.142 by (rtac nat_mult_distrib 2);
17.143 by Auto_tac;
17.144 qed "nat_mult_distrib_neg";
17.145
17.146 Goal "(number_of v :: nat) * number_of v' = \
17.147 -\ (if neg (number_of v) then Numeral0 else number_of (bin_mult v v'))";
17.148 +\ (if neg (number_of v) then 0 else number_of (bin_mult v v'))";
17.149 by (simp_tac
17.150 (simpset_of Int.thy addsimps [neg_nat, not_neg_eq_ge_0, nat_number_of_def,
17.151 nat_mult_distrib RS sym, number_of_mult,
17.152 @@ -161,15 +155,15 @@
17.153
17.154 (** Quotient **)
17.155
17.156 -Goal "(Numeral0::int) <= z ==> nat (z div z') = nat z div nat z'";
17.157 -by (case_tac "Numeral0 <= z'" 1);
17.158 +Goal "(0::int) <= z ==> nat (z div z') = nat z div nat z'";
17.159 +by (case_tac "0 <= z'" 1);
17.160 by (auto_tac (claset(),
17.161 simpset() addsimps [div_nonneg_neg_le0, DIVISION_BY_ZERO_DIV]));
17.162 -by (zdiv_undefined_case_tac "z' = Numeral0" 1);
17.163 +by (zdiv_undefined_case_tac "z' = 0" 1);
17.164 by (simp_tac (simpset() addsimps [numeral_0_eq_0, DIVISION_BY_ZERO_DIV]) 1);
17.165 by (auto_tac (claset() addSEs [nonneg_eq_int], simpset()));
17.166 by (rename_tac "m m'" 1);
17.167 -by (subgoal_tac "Numeral0 <= int m div int m'" 1);
17.168 +by (subgoal_tac "0 <= int m div int m'" 1);
17.169 by (asm_full_simp_tac
17.170 (simpset() addsimps [numeral_0_eq_0, pos_imp_zdiv_nonneg_iff]) 2);
17.171 by (rtac (inj_int RS injD) 1);
17.172 @@ -184,7 +178,7 @@
17.173 qed "nat_div_distrib";
17.174
17.175 Goal "(number_of v :: nat) div number_of v' = \
17.176 -\ (if neg (number_of v) then Numeral0 \
17.177 +\ (if neg (number_of v) then 0 \
17.178 \ else nat (number_of v div number_of v'))";
17.179 by (simp_tac
17.180 (simpset_of Int.thy addsimps [not_neg_eq_ge_0, nat_number_of_def, neg_nat,
17.181 @@ -197,12 +191,12 @@
17.182 (** Remainder **)
17.183
17.184 (*Fails if z'<0: the LHS collapses to (nat z) but the RHS doesn't*)
17.185 -Goal "[| (Numeral0::int) <= z; Numeral0 <= z' |] ==> nat (z mod z') = nat z mod nat z'";
17.186 -by (zdiv_undefined_case_tac "z' = Numeral0" 1);
17.187 +Goal "[| (0::int) <= z; 0 <= z' |] ==> nat (z mod z') = nat z mod nat z'";
17.188 +by (zdiv_undefined_case_tac "z' = 0" 1);
17.189 by (simp_tac (simpset() addsimps [numeral_0_eq_0, DIVISION_BY_ZERO_MOD]) 1);
17.190 by (auto_tac (claset() addSEs [nonneg_eq_int], simpset()));
17.191 by (rename_tac "m m'" 1);
17.192 -by (subgoal_tac "Numeral0 <= int m mod int m'" 1);
17.193 +by (subgoal_tac "0 <= int m mod int m'" 1);
17.194 by (asm_full_simp_tac
17.195 (simpset() addsimps [nat_less_iff, numeral_0_eq_0, pos_mod_sign]) 2);
17.196 by (rtac (inj_int RS injD) 1);
17.197 @@ -217,7 +211,7 @@
17.198 qed "nat_mod_distrib";
17.199
17.200 Goal "(number_of v :: nat) mod number_of v' = \
17.201 -\ (if neg (number_of v) then Numeral0 \
17.202 +\ (if neg (number_of v) then 0 \
17.203 \ else if neg (number_of v') then number_of v \
17.204 \ else nat (number_of v mod number_of v'))";
17.205 by (simp_tac
17.206 @@ -228,12 +222,36 @@
17.207
17.208 Addsimps [mod_nat_number_of];
17.209
17.210 +structure NatAbstractNumeralsData =
17.211 + struct
17.212 + val dest_eq = HOLogic.dest_eq o HOLogic.dest_Trueprop o concl_of
17.213 + val is_numeral = Bin_Simprocs.is_numeral
17.214 + val numeral_0_eq_0 = numeral_0_eq_0
17.215 + val numeral_1_eq_1 = numeral_1_eq_Suc_0
17.216 + val prove_conv = Bin_Simprocs.prove_conv_nohyps "nat_abstract_numerals"
17.217 + fun norm_tac simps = ALLGOALS (simp_tac (HOL_ss addsimps simps))
17.218 + val simplify_meta_eq = Bin_Simprocs.simplify_meta_eq
17.219 + end
17.220 +
17.221 +structure NatAbstractNumerals = AbstractNumeralsFun (NatAbstractNumeralsData)
17.222 +
17.223 +val nat_eval_numerals =
17.224 + map Bin_Simprocs.prep_simproc
17.225 + [("nat_div_eval_numerals",
17.226 + Bin_Simprocs.prep_pats ["(Suc 0) div m"],
17.227 + NatAbstractNumerals.proc div_nat_number_of),
17.228 + ("nat_mod_eval_numerals",
17.229 + Bin_Simprocs.prep_pats ["(Suc 0) mod m"],
17.230 + NatAbstractNumerals.proc mod_nat_number_of)];
17.231 +
17.232 +Addsimprocs nat_eval_numerals;
17.233 +
17.234
17.235 (*** Comparisons ***)
17.236
17.237 (** Equals (=) **)
17.238
17.239 -Goal "[| (Numeral0::int) <= z; Numeral0 <= z' |] ==> (nat z = nat z') = (z=z')";
17.240 +Goal "[| (0::int) <= z; 0 <= z' |] ==> (nat z = nat z') = (z=z')";
17.241 by (auto_tac (claset() addSEs [nonneg_eq_int], simpset()));
17.242 qed "eq_nat_nat_iff";
17.243
17.244 @@ -262,7 +280,7 @@
17.245 (simpset_of Int.thy addsimps [neg_nat, not_neg_eq_ge_0, nat_number_of_def,
17.246 nat_less_eq_zless, less_number_of_eq_neg,
17.247 nat_0]) 1);
17.248 -by (simp_tac (simpset_of Int.thy addsimps [neg_eq_less_int0, zminus_zless,
17.249 +by (simp_tac (simpset_of Int.thy addsimps [neg_eq_less_0, zminus_zless,
17.250 number_of_minus, zless_nat_eq_int_zless]) 1);
17.251 qed "less_nat_number_of";
17.252
17.253 @@ -278,24 +296,14 @@
17.254
17.255 Addsimps [le_nat_number_of_eq_not_less];
17.256
17.257 -(*** New versions of existing theorems involving 0, 1, 2 ***)
17.258
17.259 -(*Maps n to # n for n = 0, 1, 2*)
17.260 -val numeral_sym_ss =
17.261 - HOL_ss addsimps [numeral_0_eq_0 RS sym,
17.262 - numeral_1_eq_1 RS sym,
17.263 - numeral_2_eq_2 RS sym,
17.264 - Suc_numeral_1_eq_2, Suc_numeral_0_eq_1];
17.265 -
17.266 -fun rename_numerals th = simplify numeral_sym_ss (Thm.transfer (the_context ()) th);
17.267 -
17.268 -(*Maps # n to n for n = 0, 1, 2*)
17.269 +(*Maps #n to n for n = 0, 1, 2*)
17.270 bind_thms ("numerals", [numeral_0_eq_0, numeral_1_eq_1, numeral_2_eq_2]);
17.271 val numeral_ss = simpset() addsimps numerals;
17.272
17.273 (** Nat **)
17.274
17.275 -Goal "Numeral0 < n ==> n = Suc(n - Numeral1)";
17.276 +Goal "0 < n ==> n = Suc(n - 1)";
17.277 by (asm_full_simp_tac numeral_ss 1);
17.278 qed "Suc_pred'";
17.279
17.280 @@ -303,111 +311,48 @@
17.281 NOT suitable for rewriting because n recurs in the condition.*)
17.282 bind_thm ("expand_Suc", inst "n" "number_of ?v" Suc_pred');
17.283
17.284 -(** NatDef & Nat **)
17.285 -
17.286 -Addsimps (map rename_numerals [min_0L, min_0R, max_0L, max_0R]);
17.287 -
17.288 -AddIffs (map rename_numerals
17.289 - [Suc_not_Zero, Zero_not_Suc, zero_less_Suc, not_less0, less_one,
17.290 - le0, le_0_eq, neq0_conv, not_gr0]);
17.291 -
17.292 (** Arith **)
17.293
17.294 -(*Identity laws for + - * *)
17.295 -val basic_renamed_arith_simps =
17.296 - map rename_numerals
17.297 - [diff_0, diff_0_eq_0, add_0, add_0_right,
17.298 - mult_0, mult_0_right, mult_1, mult_1_right];
17.299 -
17.300 -(*Non-trivial simplifications*)
17.301 -val other_renamed_arith_simps =
17.302 - map rename_numerals
17.303 - [diff_is_0_eq, zero_less_diff,
17.304 - mult_is_0, zero_less_mult_iff, mult_eq_1_iff];
17.305 -
17.306 -Addsimps (basic_renamed_arith_simps @ other_renamed_arith_simps);
17.307 -
17.308 -AddIffs (map rename_numerals [add_is_0, add_gr_0]);
17.309 -
17.310 -Goal "Suc n = n + Numeral1";
17.311 +Goal "Suc n = n + 1";
17.312 by (asm_simp_tac numeral_ss 1);
17.313 qed "Suc_eq_add_numeral_1";
17.314
17.315 (* These two can be useful when m = number_of... *)
17.316
17.317 -Goal "(m::nat) + n = (if m=Numeral0 then n else Suc ((m - Numeral1) + n))";
17.318 +Goal "(m::nat) + n = (if m=0 then n else Suc ((m - 1) + n))";
17.319 by (case_tac "m" 1);
17.320 by (ALLGOALS (asm_simp_tac numeral_ss));
17.321 qed "add_eq_if";
17.322
17.323 -Goal "(m::nat) * n = (if m=Numeral0 then Numeral0 else n + ((m - Numeral1) * n))";
17.324 +Goal "(m::nat) * n = (if m=0 then 0 else n + ((m - 1) * n))";
17.325 by (case_tac "m" 1);
17.326 by (ALLGOALS (asm_simp_tac numeral_ss));
17.327 qed "mult_eq_if";
17.328
17.329 -Goal "(p ^ m :: nat) = (if m=Numeral0 then Numeral1 else p * (p ^ (m - Numeral1)))";
17.330 +Goal "(p ^ m :: nat) = (if m=0 then 1 else p * (p ^ (m - 1)))";
17.331 by (case_tac "m" 1);
17.332 by (ALLGOALS (asm_simp_tac numeral_ss));
17.333 qed "power_eq_if";
17.334
17.335 -Goal "[| Numeral0<n; Numeral0<m |] ==> m - n < (m::nat)";
17.336 +Goal "[| 0<n; 0<m |] ==> m - n < (m::nat)";
17.337 by (asm_full_simp_tac (numeral_ss addsimps [diff_less]) 1);
17.338 qed "diff_less'";
17.339
17.340 Addsimps [inst "n" "number_of ?v" diff_less'];
17.341
17.342 -(*various theorems that aren't in the default simpset*)
17.343 -bind_thm ("add_is_one'", rename_numerals add_is_1);
17.344 -bind_thm ("zero_induct'", rename_numerals zero_induct);
17.345 -bind_thm ("diff_self_eq_0'", rename_numerals diff_self_eq_0);
17.346 -bind_thm ("mult_eq_self_implies_10'", rename_numerals mult_eq_self_implies_10);
17.347 -
17.348 -(** Divides **)
17.349 -
17.350 -Addsimps (map rename_numerals [mod_1, mod_0, div_1, div_0]);
17.351 -AddIffs (map rename_numerals [dvd_1_left, dvd_0_right]);
17.352 -
17.353 -(*useful?*)
17.354 -bind_thm ("mod_self'", rename_numerals mod_self);
17.355 -bind_thm ("div_self'", rename_numerals div_self);
17.356 -bind_thm ("div_less'", rename_numerals div_less);
17.357 -bind_thm ("mod_mult_self_is_zero'", rename_numerals mod_mult_self_is_0);
17.358 -
17.359 (** Power **)
17.360
17.361 -Goal "(p::nat) ^ Numeral0 = Numeral1";
17.362 -by (simp_tac numeral_ss 1);
17.363 -qed "power_zero";
17.364 -
17.365 -Goal "(p::nat) ^ Numeral1 = p";
17.366 -by (simp_tac numeral_ss 1);
17.367 -qed "power_one";
17.368 -Addsimps [power_zero, power_one];
17.369 -
17.370 Goal "(p::nat) ^ 2 = p*p";
17.371 by (simp_tac numeral_ss 1);
17.372 qed "power_two";
17.373
17.374 -Goal "Numeral0 < (i::nat) ==> Numeral0 < i^n";
17.375 -by (asm_simp_tac numeral_ss 1);
17.376 -qed "zero_less_power'";
17.377 -Addsimps [zero_less_power'];
17.378 -
17.379 -bind_thm ("binomial_zero", rename_numerals binomial_0);
17.380 -bind_thm ("binomial_Suc'", rename_numerals binomial_Suc);
17.381 -bind_thm ("binomial_n_n'", rename_numerals binomial_n_n);
17.382 -
17.383 -(*binomial_0_Suc doesn't work well on numerals*)
17.384 -Addsimps (map rename_numerals [binomial_n_0, binomial_zero, binomial_1]);
17.385 -
17.386 -Addsimps [rename_numerals card_Pow];
17.387
17.388 (*** Comparisons involving (0::nat) ***)
17.389
17.390 Goal "(number_of v = (0::nat)) = \
17.391 \ (if neg (number_of v) then True else iszero (number_of v))";
17.392 -by (simp_tac (simpset() addsimps [numeral_0_eq_0 RS sym]) 1);
17.393 -qed "eq_number_of_0";
17.394 +by (simp_tac (simpset() addsimps [numeral_0_eq_0 RS sym, iszero_0]) 1);
17.395 +qed "eq_number_of_0";
17.396
17.397 Goal "((0::nat) = number_of v) = \
17.398 \ (if neg (number_of v) then True else iszero (number_of v))";
17.399 @@ -422,7 +367,7 @@
17.400 Addsimps [eq_number_of_0, eq_0_number_of, less_0_number_of];
17.401
17.402 Goal "neg (number_of v) ==> number_of v = (0::nat)";
17.403 -by (asm_simp_tac (simpset() addsimps [numeral_0_eq_0 RS sym]) 1);
17.404 +by (asm_simp_tac (simpset() addsimps [numeral_0_eq_0 RS sym, iszero_0]) 1);
17.405 qed "neg_imp_number_of_eq_0";
17.406
17.407
17.408 @@ -489,13 +434,13 @@
17.409 le_number_of_Suc, le_Suc_number_of];
17.410
17.411 (* Push int(.) inwards: *)
17.412 -Addsimps [int_Suc,zadd_int RS sym];
17.413 +Addsimps [zadd_int RS sym];
17.414
17.415 Goal "(m+m = n+n) = (m = (n::int))";
17.416 by Auto_tac;
17.417 val lemma1 = result();
17.418
17.419 -Goal "m+m ~= int (Suc 0) + n + n";
17.420 +Goal "m+m ~= (1::int) + n + n";
17.421 by Auto_tac;
17.422 by (dres_inst_tac [("f", "%x. x mod 2")] arg_cong 1);
17.423 by (full_simp_tac (simpset() addsimps [zmod_zadd1_eq]) 1);
17.424 @@ -536,7 +481,7 @@
17.425 (*** Further lemmas about "nat" ***)
17.426
17.427 Goal "nat (abs (w * z)) = nat (abs w) * nat (abs z)";
17.428 -by (case_tac "z=Numeral0 | w=Numeral0" 1);
17.429 +by (case_tac "z=0 | w=0" 1);
17.430 by Auto_tac;
17.431 by (simp_tac (simpset() addsimps [zabs_def, nat_mult_distrib RS sym,
17.432 nat_mult_distrib_neg RS sym, zmult_less_0_iff]) 1);
18.1 --- a/src/HOL/Integ/nat_simprocs.ML Mon Oct 22 11:01:30 2001 +0200
18.2 +++ b/src/HOL/Integ/nat_simprocs.ML Mon Oct 22 11:54:22 2001 +0200
18.3 @@ -66,19 +66,19 @@
18.4
18.5 (** For cancel_numeral_factors **)
18.6
18.7 -Goal "(Numeral0::nat) < k ==> (k*m <= k*n) = (m<=n)";
18.8 +Goal "(0::nat) < k ==> (k*m <= k*n) = (m<=n)";
18.9 by Auto_tac;
18.10 qed "nat_mult_le_cancel1";
18.11
18.12 -Goal "(Numeral0::nat) < k ==> (k*m < k*n) = (m<n)";
18.13 +Goal "(0::nat) < k ==> (k*m < k*n) = (m<n)";
18.14 by Auto_tac;
18.15 qed "nat_mult_less_cancel1";
18.16
18.17 -Goal "(Numeral0::nat) < k ==> (k*m = k*n) = (m=n)";
18.18 +Goal "(0::nat) < k ==> (k*m = k*n) = (m=n)";
18.19 by Auto_tac;
18.20 qed "nat_mult_eq_cancel1";
18.21
18.22 -Goal "(Numeral0::nat) < k ==> (k*m) div (k*n) = (m div n)";
18.23 +Goal "(0::nat) < k ==> (k*m) div (k*n) = (m div n)";
18.24 by Auto_tac;
18.25 qed "nat_mult_div_cancel1";
18.26
18.27 @@ -105,6 +105,14 @@
18.28 structure Nat_Numeral_Simprocs =
18.29 struct
18.30
18.31 +(*Maps n to #n for n = 0, 1, 2*)
18.32 +val numeral_syms =
18.33 + [numeral_0_eq_0 RS sym, numeral_1_eq_1 RS sym, numeral_2_eq_2 RS sym];
18.34 +val numeral_sym_ss = HOL_ss addsimps numeral_syms;
18.35 +
18.36 +fun rename_numerals th =
18.37 + simplify numeral_sym_ss (Thm.transfer (the_context ()) th);
18.38 +
18.39 (*Utilities*)
18.40
18.41 fun mk_numeral n = HOLogic.number_of_const HOLogic.natT $ HOLogic.mk_bin n;
18.42 @@ -125,13 +133,13 @@
18.43 val zero = mk_numeral 0;
18.44 val mk_plus = HOLogic.mk_binop "op +";
18.45
18.46 -(*Thus mk_sum[t] yields t+Numeral0; longer sums don't have a trailing zero*)
18.47 +(*Thus mk_sum[t] yields t+0; longer sums don't have a trailing zero*)
18.48 fun mk_sum [] = zero
18.49 | mk_sum [t,u] = mk_plus (t, u)
18.50 | mk_sum (t :: ts) = mk_plus (t, mk_sum ts);
18.51
18.52 (*this version ALWAYS includes a trailing zero*)
18.53 -fun long_mk_sum [] = zero
18.54 +fun long_mk_sum [] = HOLogic.zero
18.55 | long_mk_sum (t :: ts) = mk_plus (t, mk_sum ts);
18.56
18.57 val dest_plus = HOLogic.dest_bin "op +" HOLogic.natT;
18.58 @@ -153,9 +161,8 @@
18.59
18.60 val trans_tac = Int_Numeral_Simprocs.trans_tac;
18.61
18.62 -val prove_conv = Int_Numeral_Simprocs.prove_conv;
18.63 -
18.64 -val bin_simps = [add_nat_number_of, nat_number_of_add_left,
18.65 +val bin_simps = [numeral_0_eq_0 RS sym, numeral_1_eq_1 RS sym,
18.66 + add_nat_number_of, nat_number_of_add_left,
18.67 diff_nat_number_of, le_nat_number_of_eq_not_less,
18.68 less_nat_number_of, mult_nat_number_of,
18.69 thm "Let_number_of", nat_number_of] @
18.70 @@ -204,14 +211,14 @@
18.71 handle TERM _ => find_first_coeff (t::past) u terms;
18.72
18.73
18.74 -(*Simplify Numeral1*n and n*Numeral1 to n*)
18.75 -val add_0s = map rename_numerals [add_0, add_0_right];
18.76 +(*Simplify 1*n and n*1 to n*)
18.77 +val add_0s = map rename_numerals [add_0, add_0_right];
18.78 val mult_1s = map rename_numerals [mult_1, mult_1_right];
18.79
18.80 (*Final simplification: cancel + and *; replace Numeral0 by 0 and Numeral1 by 1*)
18.81 val simplify_meta_eq =
18.82 Int_Numeral_Simprocs.simplify_meta_eq
18.83 - [numeral_0_eq_0, numeral_1_eq_1, add_0, add_0_right,
18.84 + [numeral_0_eq_0, numeral_1_eq_Suc_0, add_0, add_0_right,
18.85 mult_0, mult_0_right, mult_1, mult_1_right];
18.86
18.87
18.88 @@ -243,19 +250,19 @@
18.89 val find_first_coeff = find_first_coeff []
18.90 val trans_tac = trans_tac
18.91 val norm_tac = ALLGOALS
18.92 - (simp_tac (HOL_ss addsimps add_0s@mult_1s@
18.93 - [add_0, Suc_eq_add_numeral_1]@add_ac))
18.94 + (simp_tac (HOL_ss addsimps numeral_syms@add_0s@mult_1s@
18.95 + [Suc_eq_add_numeral_1] @ add_ac))
18.96 THEN ALLGOALS (simp_tac
18.97 (HOL_ss addsimps bin_simps@add_ac@mult_ac))
18.98 val numeral_simp_tac = ALLGOALS
18.99 - (simp_tac (HOL_ss addsimps [numeral_0_eq_0 RS sym]@add_0s@bin_simps))
18.100 + (simp_tac (HOL_ss addsimps add_0s@bin_simps))
18.101 val simplify_meta_eq = simplify_meta_eq
18.102 end;
18.103
18.104
18.105 structure EqCancelNumerals = CancelNumeralsFun
18.106 (open CancelNumeralsCommon
18.107 - val prove_conv = prove_conv "nateq_cancel_numerals"
18.108 + val prove_conv = Bin_Simprocs.prove_conv "nateq_cancel_numerals"
18.109 val mk_bal = HOLogic.mk_eq
18.110 val dest_bal = HOLogic.dest_bin "op =" HOLogic.natT
18.111 val bal_add1 = nat_eq_add_iff1 RS trans
18.112 @@ -264,7 +271,7 @@
18.113
18.114 structure LessCancelNumerals = CancelNumeralsFun
18.115 (open CancelNumeralsCommon
18.116 - val prove_conv = prove_conv "natless_cancel_numerals"
18.117 + val prove_conv = Bin_Simprocs.prove_conv "natless_cancel_numerals"
18.118 val mk_bal = HOLogic.mk_binrel "op <"
18.119 val dest_bal = HOLogic.dest_bin "op <" HOLogic.natT
18.120 val bal_add1 = nat_less_add_iff1 RS trans
18.121 @@ -273,7 +280,7 @@
18.122
18.123 structure LeCancelNumerals = CancelNumeralsFun
18.124 (open CancelNumeralsCommon
18.125 - val prove_conv = prove_conv "natle_cancel_numerals"
18.126 + val prove_conv = Bin_Simprocs.prove_conv "natle_cancel_numerals"
18.127 val mk_bal = HOLogic.mk_binrel "op <="
18.128 val dest_bal = HOLogic.dest_bin "op <=" HOLogic.natT
18.129 val bal_add1 = nat_le_add_iff1 RS trans
18.130 @@ -282,7 +289,7 @@
18.131
18.132 structure DiffCancelNumerals = CancelNumeralsFun
18.133 (open CancelNumeralsCommon
18.134 - val prove_conv = prove_conv "natdiff_cancel_numerals"
18.135 + val prove_conv = Bin_Simprocs.prove_conv "natdiff_cancel_numerals"
18.136 val mk_bal = HOLogic.mk_binop "op -"
18.137 val dest_bal = HOLogic.dest_bin "op -" HOLogic.natT
18.138 val bal_add1 = nat_diff_add_eq1 RS trans
18.139 @@ -324,16 +331,15 @@
18.140 val mk_coeff = mk_coeff
18.141 val dest_coeff = dest_coeff
18.142 val left_distrib = left_add_mult_distrib RS trans
18.143 - val prove_conv =
18.144 - Int_Numeral_Simprocs.prove_conv_nohyps "nat_combine_numerals"
18.145 + val prove_conv = Bin_Simprocs.prove_conv_nohyps "nat_combine_numerals"
18.146 val trans_tac = trans_tac
18.147 val norm_tac = ALLGOALS
18.148 - (simp_tac (HOL_ss addsimps add_0s@mult_1s@
18.149 - [add_0, Suc_eq_add_numeral_1]@add_ac))
18.150 + (simp_tac (HOL_ss addsimps numeral_syms@add_0s@mult_1s@
18.151 + [Suc_eq_add_numeral_1] @ add_ac))
18.152 THEN ALLGOALS (simp_tac
18.153 (HOL_ss addsimps bin_simps@add_ac@mult_ac))
18.154 val numeral_simp_tac = ALLGOALS
18.155 - (simp_tac (HOL_ss addsimps [numeral_0_eq_0 RS sym]@add_0s@bin_simps))
18.156 + (simp_tac (HOL_ss addsimps add_0s@bin_simps))
18.157 val simplify_meta_eq = simplify_meta_eq
18.158 end;
18.159
18.160 @@ -352,8 +358,8 @@
18.161 val mk_coeff = mk_coeff
18.162 val dest_coeff = dest_coeff
18.163 val trans_tac = trans_tac
18.164 - val norm_tac = ALLGOALS (simp_tac (HOL_ss addsimps
18.165 - [Suc_eq_add_numeral_1]@mult_1s))
18.166 + val norm_tac = ALLGOALS
18.167 + (simp_tac (HOL_ss addsimps [Suc_eq_add_numeral_1]@mult_1s))
18.168 THEN ALLGOALS (simp_tac (HOL_ss addsimps bin_simps@mult_ac))
18.169 val numeral_simp_tac = ALLGOALS (simp_tac (HOL_ss addsimps bin_simps))
18.170 val simplify_meta_eq = simplify_meta_eq
18.171 @@ -361,7 +367,7 @@
18.172
18.173 structure DivCancelNumeralFactor = CancelNumeralFactorFun
18.174 (open CancelNumeralFactorCommon
18.175 - val prove_conv = prove_conv "natdiv_cancel_numeral_factor"
18.176 + val prove_conv = Bin_Simprocs.prove_conv "natdiv_cancel_numeral_factor"
18.177 val mk_bal = HOLogic.mk_binop "Divides.op div"
18.178 val dest_bal = HOLogic.dest_bin "Divides.op div" HOLogic.natT
18.179 val cancel = nat_mult_div_cancel1 RS trans
18.180 @@ -370,7 +376,7 @@
18.181
18.182 structure EqCancelNumeralFactor = CancelNumeralFactorFun
18.183 (open CancelNumeralFactorCommon
18.184 - val prove_conv = prove_conv "nateq_cancel_numeral_factor"
18.185 + val prove_conv = Bin_Simprocs.prove_conv "nateq_cancel_numeral_factor"
18.186 val mk_bal = HOLogic.mk_eq
18.187 val dest_bal = HOLogic.dest_bin "op =" HOLogic.natT
18.188 val cancel = nat_mult_eq_cancel1 RS trans
18.189 @@ -379,7 +385,7 @@
18.190
18.191 structure LessCancelNumeralFactor = CancelNumeralFactorFun
18.192 (open CancelNumeralFactorCommon
18.193 - val prove_conv = prove_conv "natless_cancel_numeral_factor"
18.194 + val prove_conv = Bin_Simprocs.prove_conv "natless_cancel_numeral_factor"
18.195 val mk_bal = HOLogic.mk_binrel "op <"
18.196 val dest_bal = HOLogic.dest_bin "op <" HOLogic.natT
18.197 val cancel = nat_mult_less_cancel1 RS trans
18.198 @@ -388,7 +394,7 @@
18.199
18.200 structure LeCancelNumeralFactor = CancelNumeralFactorFun
18.201 (open CancelNumeralFactorCommon
18.202 - val prove_conv = prove_conv "natle_cancel_numeral_factor"
18.203 + val prove_conv = Bin_Simprocs.prove_conv "natle_cancel_numeral_factor"
18.204 val mk_bal = HOLogic.mk_binrel "op <="
18.205 val dest_bal = HOLogic.dest_bin "op <=" HOLogic.natT
18.206 val cancel = nat_mult_le_cancel1 RS trans
18.207 @@ -443,7 +449,7 @@
18.208
18.209 structure EqCancelFactor = ExtractCommonTermFun
18.210 (open CancelFactorCommon
18.211 - val prove_conv = prove_conv "nat_eq_cancel_factor"
18.212 + val prove_conv = Bin_Simprocs.prove_conv "nat_eq_cancel_factor"
18.213 val mk_bal = HOLogic.mk_eq
18.214 val dest_bal = HOLogic.dest_bin "op =" HOLogic.natT
18.215 val simplify_meta_eq = cancel_simplify_meta_eq nat_mult_eq_cancel_disj
18.216 @@ -451,7 +457,7 @@
18.217
18.218 structure LessCancelFactor = ExtractCommonTermFun
18.219 (open CancelFactorCommon
18.220 - val prove_conv = prove_conv "nat_less_cancel_factor"
18.221 + val prove_conv = Bin_Simprocs.prove_conv "nat_less_cancel_factor"
18.222 val mk_bal = HOLogic.mk_binrel "op <"
18.223 val dest_bal = HOLogic.dest_bin "op <" HOLogic.natT
18.224 val simplify_meta_eq = cancel_simplify_meta_eq nat_mult_less_cancel_disj
18.225 @@ -459,7 +465,7 @@
18.226
18.227 structure LeCancelFactor = ExtractCommonTermFun
18.228 (open CancelFactorCommon
18.229 - val prove_conv = prove_conv "nat_leq_cancel_factor"
18.230 + val prove_conv = Bin_Simprocs.prove_conv "nat_leq_cancel_factor"
18.231 val mk_bal = HOLogic.mk_binrel "op <="
18.232 val dest_bal = HOLogic.dest_bin "op <=" HOLogic.natT
18.233 val simplify_meta_eq = cancel_simplify_meta_eq nat_mult_le_cancel_disj
18.234 @@ -467,7 +473,7 @@
18.235
18.236 structure DivideCancelFactor = ExtractCommonTermFun
18.237 (open CancelFactorCommon
18.238 - val prove_conv = prove_conv "nat_divide_cancel_factor"
18.239 + val prove_conv = Bin_Simprocs.prove_conv "nat_divide_cancel_factor"
18.240 val mk_bal = HOLogic.mk_binop "Divides.op div"
18.241 val dest_bal = HOLogic.dest_bin "Divides.op div" HOLogic.natT
18.242 val simplify_meta_eq = cancel_simplify_meta_eq nat_mult_div_cancel_disj
18.243 @@ -514,7 +520,7 @@
18.244 test "Suc u - 2 = y";
18.245 test "Suc (Suc (Suc u)) - 2 = y";
18.246 test "(i + j + 2 + (k::nat)) - 1 = y";
18.247 -test "(i + j + Numeral1 + (k::nat)) - 2 = y";
18.248 +test "(i + j + 1 + (k::nat)) - 2 = y";
18.249
18.250 test "(2*x + (u*v) + y) - v*3*u = (w::nat)";
18.251 test "(2*x*u*v + 5 + (u*v)*4 + y) - v*u*4 = (w::nat)";
18.252 @@ -590,7 +596,8 @@
18.253
18.254 (* reduce contradictory <= to False *)
18.255 val add_rules =
18.256 - [add_nat_number_of, diff_nat_number_of, mult_nat_number_of,
18.257 + [thm "Let_number_of", thm "Let_0", thm "Let_1", nat_0, nat_1,
18.258 + add_nat_number_of, diff_nat_number_of, mult_nat_number_of,
18.259 eq_nat_number_of, less_nat_number_of, le_nat_number_of_eq_not_less,
18.260 le_Suc_number_of,le_number_of_Suc,
18.261 less_Suc_number_of,less_number_of_Suc,
18.262 @@ -610,7 +617,6 @@
18.263 {add_mono_thms = add_mono_thms, mult_mono_thms = mult_mono_thms,
18.264 inj_thms = inj_thms, lessD = lessD,
18.265 simpset = simpset addsimps add_rules
18.266 - addsimps basic_renamed_arith_simps
18.267 addsimprocs simprocs})];
18.268
18.269 end;
19.1 --- a/src/HOL/Library/Multiset.thy Mon Oct 22 11:01:30 2001 +0200
19.2 +++ b/src/HOL/Library/Multiset.thy Mon Oct 22 11:54:22 2001 +0200
19.3 @@ -274,18 +274,8 @@
19.4 apply (simp (no_asm) add: expand_fun_eq)
19.5 apply (rule conjI)
19.6 apply force
19.7 - apply clarify
19.8 - apply (rule conjI)
19.9 - apply blast
19.10 - apply clarify
19.11 - apply (rule iffI)
19.12 - apply (rule conjI)
19.13 - apply clarify
19.14 - apply (rule conjI)
19.15 - apply (simp add: eq_sym_conv) (* FIXME blast fails !? *)
19.16 - apply fast
19.17 - apply simp
19.18 - apply force
19.19 + apply safe
19.20 + apply (simp_all add: eq_sym_conv)
19.21 done
19.22
19.23 (*
20.1 --- a/src/HOL/List.ML Mon Oct 22 11:01:30 2001 +0200
20.2 +++ b/src/HOL/List.ML Mon Oct 22 11:54:22 2001 +0200
20.3 @@ -232,23 +232,23 @@
20.4 local
20.5
20.6 val list_eq_pattern =
20.7 - Thm.read_cterm (Theory.sign_of (the_context ())) ("(xs::'a list) = ys",HOLogic.boolT);
20.8 + Thm.read_cterm (Theory.sign_of (the_context ())) ("(xs::'a list) = ys",HOLogic.boolT)
20.9
20.10 fun last (cons as Const("List.list.Cons",_) $ _ $ xs) =
20.11 (case xs of Const("List.list.Nil",_) => cons | _ => last xs)
20.12 | last (Const("List.op @",_) $ _ $ ys) = last ys
20.13 - | last t = t;
20.14 + | last t = t
20.15
20.16 fun list1 (Const("List.list.Cons",_) $ _ $ Const("List.list.Nil",_)) = true
20.17 - | list1 _ = false;
20.18 + | list1 _ = false
20.19
20.20 fun butlast ((cons as Const("List.list.Cons",_) $ x) $ xs) =
20.21 (case xs of Const("List.list.Nil",_) => xs | _ => cons $ butlast xs)
20.22 | butlast ((app as Const("List.op @",_) $ xs) $ ys) = app $ butlast ys
20.23 - | butlast xs = Const("List.list.Nil",fastype_of xs);
20.24 + | butlast xs = Const("List.list.Nil",fastype_of xs)
20.25
20.26 val rearr_tac =
20.27 - simp_tac (HOL_basic_ss addsimps [append_assoc,append_Nil,append_Cons]);
20.28 + simp_tac (HOL_basic_ss addsimps [append_assoc,append_Nil,append_Cons])
20.29
20.30 fun list_eq sg _ (F as (eq as Const(_,eqT)) $ lhs $ rhs) =
20.31 let
20.32 @@ -272,9 +272,9 @@
20.33 if lastl aconv lastr
20.34 then rearr append_same_eq
20.35 else None
20.36 - end;
20.37 + end
20.38 in
20.39 -val list_eq_simproc = mk_simproc "list_eq" [list_eq_pattern] list_eq;
20.40 +val list_eq_simproc = mk_simproc "list_eq" [list_eq_pattern] list_eq
20.41 end;
20.42
20.43 Addsimprocs [list_eq_simproc];
20.44 @@ -1501,24 +1501,19 @@
20.45 Addsimps [sublist_upt_eq_take];
20.46
20.47
20.48 -(*** Versions of some theorems above using binary numerals ***)
20.49 -
20.50 -AddIffs (map rename_numerals
20.51 - [length_0_conv, length_greater_0_conv, sum_eq_0_conv]);
20.52 -
20.53 -Goal "take n (x#xs) = (if n = Numeral0 then [] else x # take (n - Numeral1) xs)";
20.54 +Goal "take n (x#xs) = (if n=0 then [] else x # take (n - 1) xs)";
20.55 by (case_tac "n" 1);
20.56 by (ALLGOALS
20.57 (asm_simp_tac (simpset() addsimps [numeral_0_eq_0, numeral_1_eq_1])));
20.58 qed "take_Cons'";
20.59
20.60 -Goal "drop n (x#xs) = (if n = Numeral0 then x#xs else drop (n - Numeral1) xs)";
20.61 +Goal "drop n (x#xs) = (if n=0 then x#xs else drop (n - 1) xs)";
20.62 by (case_tac "n" 1);
20.63 by (ALLGOALS
20.64 (asm_simp_tac (simpset() addsimps [numeral_0_eq_0, numeral_1_eq_1])));
20.65 qed "drop_Cons'";
20.66
20.67 -Goal "(x#xs)!n = (if n = Numeral0 then x else xs!(n - Numeral1))";
20.68 +Goal "(x#xs)!n = (if n=0 then x else xs!(n - 1))";
20.69 by (case_tac "n" 1);
20.70 by (ALLGOALS
20.71 (asm_simp_tac (simpset() addsimps [numeral_0_eq_0, numeral_1_eq_1])));
21.1 --- a/src/HOL/Nat.ML Mon Oct 22 11:01:30 2001 +0200
21.2 +++ b/src/HOL/Nat.ML Mon Oct 22 11:54:22 2001 +0200
21.3 @@ -243,9 +243,8 @@
21.4 by (Auto_tac);
21.5 qed "add_is_1";
21.6
21.7 -Goal "(Suc 0 = m+n) = (m=Suc 0 & n=0 | m=0 & n= Suc 0)";
21.8 -by (case_tac "m" 1);
21.9 -by (Auto_tac);
21.10 +Goal "(Suc 0 = m+n) = (m = Suc 0 & n=0 | m=0 & n = Suc 0)";
21.11 +by (rtac ([eq_commute, add_is_1] MRS trans) 1);
21.12 qed "one_is_add";
21.13
21.14 Goal "!!m::nat. (0<m+n) = (0<m | 0<n)";
22.1 --- a/src/HOL/NatDef.ML Mon Oct 22 11:01:30 2001 +0200
22.2 +++ b/src/HOL/NatDef.ML Mon Oct 22 11:54:22 2001 +0200
22.3 @@ -450,25 +450,15 @@
22.4 bind_thms ("not_less_simps", [not_less_less_Suc_eq, leD RS not_less_less_Suc_eq]);
22.5
22.6
22.7 -(** Re-orientation of the equations 0=x and Suc n = x. *
22.8 -
22.9 - The condition "True" is a hack to prevent looping for e.g. Suc m = Suc n.
22.10 - Conditional rewrite rules are tried after unconditional ones.
22.11 -**)
22.12 +(** Re-orientation of the equations 0=x and 1=x.
22.13 + No longer added as simprules (they loop)
22.14 + but via reorient_simproc in Bin **)
22.15
22.16 (*Polymorphic, not just for "nat"*)
22.17 -Goal "True ==> (0 = x) = (x = 0)";
22.18 +Goal "(0 = x) = (x = 0)";
22.19 by Auto_tac;
22.20 qed "zero_reorient";
22.21 -Addsimps [zero_reorient];
22.22
22.23 -(*Polymorphic, not just for "nat"*)
22.24 -Goal "True ==> (1 = x) = (x = 1)";
22.25 +Goal "(1 = x) = (x = 1)";
22.26 by Auto_tac;
22.27 qed "one_reorient";
22.28 -Addsimps [one_reorient];
22.29 -
22.30 -Goal "True ==> (Suc (Suc 0) = x) = (x = Suc (Suc 0))"; (* FIXME !? *)
22.31 -by Auto_tac;
22.32 -qed "two_reorient";
22.33 -Addsimps [two_reorient];
23.1 --- a/src/HOL/NumberTheory/Chinese.thy Mon Oct 22 11:01:30 2001 +0200
23.2 +++ b/src/HOL/NumberTheory/Chinese.thy Mon Oct 22 11:54:22 2001 +0200
23.3 @@ -45,11 +45,11 @@
23.4 defs
23.5 m_cond_def:
23.6 "m_cond n mf ==
23.7 - (\<forall>i. i \<le> n --> Numeral0 < mf i) \<and>
23.8 - (\<forall>i j. i \<le> n \<and> j \<le> n \<and> i \<noteq> j --> zgcd (mf i, mf j) = Numeral1)"
23.9 + (\<forall>i. i \<le> n --> 0 < mf i) \<and>
23.10 + (\<forall>i j. i \<le> n \<and> j \<le> n \<and> i \<noteq> j --> zgcd (mf i, mf j) = 1)"
23.11
23.12 km_cond_def:
23.13 - "km_cond n kf mf == \<forall>i. i \<le> n --> zgcd (kf i, mf i) = Numeral1"
23.14 + "km_cond n kf mf == \<forall>i. i \<le> n --> zgcd (kf i, mf i) = 1"
23.15
23.16 lincong_sol_def:
23.17 "lincong_sol n kf bf mf x == \<forall>i. i \<le> n --> zcong (kf i * x) (bf i) (mf i)"
23.18 @@ -63,8 +63,8 @@
23.19 xilin_sol_def:
23.20 "xilin_sol i n kf bf mf ==
23.21 if 0 < n \<and> i \<le> n \<and> m_cond n mf \<and> km_cond n kf mf then
23.22 - (SOME x. Numeral0 \<le> x \<and> x < mf i \<and> zcong (kf i * mhf mf n i * x) (bf i) (mf i))
23.23 - else Numeral0"
23.24 + (SOME x. 0 \<le> x \<and> x < mf i \<and> zcong (kf i * mhf mf n i * x) (bf i) (mf i))
23.25 + else 0"
23.26
23.27 x_sol_def:
23.28 "x_sol n kf bf mf == funsum (\<lambda>i. xilin_sol i n kf bf mf * mhf mf n i) 0 n"
23.29 @@ -72,15 +72,15 @@
23.30
23.31 text {* \medskip @{term funprod} and @{term funsum} *}
23.32
23.33 -lemma funprod_pos: "(\<forall>i. i \<le> n --> Numeral0 < mf i) ==> Numeral0 < funprod mf 0 n"
23.34 +lemma funprod_pos: "(\<forall>i. i \<le> n --> 0 < mf i) ==> 0 < funprod mf 0 n"
23.35 apply (induct n)
23.36 apply auto
23.37 apply (simp add: int_0_less_mult_iff)
23.38 done
23.39
23.40 lemma funprod_zgcd [rule_format (no_asm)]:
23.41 - "(\<forall>i. k \<le> i \<and> i \<le> k + l --> zgcd (mf i, mf m) = Numeral1) -->
23.42 - zgcd (funprod mf k l, mf m) = Numeral1"
23.43 + "(\<forall>i. k \<le> i \<and> i \<le> k + l --> zgcd (mf i, mf m) = 1) -->
23.44 + zgcd (funprod mf k l, mf m) = 1"
23.45 apply (induct l)
23.46 apply simp_all
23.47 apply (rule impI)+
23.48 @@ -110,14 +110,14 @@
23.49 done
23.50
23.51 lemma funsum_zero [rule_format (no_asm)]:
23.52 - "(\<forall>i. k \<le> i \<and> i \<le> k + l --> f i = Numeral0) --> (funsum f k l) = Numeral0"
23.53 + "(\<forall>i. k \<le> i \<and> i \<le> k + l --> f i = 0) --> (funsum f k l) = 0"
23.54 apply (induct l)
23.55 apply auto
23.56 done
23.57
23.58 lemma funsum_oneelem [rule_format (no_asm)]:
23.59 "k \<le> j --> j \<le> k + l -->
23.60 - (\<forall>i. k \<le> i \<and> i \<le> k + l \<and> i \<noteq> j --> f i = Numeral0) -->
23.61 + (\<forall>i. k \<le> i \<and> i \<le> k + l \<and> i \<noteq> j --> f i = 0) -->
23.62 funsum f k l = f j"
23.63 apply (induct l)
23.64 prefer 2
23.65 @@ -127,9 +127,9 @@
23.66 apply (subgoal_tac "k = j")
23.67 apply (simp_all (no_asm_simp))
23.68 apply (case_tac "Suc (k + n) = j")
23.69 - apply (subgoal_tac "funsum f k n = Numeral0")
23.70 + apply (subgoal_tac "funsum f k n = 0")
23.71 apply (rule_tac [2] funsum_zero)
23.72 - apply (subgoal_tac [3] "f (Suc (k + n)) = Numeral0")
23.73 + apply (subgoal_tac [3] "f (Suc (k + n)) = 0")
23.74 apply (subgoal_tac [3] "j \<le> k + n")
23.75 prefer 4
23.76 apply arith
23.77 @@ -175,7 +175,7 @@
23.78
23.79 lemma unique_xi_sol:
23.80 "0 < n ==> i \<le> n ==> m_cond n mf ==> km_cond n kf mf
23.81 - ==> \<exists>!x. Numeral0 \<le> x \<and> x < mf i \<and> [kf i * mhf mf n i * x = bf i] (mod mf i)"
23.82 + ==> \<exists>!x. 0 \<le> x \<and> x < mf i \<and> [kf i * mhf mf n i * x = bf i] (mod mf i)"
23.83 apply (rule zcong_lineq_unique)
23.84 apply (tactic {* stac (thm "zgcd_zmult_cancel") 2 *})
23.85 apply (unfold m_cond_def km_cond_def mhf_def)
23.86 @@ -227,7 +227,7 @@
23.87
23.88 lemma chinese_remainder:
23.89 "0 < n ==> m_cond n mf ==> km_cond n kf mf
23.90 - ==> \<exists>!x. Numeral0 \<le> x \<and> x < funprod mf 0 n \<and> lincong_sol n kf bf mf x"
23.91 + ==> \<exists>!x. 0 \<le> x \<and> x < funprod mf 0 n \<and> lincong_sol n kf bf mf x"
23.92 apply safe
23.93 apply (rule_tac [2] m = "funprod mf 0 n" in zcong_zless_imp_eq)
23.94 apply (rule_tac [6] zcong_funprod)
23.95 @@ -242,7 +242,7 @@
23.96 apply (tactic {* stac (thm "zmod_zmult_distrib" RS sym) 7 *})
23.97 apply (tactic {* stac (thm "zcong_zmod" RS sym) 7 *})
23.98 apply (subgoal_tac [7]
23.99 - "Numeral0 \<le> xilin_sol i n kf bf mf \<and> xilin_sol i n kf bf mf < mf i
23.100 + "0 \<le> xilin_sol i n kf bf mf \<and> xilin_sol i n kf bf mf < mf i
23.101 \<and> [kf i * mhf mf n i * xilin_sol i n kf bf mf = bf i] (mod mf i)")
23.102 prefer 7
23.103 apply (simp add: zmult_ac)
24.1 --- a/src/HOL/NumberTheory/EulerFermat.thy Mon Oct 22 11:01:30 2001 +0200
24.2 +++ b/src/HOL/NumberTheory/EulerFermat.thy Mon Oct 22 11:54:22 2001 +0200
24.3 @@ -29,33 +29,33 @@
24.4 inductive "RsetR m"
24.5 intros
24.6 empty [simp]: "{} \<in> RsetR m"
24.7 - insert: "A \<in> RsetR m ==> zgcd (a, m) = Numeral1 ==>
24.8 + insert: "A \<in> RsetR m ==> zgcd (a, m) = 1 ==>
24.9 \<forall>a'. a' \<in> A --> \<not> zcong a a' m ==> insert a A \<in> RsetR m"
24.10
24.11 recdef BnorRset
24.12 "measure ((\<lambda>(a, m). nat a) :: int * int => nat)"
24.13 "BnorRset (a, m) =
24.14 - (if Numeral0 < a then
24.15 - let na = BnorRset (a - Numeral1, m)
24.16 - in (if zgcd (a, m) = Numeral1 then insert a na else na)
24.17 + (if 0 < a then
24.18 + let na = BnorRset (a - 1, m)
24.19 + in (if zgcd (a, m) = 1 then insert a na else na)
24.20 else {})"
24.21
24.22 defs
24.23 - norRRset_def: "norRRset m == BnorRset (m - Numeral1, m)"
24.24 + norRRset_def: "norRRset m == BnorRset (m - 1, m)"
24.25 noXRRset_def: "noXRRset m x == (\<lambda>a. a * x) ` norRRset m"
24.26 phi_def: "phi m == card (norRRset m)"
24.27 is_RRset_def: "is_RRset A m == A \<in> RsetR m \<and> card A = phi m"
24.28 RRset2norRR_def:
24.29 "RRset2norRR A m a ==
24.30 - (if Numeral1 < m \<and> is_RRset A m \<and> a \<in> A then
24.31 + (if 1 < m \<and> is_RRset A m \<and> a \<in> A then
24.32 SOME b. zcong a b m \<and> b \<in> norRRset m
24.33 - else Numeral0)"
24.34 + else 0)"
24.35
24.36 constdefs
24.37 zcongm :: "int => int => int => bool"
24.38 "zcongm m == \<lambda>a b. zcong a b m"
24.39
24.40 -lemma abs_eq_1_iff [iff]: "(abs z = (Numeral1::int)) = (z = Numeral1 \<or> z = -1)"
24.41 +lemma abs_eq_1_iff [iff]: "(abs z = (1::int)) = (z = 1 \<or> z = -1)"
24.42 -- {* LCP: not sure why this lemma is needed now *}
24.43 apply (auto simp add: zabs_def)
24.44 done
24.45 @@ -67,7 +67,7 @@
24.46
24.47 lemma BnorRset_induct:
24.48 "(!!a m. P {} a m) ==>
24.49 - (!!a m. Numeral0 < (a::int) ==> P (BnorRset (a - Numeral1, m::int)) (a - Numeral1) m
24.50 + (!!a m. 0 < (a::int) ==> P (BnorRset (a - 1, m::int)) (a - 1) m
24.51 ==> P (BnorRset(a,m)) a m)
24.52 ==> P (BnorRset(u,v)) u v"
24.53 proof -
24.54 @@ -75,7 +75,7 @@
24.55 show ?thesis
24.56 apply (rule BnorRset.induct)
24.57 apply safe
24.58 - apply (case_tac [2] "Numeral0 < a")
24.59 + apply (case_tac [2] "0 < a")
24.60 apply (rule_tac [2] rule_context)
24.61 apply simp_all
24.62 apply (simp_all add: BnorRset.simps rule_context)
24.63 @@ -94,7 +94,7 @@
24.64 apply (auto dest: Bnor_mem_zle)
24.65 done
24.66
24.67 -lemma Bnor_mem_zg [rule_format]: "b \<in> BnorRset (a, m) --> Numeral0 < b"
24.68 +lemma Bnor_mem_zg [rule_format]: "b \<in> BnorRset (a, m) --> 0 < b"
24.69 apply (induct a m rule: BnorRset_induct)
24.70 prefer 2
24.71 apply (subst BnorRset.simps)
24.72 @@ -103,7 +103,7 @@
24.73 done
24.74
24.75 lemma Bnor_mem_if [rule_format]:
24.76 - "zgcd (b, m) = Numeral1 --> Numeral0 < b --> b \<le> a --> b \<in> BnorRset (a, m)"
24.77 + "zgcd (b, m) = 1 --> 0 < b --> b \<le> a --> b \<in> BnorRset (a, m)"
24.78 apply (induct a m rule: BnorRset.induct)
24.79 apply auto
24.80 apply (case_tac "a = b")
24.81 @@ -128,7 +128,7 @@
24.82 apply (rule_tac [3] allI)
24.83 apply (rule_tac [3] impI)
24.84 apply (rule_tac [3] zcong_not)
24.85 - apply (subgoal_tac [6] "a' \<le> a - Numeral1")
24.86 + apply (subgoal_tac [6] "a' \<le> a - 1")
24.87 apply (rule_tac [7] Bnor_mem_zle)
24.88 apply (rule_tac [5] Bnor_mem_zg)
24.89 apply auto
24.90 @@ -142,13 +142,13 @@
24.91 apply auto
24.92 done
24.93
24.94 -lemma aux: "a \<le> b - Numeral1 ==> a < (b::int)"
24.95 +lemma aux: "a \<le> b - 1 ==> a < (b::int)"
24.96 apply auto
24.97 done
24.98
24.99 lemma norR_mem_unique:
24.100 - "Numeral1 < m ==>
24.101 - zgcd (a, m) = Numeral1 ==> \<exists>!b. [a = b] (mod m) \<and> b \<in> norRRset m"
24.102 + "1 < m ==>
24.103 + zgcd (a, m) = 1 ==> \<exists>!b. [a = b] (mod m) \<and> b \<in> norRRset m"
24.104 apply (unfold norRRset_def)
24.105 apply (cut_tac a = a and m = m in zcong_zless_unique)
24.106 apply auto
24.107 @@ -158,7 +158,7 @@
24.108 apply (rule_tac "x" = "b" in exI)
24.109 apply safe
24.110 apply (rule Bnor_mem_if)
24.111 - apply (case_tac [2] "b = Numeral0")
24.112 + apply (case_tac [2] "b = 0")
24.113 apply (auto intro: order_less_le [THEN iffD2])
24.114 prefer 2
24.115 apply (simp only: zcong_def)
24.116 @@ -173,7 +173,7 @@
24.117 text {* \medskip @{term noXRRset} *}
24.118
24.119 lemma RRset_gcd [rule_format]:
24.120 - "is_RRset A m ==> a \<in> A --> zgcd (a, m) = Numeral1"
24.121 + "is_RRset A m ==> a \<in> A --> zgcd (a, m) = 1"
24.122 apply (unfold is_RRset_def)
24.123 apply (rule RsetR.induct)
24.124 apply auto
24.125 @@ -181,7 +181,7 @@
24.126
24.127 lemma RsetR_zmult_mono:
24.128 "A \<in> RsetR m ==>
24.129 - Numeral0 < m ==> zgcd (x, m) = Numeral1 ==> (\<lambda>a. a * x) ` A \<in> RsetR m"
24.130 + 0 < m ==> zgcd (x, m) = 1 ==> (\<lambda>a. a * x) ` A \<in> RsetR m"
24.131 apply (erule RsetR.induct)
24.132 apply simp_all
24.133 apply (rule RsetR.insert)
24.134 @@ -191,8 +191,8 @@
24.135 done
24.136
24.137 lemma card_nor_eq_noX:
24.138 - "Numeral0 < m ==>
24.139 - zgcd (x, m) = Numeral1 ==> card (noXRRset m x) = card (norRRset m)"
24.140 + "0 < m ==>
24.141 + zgcd (x, m) = 1 ==> card (noXRRset m x) = card (norRRset m)"
24.142 apply (unfold norRRset_def noXRRset_def)
24.143 apply (rule card_image)
24.144 apply (auto simp add: inj_on_def Bnor_fin)
24.145 @@ -200,7 +200,7 @@
24.146 done
24.147
24.148 lemma noX_is_RRset:
24.149 - "Numeral0 < m ==> zgcd (x, m) = Numeral1 ==> is_RRset (noXRRset m x) m"
24.150 + "0 < m ==> zgcd (x, m) = 1 ==> is_RRset (noXRRset m x) m"
24.151 apply (unfold is_RRset_def phi_def)
24.152 apply (auto simp add: card_nor_eq_noX)
24.153 apply (unfold noXRRset_def norRRset_def)
24.154 @@ -210,7 +210,7 @@
24.155 done
24.156
24.157 lemma aux_some:
24.158 - "Numeral1 < m ==> is_RRset A m ==> a \<in> A
24.159 + "1 < m ==> is_RRset A m ==> a \<in> A
24.160 ==> zcong a (SOME b. [a = b] (mod m) \<and> b \<in> norRRset m) m \<and>
24.161 (SOME b. [a = b] (mod m) \<and> b \<in> norRRset m) \<in> norRRset m"
24.162 apply (rule norR_mem_unique [THEN ex1_implies_ex, THEN someI_ex])
24.163 @@ -219,7 +219,7 @@
24.164 done
24.165
24.166 lemma RRset2norRR_correct:
24.167 - "Numeral1 < m ==> is_RRset A m ==> a \<in> A ==>
24.168 + "1 < m ==> is_RRset A m ==> a \<in> A ==>
24.169 [a = RRset2norRR A m a] (mod m) \<and> RRset2norRR A m a \<in> norRRset m"
24.170 apply (unfold RRset2norRR_def)
24.171 apply simp
24.172 @@ -238,7 +238,7 @@
24.173 done
24.174
24.175 lemma RRset_zcong_eq [rule_format]:
24.176 - "Numeral1 < m ==>
24.177 + "1 < m ==>
24.178 is_RRset A m ==> [a = b] (mod m) ==> a \<in> A --> b \<in> A --> a = b"
24.179 apply (unfold is_RRset_def)
24.180 apply (rule RsetR.induct)
24.181 @@ -252,7 +252,7 @@
24.182 done
24.183
24.184 lemma RRset2norRR_inj:
24.185 - "Numeral1 < m ==> is_RRset A m ==> inj_on (RRset2norRR A m) A"
24.186 + "1 < m ==> is_RRset A m ==> inj_on (RRset2norRR A m) A"
24.187 apply (unfold RRset2norRR_def inj_on_def)
24.188 apply auto
24.189 apply (subgoal_tac "\<exists>b. ([x = b] (mod m) \<and> b \<in> norRRset m) \<and>
24.190 @@ -267,7 +267,7 @@
24.191 done
24.192
24.193 lemma RRset2norRR_eq_norR:
24.194 - "Numeral1 < m ==> is_RRset A m ==> RRset2norRR A m ` A = norRRset m"
24.195 + "1 < m ==> is_RRset A m ==> RRset2norRR A m ` A = norRRset m"
24.196 apply (rule card_seteq)
24.197 prefer 3
24.198 apply (subst card_image)
24.199 @@ -286,7 +286,7 @@
24.200 done
24.201
24.202 lemma Bnor_prod_power [rule_format]:
24.203 - "x \<noteq> Numeral0 ==> a < m --> setprod ((\<lambda>a. a * x) ` BnorRset (a, m)) =
24.204 + "x \<noteq> 0 ==> a < m --> setprod ((\<lambda>a. a * x) ` BnorRset (a, m)) =
24.205 setprod (BnorRset(a, m)) * x^card (BnorRset (a, m))"
24.206 apply (induct a m rule: BnorRset_induct)
24.207 prefer 2
24.208 @@ -313,7 +313,7 @@
24.209 done
24.210
24.211 lemma Bnor_prod_zgcd [rule_format]:
24.212 - "a < m --> zgcd (setprod (BnorRset (a, m)), m) = Numeral1"
24.213 + "a < m --> zgcd (setprod (BnorRset (a, m)), m) = 1"
24.214 apply (induct a m rule: BnorRset_induct)
24.215 prefer 2
24.216 apply (subst BnorRset.simps)
24.217 @@ -324,12 +324,12 @@
24.218 done
24.219
24.220 theorem Euler_Fermat:
24.221 - "Numeral0 < m ==> zgcd (x, m) = Numeral1 ==> [x^(phi m) = Numeral1] (mod m)"
24.222 + "0 < m ==> zgcd (x, m) = 1 ==> [x^(phi m) = 1] (mod m)"
24.223 apply (unfold norRRset_def phi_def)
24.224 - apply (case_tac "x = Numeral0")
24.225 - apply (case_tac [2] "m = Numeral1")
24.226 + apply (case_tac "x = 0")
24.227 + apply (case_tac [2] "m = 1")
24.228 apply (rule_tac [3] iffD1)
24.229 - apply (rule_tac [3] k = "setprod (BnorRset (m - Numeral1, m))"
24.230 + apply (rule_tac [3] k = "setprod (BnorRset (m - 1, m))"
24.231 in zcong_cancel2)
24.232 prefer 5
24.233 apply (subst Bnor_prod_power [symmetric])
24.234 @@ -352,7 +352,7 @@
24.235
24.236 lemma Bnor_prime [rule_format (no_asm)]:
24.237 "p \<in> zprime ==>
24.238 - a < p --> (\<forall>b. Numeral0 < b \<and> b \<le> a --> zgcd (b, p) = Numeral1)
24.239 + a < p --> (\<forall>b. 0 < b \<and> b \<le> a --> zgcd (b, p) = 1)
24.240 --> card (BnorRset (a, p)) = nat a"
24.241 apply (unfold zprime_def)
24.242 apply (induct a p rule: BnorRset.induct)
24.243 @@ -361,7 +361,7 @@
24.244 apply auto
24.245 done
24.246
24.247 -lemma phi_prime: "p \<in> zprime ==> phi p = nat (p - Numeral1)"
24.248 +lemma phi_prime: "p \<in> zprime ==> phi p = nat (p - 1)"
24.249 apply (unfold phi_def norRRset_def)
24.250 apply (rule Bnor_prime)
24.251 apply auto
24.252 @@ -370,7 +370,7 @@
24.253 done
24.254
24.255 theorem Little_Fermat:
24.256 - "p \<in> zprime ==> \<not> p dvd x ==> [x^(nat (p - Numeral1)) = Numeral1] (mod p)"
24.257 + "p \<in> zprime ==> \<not> p dvd x ==> [x^(nat (p - 1)) = 1] (mod p)"
24.258 apply (subst phi_prime [symmetric])
24.259 apply (rule_tac [2] Euler_Fermat)
24.260 apply (erule_tac [3] zprime_imp_zrelprime)
25.1 --- a/src/HOL/NumberTheory/Fib.thy Mon Oct 22 11:01:30 2001 +0200
25.2 +++ b/src/HOL/NumberTheory/Fib.thy Mon Oct 22 11:54:22 2001 +0200
25.3 @@ -67,8 +67,8 @@
25.4 *}
25.5
25.6 lemma fib_Cassini: "int (fib (Suc (Suc n)) * fib n) =
25.7 - (if n mod 2 = 0 then int (fib (Suc n) * fib (Suc n)) - Numeral1
25.8 - else int (fib (Suc n) * fib (Suc n)) + Numeral1)"
25.9 + (if n mod 2 = 0 then int (fib (Suc n) * fib (Suc n)) - 1
25.10 + else int (fib (Suc n) * fib (Suc n)) + 1)"
25.11 apply (induct n rule: fib.induct)
25.12 apply (simp add: fib.Suc_Suc)
25.13 apply (simp add: fib.Suc_Suc mod_Suc)
26.1 --- a/src/HOL/NumberTheory/IntFact.thy Mon Oct 22 11:01:30 2001 +0200
26.2 +++ b/src/HOL/NumberTheory/IntFact.thy Mon Oct 22 11:54:22 2001 +0200
26.3 @@ -22,18 +22,18 @@
26.4 d22set :: "int => int set"
26.5
26.6 recdef zfact "measure ((\<lambda>n. nat n) :: int => nat)"
26.7 - "zfact n = (if n \<le> Numeral0 then Numeral1 else n * zfact (n - Numeral1))"
26.8 + "zfact n = (if n \<le> 0 then 1 else n * zfact (n - 1))"
26.9
26.10 defs
26.11 - setprod_def: "setprod A == (if finite A then fold (op *) Numeral1 A else Numeral1)"
26.12 + setprod_def: "setprod A == (if finite A then fold (op *) 1 A else 1)"
26.13
26.14 recdef d22set "measure ((\<lambda>a. nat a) :: int => nat)"
26.15 - "d22set a = (if Numeral1 < a then insert a (d22set (a - Numeral1)) else {})"
26.16 + "d22set a = (if 1 < a then insert a (d22set (a - 1)) else {})"
26.17
26.18
26.19 text {* \medskip @{term setprod} --- product of finite set *}
26.20
26.21 -lemma setprod_empty [simp]: "setprod {} = Numeral1"
26.22 +lemma setprod_empty [simp]: "setprod {} = 1"
26.23 apply (simp add: setprod_def)
26.24 done
26.25
26.26 @@ -54,7 +54,7 @@
26.27
26.28 lemma d22set_induct:
26.29 "(!!a. P {} a) ==>
26.30 - (!!a. Numeral1 < (a::int) ==> P (d22set (a - Numeral1)) (a - Numeral1)
26.31 + (!!a. 1 < (a::int) ==> P (d22set (a - 1)) (a - 1)
26.32 ==> P (d22set a) a)
26.33 ==> P (d22set u) u"
26.34 proof -
26.35 @@ -62,14 +62,14 @@
26.36 show ?thesis
26.37 apply (rule d22set.induct)
26.38 apply safe
26.39 - apply (case_tac [2] "Numeral1 < a")
26.40 + apply (case_tac [2] "1 < a")
26.41 apply (rule_tac [2] rule_context)
26.42 apply (simp_all (no_asm_simp))
26.43 apply (simp_all (no_asm_simp) add: d22set.simps rule_context)
26.44 done
26.45 qed
26.46
26.47 -lemma d22set_g_1 [rule_format]: "b \<in> d22set a --> Numeral1 < b"
26.48 +lemma d22set_g_1 [rule_format]: "b \<in> d22set a --> 1 < b"
26.49 apply (induct a rule: d22set_induct)
26.50 prefer 2
26.51 apply (subst d22set.simps)
26.52 @@ -87,7 +87,7 @@
26.53 apply (auto dest: d22set_le)
26.54 done
26.55
26.56 -lemma d22set_mem [rule_format]: "Numeral1 < b --> b \<le> a --> b \<in> d22set a"
26.57 +lemma d22set_mem [rule_format]: "1 < b --> b \<le> a --> b \<in> d22set a"
26.58 apply (induct a rule: d22set.induct)
26.59 apply auto
26.60 apply (simp_all add: d22set.simps)
26.61 @@ -109,7 +109,7 @@
26.62 apply (simp add: d22set.simps zfact.simps)
26.63 apply (subst d22set.simps)
26.64 apply (subst zfact.simps)
26.65 - apply (case_tac "Numeral1 < a")
26.66 + apply (case_tac "1 < a")
26.67 prefer 2
26.68 apply (simp add: d22set.simps zfact.simps)
26.69 apply (simp add: d22set_fin d22set_le_swap)
27.1 --- a/src/HOL/NumberTheory/IntPrimes.thy Mon Oct 22 11:01:30 2001 +0200
27.2 +++ b/src/HOL/NumberTheory/IntPrimes.thy Mon Oct 22 11:54:22 2001 +0200
27.3 @@ -29,7 +29,7 @@
27.4 "measure ((\<lambda>(m, n, r', r, s', s, t', t). nat r)
27.5 :: int * int * int * int *int * int * int * int => nat)"
27.6 "xzgcda (m, n, r', r, s', s, t', t) =
27.7 - (if r \<le> Numeral0 then (r', s', t')
27.8 + (if r \<le> 0 then (r', s', t')
27.9 else xzgcda (m, n, r, r' mod r, s, s' - (r' div r) * s, t, t' - (r' div r) * t))"
27.10 (hints simp: pos_mod_bound)
27.11
27.12 @@ -38,13 +38,13 @@
27.13 "zgcd == \<lambda>(x,y). int (gcd (nat (abs x), nat (abs y)))"
27.14
27.15 defs
27.16 - xzgcd_def: "xzgcd m n == xzgcda (m, n, m, n, Numeral1, Numeral0, Numeral0, Numeral1)"
27.17 - zprime_def: "zprime == {p. Numeral1 < p \<and> (\<forall>m. m dvd p --> m = Numeral1 \<or> m = p)}"
27.18 + xzgcd_def: "xzgcd m n == xzgcda (m, n, m, n, 1, 0, 0, 1)"
27.19 + zprime_def: "zprime == {p. 1 < p \<and> (\<forall>m. m dvd p --> m = 1 \<or> m = p)}"
27.20 zcong_def: "[a = b] (mod m) == m dvd (a - b)"
27.21
27.22
27.23 lemma zabs_eq_iff:
27.24 - "(abs (z::int) = w) = (z = w \<and> Numeral0 <= z \<or> z = -w \<and> z < Numeral0)"
27.25 + "(abs (z::int) = w) = (z = w \<and> 0 <= z \<or> z = -w \<and> z < 0)"
27.26 apply (auto simp add: zabs_def)
27.27 done
27.28
27.29 @@ -64,17 +64,17 @@
27.30
27.31 subsection {* Divides relation *}
27.32
27.33 -lemma zdvd_0_right [iff]: "(m::int) dvd Numeral0"
27.34 +lemma zdvd_0_right [iff]: "(m::int) dvd 0"
27.35 apply (unfold dvd_def)
27.36 apply (blast intro: zmult_0_right [symmetric])
27.37 done
27.38
27.39 -lemma zdvd_0_left [iff]: "(Numeral0 dvd (m::int)) = (m = Numeral0)"
27.40 +lemma zdvd_0_left [iff]: "(0 dvd (m::int)) = (m = 0)"
27.41 apply (unfold dvd_def)
27.42 apply auto
27.43 done
27.44
27.45 -lemma zdvd_1_left [iff]: "Numeral1 dvd (m::int)"
27.46 +lemma zdvd_1_left [iff]: "1 dvd (m::int)"
27.47 apply (unfold dvd_def)
27.48 apply simp
27.49 done
27.50 @@ -104,7 +104,7 @@
27.51 done
27.52
27.53 lemma zdvd_anti_sym:
27.54 - "Numeral0 < m ==> Numeral0 < n ==> m dvd n ==> n dvd m ==> m = (n::int)"
27.55 + "0 < m ==> 0 < n ==> m dvd n ==> n dvd m ==> m = (n::int)"
27.56 apply (unfold dvd_def)
27.57 apply auto
27.58 apply (simp add: zmult_assoc zmult_eq_self_iff int_0_less_mult_iff zmult_eq_1_iff)
27.59 @@ -186,19 +186,19 @@
27.60 apply (simp add: zdvd_zadd zdvd_zmult2)
27.61 done
27.62
27.63 -lemma zdvd_iff_zmod_eq_0: "(k dvd n) = (n mod (k::int) = Numeral0)"
27.64 +lemma zdvd_iff_zmod_eq_0: "(k dvd n) = (n mod (k::int) = 0)"
27.65 apply (unfold dvd_def)
27.66 apply auto
27.67 done
27.68
27.69 -lemma zdvd_not_zless: "Numeral0 < m ==> m < n ==> \<not> n dvd (m::int)"
27.70 +lemma zdvd_not_zless: "0 < m ==> m < n ==> \<not> n dvd (m::int)"
27.71 apply (unfold dvd_def)
27.72 apply auto
27.73 - apply (subgoal_tac "Numeral0 < n")
27.74 + apply (subgoal_tac "0 < n")
27.75 prefer 2
27.76 apply (blast intro: zless_trans)
27.77 apply (simp add: int_0_less_mult_iff)
27.78 - apply (subgoal_tac "n * k < n * Numeral1")
27.79 + apply (subgoal_tac "n * k < n * 1")
27.80 apply (drule zmult_zless_cancel1 [THEN iffD1])
27.81 apply auto
27.82 done
27.83 @@ -221,7 +221,7 @@
27.84 nat_mult_distrib [symmetric] nat_eq_iff2)
27.85 done
27.86
27.87 -lemma nat_dvd_iff: "(nat z dvd m) = (if Numeral0 \<le> z then (z dvd int m) else m = 0)"
27.88 +lemma nat_dvd_iff: "(nat z dvd m) = (if 0 \<le> z then (z dvd int m) else m = 0)"
27.89 apply (auto simp add: dvd_def zmult_int [symmetric])
27.90 apply (rule_tac x = "nat k" in exI)
27.91 apply (cut_tac k = m in int_less_0_conv)
27.92 @@ -245,11 +245,11 @@
27.93
27.94 subsection {* Euclid's Algorithm and GCD *}
27.95
27.96 -lemma zgcd_0 [simp]: "zgcd (m, Numeral0) = abs m"
27.97 +lemma zgcd_0 [simp]: "zgcd (m, 0) = abs m"
27.98 apply (simp add: zgcd_def zabs_def)
27.99 done
27.100
27.101 -lemma zgcd_0_left [simp]: "zgcd (Numeral0, m) = abs m"
27.102 +lemma zgcd_0_left [simp]: "zgcd (0, m) = abs m"
27.103 apply (simp add: zgcd_def zabs_def)
27.104 done
27.105
27.106 @@ -261,7 +261,7 @@
27.107 apply (simp add: zgcd_def)
27.108 done
27.109
27.110 -lemma zgcd_non_0: "Numeral0 < n ==> zgcd (m, n) = zgcd (n, m mod n)"
27.111 +lemma zgcd_non_0: "0 < n ==> zgcd (m, n) = zgcd (n, m mod n)"
27.112 apply (frule_tac b = n and a = m in pos_mod_sign)
27.113 apply (simp add: zgcd_def zabs_def nat_mod_distrib)
27.114 apply (cut_tac a = "-m" and b = n in zmod_zminus1_eq_if)
27.115 @@ -273,17 +273,17 @@
27.116 done
27.117
27.118 lemma zgcd_eq: "zgcd (m, n) = zgcd (n, m mod n)"
27.119 - apply (tactic {* zdiv_undefined_case_tac "n = Numeral0" 1 *})
27.120 + apply (tactic {* zdiv_undefined_case_tac "n = 0" 1 *})
27.121 apply (auto simp add: linorder_neq_iff zgcd_non_0)
27.122 apply (cut_tac m = "-m" and n = "-n" in zgcd_non_0)
27.123 apply auto
27.124 done
27.125
27.126 -lemma zgcd_1 [simp]: "zgcd (m, Numeral1) = Numeral1"
27.127 +lemma zgcd_1 [simp]: "zgcd (m, 1) = 1"
27.128 apply (simp add: zgcd_def zabs_def)
27.129 done
27.130
27.131 -lemma zgcd_0_1_iff [simp]: "(zgcd (Numeral0, m) = Numeral1) = (abs m = Numeral1)"
27.132 +lemma zgcd_0_1_iff [simp]: "(zgcd (0, m) = 1) = (abs m = 1)"
27.133 apply (simp add: zgcd_def zabs_def)
27.134 done
27.135
27.136 @@ -303,7 +303,7 @@
27.137 apply (simp add: zgcd_def gcd_commute)
27.138 done
27.139
27.140 -lemma zgcd_1_left [simp]: "zgcd (Numeral1, m) = Numeral1"
27.141 +lemma zgcd_1_left [simp]: "zgcd (1, m) = 1"
27.142 apply (simp add: zgcd_def gcd_1_left)
27.143 done
27.144
27.145 @@ -320,7 +320,7 @@
27.146 lemmas zgcd_ac = zgcd_assoc zgcd_commute zgcd_left_commute
27.147 -- {* addition is an AC-operator *}
27.148
27.149 -lemma zgcd_zmult_distrib2: "Numeral0 \<le> k ==> k * zgcd (m, n) = zgcd (k * m, k * n)"
27.150 +lemma zgcd_zmult_distrib2: "0 \<le> k ==> k * zgcd (m, n) = zgcd (k * m, k * n)"
27.151 apply (simp del: zmult_zminus_right
27.152 add: zmult_zminus_right [symmetric] nat_mult_distrib zgcd_def zabs_def
27.153 zmult_less_0_iff gcd_mult_distrib2 [symmetric] zmult_int [symmetric])
27.154 @@ -330,29 +330,29 @@
27.155 apply (simp add: zabs_def zgcd_zmult_distrib2)
27.156 done
27.157
27.158 -lemma zgcd_self [simp]: "Numeral0 \<le> m ==> zgcd (m, m) = m"
27.159 - apply (cut_tac k = m and m = "Numeral1" and n = "Numeral1" in zgcd_zmult_distrib2)
27.160 +lemma zgcd_self [simp]: "0 \<le> m ==> zgcd (m, m) = m"
27.161 + apply (cut_tac k = m and m = "1" and n = "1" in zgcd_zmult_distrib2)
27.162 apply simp_all
27.163 done
27.164
27.165 -lemma zgcd_zmult_eq_self [simp]: "Numeral0 \<le> k ==> zgcd (k, k * n) = k"
27.166 - apply (cut_tac k = k and m = "Numeral1" and n = n in zgcd_zmult_distrib2)
27.167 +lemma zgcd_zmult_eq_self [simp]: "0 \<le> k ==> zgcd (k, k * n) = k"
27.168 + apply (cut_tac k = k and m = "1" and n = n in zgcd_zmult_distrib2)
27.169 apply simp_all
27.170 done
27.171
27.172 -lemma zgcd_zmult_eq_self2 [simp]: "Numeral0 \<le> k ==> zgcd (k * n, k) = k"
27.173 - apply (cut_tac k = k and m = n and n = "Numeral1" in zgcd_zmult_distrib2)
27.174 +lemma zgcd_zmult_eq_self2 [simp]: "0 \<le> k ==> zgcd (k * n, k) = k"
27.175 + apply (cut_tac k = k and m = n and n = "1" in zgcd_zmult_distrib2)
27.176 apply simp_all
27.177 done
27.178
27.179 -lemma aux: "zgcd (n, k) = Numeral1 ==> k dvd m * n ==> Numeral0 \<le> m ==> k dvd m"
27.180 +lemma aux: "zgcd (n, k) = 1 ==> k dvd m * n ==> 0 \<le> m ==> k dvd m"
27.181 apply (subgoal_tac "m = zgcd (m * n, m * k)")
27.182 apply (erule ssubst, rule zgcd_greatest_iff [THEN iffD2])
27.183 apply (simp_all add: zgcd_zmult_distrib2 [symmetric] int_0_le_mult_iff)
27.184 done
27.185
27.186 -lemma zrelprime_zdvd_zmult: "zgcd (n, k) = Numeral1 ==> k dvd m * n ==> k dvd m"
27.187 - apply (case_tac "Numeral0 \<le> m")
27.188 +lemma zrelprime_zdvd_zmult: "zgcd (n, k) = 1 ==> k dvd m * n ==> k dvd m"
27.189 + apply (case_tac "0 \<le> m")
27.190 apply (blast intro: aux)
27.191 apply (subgoal_tac "k dvd -m")
27.192 apply (rule_tac [2] aux)
27.193 @@ -360,20 +360,20 @@
27.194 done
27.195
27.196 lemma zprime_imp_zrelprime:
27.197 - "p \<in> zprime ==> \<not> p dvd n ==> zgcd (n, p) = Numeral1"
27.198 + "p \<in> zprime ==> \<not> p dvd n ==> zgcd (n, p) = 1"
27.199 apply (unfold zprime_def)
27.200 apply auto
27.201 done
27.202
27.203 lemma zless_zprime_imp_zrelprime:
27.204 - "p \<in> zprime ==> Numeral0 < n ==> n < p ==> zgcd (n, p) = Numeral1"
27.205 + "p \<in> zprime ==> 0 < n ==> n < p ==> zgcd (n, p) = 1"
27.206 apply (erule zprime_imp_zrelprime)
27.207 apply (erule zdvd_not_zless)
27.208 apply assumption
27.209 done
27.210
27.211 lemma zprime_zdvd_zmult:
27.212 - "Numeral0 \<le> (m::int) ==> p \<in> zprime ==> p dvd m * n ==> p dvd m \<or> p dvd n"
27.213 + "0 \<le> (m::int) ==> p \<in> zprime ==> p dvd m * n ==> p dvd m \<or> p dvd n"
27.214 apply safe
27.215 apply (rule zrelprime_zdvd_zmult)
27.216 apply (rule zprime_imp_zrelprime)
27.217 @@ -392,7 +392,7 @@
27.218 done
27.219
27.220 lemma zgcd_zmult_zdvd_zgcd:
27.221 - "zgcd (k, n) = Numeral1 ==> zgcd (k * m, n) dvd zgcd (m, n)"
27.222 + "zgcd (k, n) = 1 ==> zgcd (k * m, n) dvd zgcd (m, n)"
27.223 apply (simp add: zgcd_greatest_iff)
27.224 apply (rule_tac n = k in zrelprime_zdvd_zmult)
27.225 prefer 2
27.226 @@ -402,16 +402,16 @@
27.227 apply (simp (no_asm) add: zgcd_ac)
27.228 done
27.229
27.230 -lemma zgcd_zmult_cancel: "zgcd (k, n) = Numeral1 ==> zgcd (k * m, n) = zgcd (m, n)"
27.231 +lemma zgcd_zmult_cancel: "zgcd (k, n) = 1 ==> zgcd (k * m, n) = zgcd (m, n)"
27.232 apply (simp add: zgcd_def nat_abs_mult_distrib gcd_mult_cancel)
27.233 done
27.234
27.235 lemma zgcd_zgcd_zmult:
27.236 - "zgcd (k, m) = Numeral1 ==> zgcd (n, m) = Numeral1 ==> zgcd (k * n, m) = Numeral1"
27.237 + "zgcd (k, m) = 1 ==> zgcd (n, m) = 1 ==> zgcd (k * n, m) = 1"
27.238 apply (simp (no_asm_simp) add: zgcd_zmult_cancel)
27.239 done
27.240
27.241 -lemma zdvd_iff_zgcd: "Numeral0 < m ==> (m dvd n) = (zgcd (n, m) = m)"
27.242 +lemma zdvd_iff_zgcd: "0 < m ==> (m dvd n) = (zgcd (n, m) = m)"
27.243 apply safe
27.244 apply (rule_tac [2] n = "zgcd (n, m)" in zdvd_trans)
27.245 apply (rule_tac [3] zgcd_zdvd1)
27.246 @@ -423,7 +423,7 @@
27.247
27.248 subsection {* Congruences *}
27.249
27.250 -lemma zcong_1 [simp]: "[a = b] (mod Numeral1)"
27.251 +lemma zcong_1 [simp]: "[a = b] (mod 1)"
27.252 apply (unfold zcong_def)
27.253 apply auto
27.254 done
27.255 @@ -494,19 +494,19 @@
27.256 done
27.257
27.258 lemma zcong_square:
27.259 - "p \<in> zprime ==> Numeral0 < a ==> [a * a = Numeral1] (mod p)
27.260 - ==> [a = Numeral1] (mod p) \<or> [a = p - Numeral1] (mod p)"
27.261 + "p \<in> zprime ==> 0 < a ==> [a * a = 1] (mod p)
27.262 + ==> [a = 1] (mod p) \<or> [a = p - 1] (mod p)"
27.263 apply (unfold zcong_def)
27.264 apply (rule zprime_zdvd_zmult)
27.265 - apply (rule_tac [3] s = "a * a - Numeral1 + p * (Numeral1 - a)" in subst)
27.266 + apply (rule_tac [3] s = "a * a - 1 + p * (1 - a)" in subst)
27.267 prefer 4
27.268 apply (simp add: zdvd_reduce)
27.269 apply (simp_all add: zdiff_zmult_distrib zmult_commute zdiff_zmult_distrib2)
27.270 done
27.271
27.272 lemma zcong_cancel:
27.273 - "Numeral0 \<le> m ==>
27.274 - zgcd (k, m) = Numeral1 ==> [a * k = b * k] (mod m) = [a = b] (mod m)"
27.275 + "0 \<le> m ==>
27.276 + zgcd (k, m) = 1 ==> [a * k = b * k] (mod m) = [a = b] (mod m)"
27.277 apply safe
27.278 prefer 2
27.279 apply (blast intro: zcong_scalar)
27.280 @@ -523,19 +523,19 @@
27.281 done
27.282
27.283 lemma zcong_cancel2:
27.284 - "Numeral0 \<le> m ==>
27.285 - zgcd (k, m) = Numeral1 ==> [k * a = k * b] (mod m) = [a = b] (mod m)"
27.286 + "0 \<le> m ==>
27.287 + zgcd (k, m) = 1 ==> [k * a = k * b] (mod m) = [a = b] (mod m)"
27.288 apply (simp add: zmult_commute zcong_cancel)
27.289 done
27.290
27.291 lemma zcong_zgcd_zmult_zmod:
27.292 - "[a = b] (mod m) ==> [a = b] (mod n) ==> zgcd (m, n) = Numeral1
27.293 + "[a = b] (mod m) ==> [a = b] (mod n) ==> zgcd (m, n) = 1
27.294 ==> [a = b] (mod m * n)"
27.295 apply (unfold zcong_def dvd_def)
27.296 apply auto
27.297 apply (subgoal_tac "m dvd n * ka")
27.298 apply (subgoal_tac "m dvd ka")
27.299 - apply (case_tac [2] "Numeral0 \<le> ka")
27.300 + apply (case_tac [2] "0 \<le> ka")
27.301 prefer 3
27.302 apply (subst zdvd_zminus_iff [symmetric])
27.303 apply (rule_tac n = n in zrelprime_zdvd_zmult)
27.304 @@ -550,8 +550,8 @@
27.305 done
27.306
27.307 lemma zcong_zless_imp_eq:
27.308 - "Numeral0 \<le> a ==>
27.309 - a < m ==> Numeral0 \<le> b ==> b < m ==> [a = b] (mod m) ==> a = b"
27.310 + "0 \<le> a ==>
27.311 + a < m ==> 0 \<le> b ==> b < m ==> [a = b] (mod m) ==> a = b"
27.312 apply (unfold zcong_def dvd_def)
27.313 apply auto
27.314 apply (drule_tac f = "\<lambda>z. z mod m" in arg_cong)
27.315 @@ -566,38 +566,38 @@
27.316 done
27.317
27.318 lemma zcong_square_zless:
27.319 - "p \<in> zprime ==> Numeral0 < a ==> a < p ==>
27.320 - [a * a = Numeral1] (mod p) ==> a = Numeral1 \<or> a = p - Numeral1"
27.321 + "p \<in> zprime ==> 0 < a ==> a < p ==>
27.322 + [a * a = 1] (mod p) ==> a = 1 \<or> a = p - 1"
27.323 apply (cut_tac p = p and a = a in zcong_square)
27.324 apply (simp add: zprime_def)
27.325 apply (auto intro: zcong_zless_imp_eq)
27.326 done
27.327
27.328 lemma zcong_not:
27.329 - "Numeral0 < a ==> a < m ==> Numeral0 < b ==> b < a ==> \<not> [a = b] (mod m)"
27.330 + "0 < a ==> a < m ==> 0 < b ==> b < a ==> \<not> [a = b] (mod m)"
27.331 apply (unfold zcong_def)
27.332 apply (rule zdvd_not_zless)
27.333 apply auto
27.334 done
27.335
27.336 lemma zcong_zless_0:
27.337 - "Numeral0 \<le> a ==> a < m ==> [a = Numeral0] (mod m) ==> a = Numeral0"
27.338 + "0 \<le> a ==> a < m ==> [a = 0] (mod m) ==> a = 0"
27.339 apply (unfold zcong_def dvd_def)
27.340 apply auto
27.341 - apply (subgoal_tac "Numeral0 < m")
27.342 + apply (subgoal_tac "0 < m")
27.343 apply (rotate_tac -1)
27.344 apply (simp add: int_0_le_mult_iff)
27.345 - apply (subgoal_tac "m * k < m * Numeral1")
27.346 + apply (subgoal_tac "m * k < m * 1")
27.347 apply (drule zmult_zless_cancel1 [THEN iffD1])
27.348 apply (auto simp add: linorder_neq_iff)
27.349 done
27.350
27.351 lemma zcong_zless_unique:
27.352 - "Numeral0 < m ==> (\<exists>!b. Numeral0 \<le> b \<and> b < m \<and> [a = b] (mod m))"
27.353 + "0 < m ==> (\<exists>!b. 0 \<le> b \<and> b < m \<and> [a = b] (mod m))"
27.354 apply auto
27.355 apply (subgoal_tac [2] "[b = y] (mod m)")
27.356 - apply (case_tac [2] "b = Numeral0")
27.357 - apply (case_tac [3] "y = Numeral0")
27.358 + apply (case_tac [2] "b = 0")
27.359 + apply (case_tac [3] "y = 0")
27.360 apply (auto intro: zcong_trans zcong_zless_0 zcong_zless_imp_eq order_less_le
27.361 simp add: zcong_sym)
27.362 apply (unfold zcong_def dvd_def)
27.363 @@ -616,8 +616,8 @@
27.364 done
27.365
27.366 lemma zgcd_zcong_zgcd:
27.367 - "Numeral0 < m ==>
27.368 - zgcd (a, m) = Numeral1 ==> [a = b] (mod m) ==> zgcd (b, m) = Numeral1"
27.369 + "0 < m ==>
27.370 + zgcd (a, m) = 1 ==> [a = b] (mod m) ==> zgcd (b, m) = 1"
27.371 apply (auto simp add: zcong_iff_lin)
27.372 done
27.373
27.374 @@ -643,7 +643,7 @@
27.375 apply (simp add: zadd_commute)
27.376 done
27.377
27.378 -lemma zcong_zmod_eq: "Numeral0 < m ==> [a = b] (mod m) = (a mod m = b mod m)"
27.379 +lemma zcong_zmod_eq: "0 < m ==> [a = b] (mod m) = (a mod m = b mod m)"
27.380 apply auto
27.381 apply (rule_tac m = m in zcong_zless_imp_eq)
27.382 prefer 5
27.383 @@ -659,13 +659,13 @@
27.384 apply (auto simp add: zcong_def)
27.385 done
27.386
27.387 -lemma zcong_zero [iff]: "[a = b] (mod Numeral0) = (a = b)"
27.388 +lemma zcong_zero [iff]: "[a = b] (mod 0) = (a = b)"
27.389 apply (auto simp add: zcong_def)
27.390 done
27.391
27.392 lemma "[a = b] (mod m) = (a mod m = b mod m)"
27.393 - apply (tactic {* zdiv_undefined_case_tac "m = Numeral0" 1 *})
27.394 - apply (case_tac "Numeral0 < m")
27.395 + apply (tactic {* zdiv_undefined_case_tac "m = 0" 1 *})
27.396 + apply (case_tac "0 < m")
27.397 apply (simp add: zcong_zmod_eq)
27.398 apply (rule_tac t = m in zminus_zminus [THEN subst])
27.399 apply (subst zcong_zminus)
27.400 @@ -677,7 +677,7 @@
27.401 subsection {* Modulo *}
27.402
27.403 lemma zmod_zdvd_zmod:
27.404 - "Numeral0 < (m::int) ==> m dvd b ==> (a mod b mod m) = (a mod m)"
27.405 + "0 < (m::int) ==> m dvd b ==> (a mod b mod m) = (a mod m)"
27.406 apply (unfold dvd_def)
27.407 apply auto
27.408 apply (subst zcong_zmod_eq [symmetric])
27.409 @@ -696,14 +696,14 @@
27.410 declare xzgcda.simps [simp del]
27.411
27.412 lemma aux1:
27.413 - "zgcd (r', r) = k --> Numeral0 < r -->
27.414 + "zgcd (r', r) = k --> 0 < r -->
27.415 (\<exists>sn tn. xzgcda (m, n, r', r, s', s, t', t) = (k, sn, tn))"
27.416 apply (rule_tac u = m and v = n and w = r' and x = r and y = s' and
27.417 z = s and aa = t' and ab = t in xzgcda.induct)
27.418 apply (subst zgcd_eq)
27.419 apply (subst xzgcda.simps)
27.420 apply auto
27.421 - apply (case_tac "r' mod r = Numeral0")
27.422 + apply (case_tac "r' mod r = 0")
27.423 prefer 2
27.424 apply (frule_tac a = "r'" in pos_mod_sign)
27.425 apply auto
27.426 @@ -716,14 +716,14 @@
27.427 done
27.428
27.429 lemma aux2:
27.430 - "(\<exists>sn tn. xzgcda (m, n, r', r, s', s, t', t) = (k, sn, tn)) --> Numeral0 < r -->
27.431 + "(\<exists>sn tn. xzgcda (m, n, r', r, s', s, t', t) = (k, sn, tn)) --> 0 < r -->
27.432 zgcd (r', r) = k"
27.433 apply (rule_tac u = m and v = n and w = r' and x = r and y = s' and
27.434 z = s and aa = t' and ab = t in xzgcda.induct)
27.435 apply (subst zgcd_eq)
27.436 apply (subst xzgcda.simps)
27.437 apply (auto simp add: linorder_not_le)
27.438 - apply (case_tac "r' mod r = Numeral0")
27.439 + apply (case_tac "r' mod r = 0")
27.440 prefer 2
27.441 apply (frule_tac a = "r'" in pos_mod_sign)
27.442 apply auto
27.443 @@ -735,7 +735,7 @@
27.444 done
27.445
27.446 lemma xzgcd_correct:
27.447 - "Numeral0 < n ==> (zgcd (m, n) = k) = (\<exists>s t. xzgcd m n = (k, s, t))"
27.448 + "0 < n ==> (zgcd (m, n) = k) = (\<exists>s t. xzgcd m n = (k, s, t))"
27.449 apply (unfold xzgcd_def)
27.450 apply (rule iffI)
27.451 apply (rule_tac [2] aux2 [THEN mp, THEN mp])
27.452 @@ -768,17 +768,17 @@
27.453 by (rule iffD2 [OF order_less_le conjI])
27.454
27.455 lemma xzgcda_linear [rule_format]:
27.456 - "Numeral0 < r --> xzgcda (m, n, r', r, s', s, t', t) = (rn, sn, tn) -->
27.457 + "0 < r --> xzgcda (m, n, r', r, s', s, t', t) = (rn, sn, tn) -->
27.458 r' = s' * m + t' * n --> r = s * m + t * n --> rn = sn * m + tn * n"
27.459 apply (rule_tac u = m and v = n and w = r' and x = r and y = s' and
27.460 z = s and aa = t' and ab = t in xzgcda.induct)
27.461 apply (subst xzgcda.simps)
27.462 apply (simp (no_asm))
27.463 apply (rule impI)+
27.464 - apply (case_tac "r' mod r = Numeral0")
27.465 + apply (case_tac "r' mod r = 0")
27.466 apply (simp add: xzgcda.simps)
27.467 apply clarify
27.468 - apply (subgoal_tac "Numeral0 < r' mod r")
27.469 + apply (subgoal_tac "0 < r' mod r")
27.470 apply (rule_tac [2] order_le_neq_implies_less)
27.471 apply (rule_tac [2] pos_mod_sign)
27.472 apply (cut_tac m = m and n = n and r' = r' and r = r and s' = s' and
27.473 @@ -787,7 +787,7 @@
27.474 done
27.475
27.476 lemma xzgcd_linear:
27.477 - "Numeral0 < n ==> xzgcd m n = (r, s, t) ==> r = s * m + t * n"
27.478 + "0 < n ==> xzgcd m n = (r, s, t) ==> r = s * m + t * n"
27.479 apply (unfold xzgcd_def)
27.480 apply (erule xzgcda_linear)
27.481 apply assumption
27.482 @@ -795,7 +795,7 @@
27.483 done
27.484
27.485 lemma zgcd_ex_linear:
27.486 - "Numeral0 < n ==> zgcd (m, n) = k ==> (\<exists>s t. k = s * m + t * n)"
27.487 + "0 < n ==> zgcd (m, n) = k ==> (\<exists>s t. k = s * m + t * n)"
27.488 apply (simp add: xzgcd_correct)
27.489 apply safe
27.490 apply (rule exI)+
27.491 @@ -804,8 +804,8 @@
27.492 done
27.493
27.494 lemma zcong_lineq_ex:
27.495 - "Numeral0 < n ==> zgcd (a, n) = Numeral1 ==> \<exists>x. [a * x = Numeral1] (mod n)"
27.496 - apply (cut_tac m = a and n = n and k = "Numeral1" in zgcd_ex_linear)
27.497 + "0 < n ==> zgcd (a, n) = 1 ==> \<exists>x. [a * x = 1] (mod n)"
27.498 + apply (cut_tac m = a and n = n and k = "1" in zgcd_ex_linear)
27.499 apply safe
27.500 apply (rule_tac x = s in exI)
27.501 apply (rule_tac b = "s * a + t * n" in zcong_trans)
27.502 @@ -816,8 +816,8 @@
27.503 done
27.504
27.505 lemma zcong_lineq_unique:
27.506 - "Numeral0 < n ==>
27.507 - zgcd (a, n) = Numeral1 ==> \<exists>!x. Numeral0 \<le> x \<and> x < n \<and> [a * x = b] (mod n)"
27.508 + "0 < n ==>
27.509 + zgcd (a, n) = 1 ==> \<exists>!x. 0 \<le> x \<and> x < n \<and> [a * x = b] (mod n)"
27.510 apply auto
27.511 apply (rule_tac [2] zcong_zless_imp_eq)
27.512 apply (tactic {* stac (thm "zcong_cancel2" RS sym) 6 *})
27.513 @@ -833,7 +833,7 @@
27.514 apply (subst zcong_zmod)
27.515 apply (subst zmod_zmult1_eq [symmetric])
27.516 apply (subst zcong_zmod [symmetric])
27.517 - apply (subgoal_tac "[a * x * b = Numeral1 * b] (mod n)")
27.518 + apply (subgoal_tac "[a * x * b = 1 * b] (mod n)")
27.519 apply (rule_tac [2] zcong_zmult)
27.520 apply (simp_all add: zmult_assoc)
27.521 done
28.1 --- a/src/HOL/NumberTheory/WilsonBij.thy Mon Oct 22 11:01:30 2001 +0200
28.2 +++ b/src/HOL/NumberTheory/WilsonBij.thy Mon Oct 22 11:54:22 2001 +0200
28.3 @@ -20,19 +20,19 @@
28.4 constdefs
28.5 reciR :: "int => int => int => bool"
28.6 "reciR p ==
28.7 - \<lambda>a b. zcong (a * b) Numeral1 p \<and> Numeral1 < a \<and> a < p - Numeral1 \<and> Numeral1 < b \<and> b < p - Numeral1"
28.8 + \<lambda>a b. zcong (a * b) 1 p \<and> 1 < a \<and> a < p - 1 \<and> 1 < b \<and> b < p - 1"
28.9 inv :: "int => int => int"
28.10 "inv p a ==
28.11 - if p \<in> zprime \<and> Numeral0 < a \<and> a < p then
28.12 - (SOME x. Numeral0 \<le> x \<and> x < p \<and> zcong (a * x) Numeral1 p)
28.13 - else Numeral0"
28.14 + if p \<in> zprime \<and> 0 < a \<and> a < p then
28.15 + (SOME x. 0 \<le> x \<and> x < p \<and> zcong (a * x) 1 p)
28.16 + else 0"
28.17
28.18
28.19 text {* \medskip Inverse *}
28.20
28.21 lemma inv_correct:
28.22 - "p \<in> zprime ==> Numeral0 < a ==> a < p
28.23 - ==> Numeral0 \<le> inv p a \<and> inv p a < p \<and> [a * inv p a = Numeral1] (mod p)"
28.24 + "p \<in> zprime ==> 0 < a ==> a < p
28.25 + ==> 0 \<le> inv p a \<and> inv p a < p \<and> [a * inv p a = 1] (mod p)"
28.26 apply (unfold inv_def)
28.27 apply (simp (no_asm_simp))
28.28 apply (rule zcong_lineq_unique [THEN ex1_implies_ex, THEN someI_ex])
28.29 @@ -46,53 +46,53 @@
28.30 lemmas inv_is_inv = inv_correct [THEN conjunct2, THEN conjunct2, standard]
28.31
28.32 lemma inv_not_0:
28.33 - "p \<in> zprime ==> Numeral1 < a ==> a < p - Numeral1 ==> inv p a \<noteq> Numeral0"
28.34 + "p \<in> zprime ==> 1 < a ==> a < p - 1 ==> inv p a \<noteq> 0"
28.35 -- {* same as @{text WilsonRuss} *}
28.36 apply safe
28.37 apply (cut_tac a = a and p = p in inv_is_inv)
28.38 apply (unfold zcong_def)
28.39 apply auto
28.40 - apply (subgoal_tac "\<not> p dvd Numeral1")
28.41 + apply (subgoal_tac "\<not> p dvd 1")
28.42 apply (rule_tac [2] zdvd_not_zless)
28.43 - apply (subgoal_tac "p dvd Numeral1")
28.44 + apply (subgoal_tac "p dvd 1")
28.45 prefer 2
28.46 apply (subst zdvd_zminus_iff [symmetric])
28.47 apply auto
28.48 done
28.49
28.50 lemma inv_not_1:
28.51 - "p \<in> zprime ==> Numeral1 < a ==> a < p - Numeral1 ==> inv p a \<noteq> Numeral1"
28.52 + "p \<in> zprime ==> 1 < a ==> a < p - 1 ==> inv p a \<noteq> 1"
28.53 -- {* same as @{text WilsonRuss} *}
28.54 apply safe
28.55 apply (cut_tac a = a and p = p in inv_is_inv)
28.56 prefer 4
28.57 apply simp
28.58 - apply (subgoal_tac "a = Numeral1")
28.59 + apply (subgoal_tac "a = 1")
28.60 apply (rule_tac [2] zcong_zless_imp_eq)
28.61 apply auto
28.62 done
28.63
28.64 -lemma aux: "[a * (p - Numeral1) = Numeral1] (mod p) = [a = p - Numeral1] (mod p)"
28.65 +lemma aux: "[a * (p - 1) = 1] (mod p) = [a = p - 1] (mod p)"
28.66 -- {* same as @{text WilsonRuss} *}
28.67 apply (unfold zcong_def)
28.68 apply (simp add: zdiff_zdiff_eq zdiff_zdiff_eq2 zdiff_zmult_distrib2)
28.69 - apply (rule_tac s = "p dvd -((a + Numeral1) + (p * -a))" in trans)
28.70 + apply (rule_tac s = "p dvd -((a + 1) + (p * -a))" in trans)
28.71 apply (simp add: zmult_commute zminus_zdiff_eq)
28.72 apply (subst zdvd_zminus_iff)
28.73 apply (subst zdvd_reduce)
28.74 - apply (rule_tac s = "p dvd (a + Numeral1) + (p * -Numeral1)" in trans)
28.75 + apply (rule_tac s = "p dvd (a + 1) + (p * -1)" in trans)
28.76 apply (subst zdvd_reduce)
28.77 apply auto
28.78 done
28.79
28.80 lemma inv_not_p_minus_1:
28.81 - "p \<in> zprime ==> Numeral1 < a ==> a < p - Numeral1 ==> inv p a \<noteq> p - Numeral1"
28.82 + "p \<in> zprime ==> 1 < a ==> a < p - 1 ==> inv p a \<noteq> p - 1"
28.83 -- {* same as @{text WilsonRuss} *}
28.84 apply safe
28.85 apply (cut_tac a = a and p = p in inv_is_inv)
28.86 apply auto
28.87 apply (simp add: aux)
28.88 - apply (subgoal_tac "a = p - Numeral1")
28.89 + apply (subgoal_tac "a = p - 1")
28.90 apply (rule_tac [2] zcong_zless_imp_eq)
28.91 apply auto
28.92 done
28.93 @@ -102,9 +102,9 @@
28.94 but use ``@{text correct}'' theorems.
28.95 *}
28.96
28.97 -lemma inv_g_1: "p \<in> zprime ==> Numeral1 < a ==> a < p - Numeral1 ==> Numeral1 < inv p a"
28.98 - apply (subgoal_tac "inv p a \<noteq> Numeral1")
28.99 - apply (subgoal_tac "inv p a \<noteq> Numeral0")
28.100 +lemma inv_g_1: "p \<in> zprime ==> 1 < a ==> a < p - 1 ==> 1 < inv p a"
28.101 + apply (subgoal_tac "inv p a \<noteq> 1")
28.102 + apply (subgoal_tac "inv p a \<noteq> 0")
28.103 apply (subst order_less_le)
28.104 apply (subst zle_add1_eq_le [symmetric])
28.105 apply (subst order_less_le)
28.106 @@ -116,7 +116,7 @@
28.107 done
28.108
28.109 lemma inv_less_p_minus_1:
28.110 - "p \<in> zprime ==> Numeral1 < a ==> a < p - Numeral1 ==> inv p a < p - Numeral1"
28.111 + "p \<in> zprime ==> 1 < a ==> a < p - 1 ==> inv p a < p - 1"
28.112 -- {* ditto *}
28.113 apply (subst order_less_le)
28.114 apply (simp add: inv_not_p_minus_1 inv_less)
28.115 @@ -125,11 +125,11 @@
28.116
28.117 text {* \medskip Bijection *}
28.118
28.119 -lemma aux1: "Numeral1 < x ==> Numeral0 \<le> (x::int)"
28.120 +lemma aux1: "1 < x ==> 0 \<le> (x::int)"
28.121 apply auto
28.122 done
28.123
28.124 -lemma aux2: "Numeral1 < x ==> Numeral0 < (x::int)"
28.125 +lemma aux2: "1 < x ==> 0 < (x::int)"
28.126 apply auto
28.127 done
28.128
28.129 @@ -137,7 +137,7 @@
28.130 apply auto
28.131 done
28.132
28.133 -lemma aux4: "x \<le> p - 2 ==> x < (p::int)-Numeral1"
28.134 +lemma aux4: "x \<le> p - 2 ==> x < (p::int) - 1"
28.135 apply auto
28.136 done
28.137
28.138 @@ -167,7 +167,7 @@
28.139 apply auto
28.140 apply (rule d22set_mem)
28.141 apply (erule inv_g_1)
28.142 - apply (subgoal_tac [3] "inv p xa < p - Numeral1")
28.143 + apply (subgoal_tac [3] "inv p xa < p - 1")
28.144 apply (erule_tac [4] inv_less_p_minus_1)
28.145 apply (auto intro: d22set_g_1 d22set_le aux4)
28.146 done
28.147 @@ -229,28 +229,28 @@
28.148 subsection {* Wilson *}
28.149
28.150 lemma bijER_zcong_prod_1:
28.151 - "p \<in> zprime ==> A \<in> bijER (reciR p) ==> [setprod A = Numeral1] (mod p)"
28.152 + "p \<in> zprime ==> A \<in> bijER (reciR p) ==> [setprod A = 1] (mod p)"
28.153 apply (unfold reciR_def)
28.154 apply (erule bijER.induct)
28.155 - apply (subgoal_tac [2] "a = Numeral1 \<or> a = p - Numeral1")
28.156 + apply (subgoal_tac [2] "a = 1 \<or> a = p - 1")
28.157 apply (rule_tac [3] zcong_square_zless)
28.158 apply auto
28.159 apply (subst setprod_insert)
28.160 prefer 3
28.161 apply (subst setprod_insert)
28.162 apply (auto simp add: fin_bijER)
28.163 - apply (subgoal_tac "zcong ((a * b) * setprod A) (Numeral1 * Numeral1) p")
28.164 + apply (subgoal_tac "zcong ((a * b) * setprod A) (1 * 1) p")
28.165 apply (simp add: zmult_assoc)
28.166 apply (rule zcong_zmult)
28.167 apply auto
28.168 done
28.169
28.170 -theorem Wilson_Bij: "p \<in> zprime ==> [zfact (p - Numeral1) = -1] (mod p)"
28.171 - apply (subgoal_tac "zcong ((p - Numeral1) * zfact (p - 2)) (-1 * Numeral1) p")
28.172 +theorem Wilson_Bij: "p \<in> zprime ==> [zfact (p - 1) = -1] (mod p)"
28.173 + apply (subgoal_tac "zcong ((p - 1) * zfact (p - 2)) (-1 * 1) p")
28.174 apply (rule_tac [2] zcong_zmult)
28.175 apply (simp add: zprime_def)
28.176 apply (subst zfact.simps)
28.177 - apply (rule_tac t = "p - Numeral1 - Numeral1" and s = "p - 2" in subst)
28.178 + apply (rule_tac t = "p - 1 - 1" and s = "p - 2" in subst)
28.179 apply auto
28.180 apply (simp add: zcong_def)
28.181 apply (subst d22set_prod_zfact [symmetric])
29.1 --- a/src/HOL/NumberTheory/WilsonRuss.thy Mon Oct 22 11:01:30 2001 +0200
29.2 +++ b/src/HOL/NumberTheory/WilsonRuss.thy Mon Oct 22 11:54:22 2001 +0200
29.3 @@ -25,20 +25,20 @@
29.4 recdef wset
29.5 "measure ((\<lambda>(a, p). nat a) :: int * int => nat)"
29.6 "wset (a, p) =
29.7 - (if Numeral1 < a then
29.8 - let ws = wset (a - Numeral1, p)
29.9 + (if 1 < a then
29.10 + let ws = wset (a - 1, p)
29.11 in (if a \<in> ws then ws else insert a (insert (inv p a) ws)) else {})"
29.12
29.13
29.14 text {* \medskip @{term [source] inv} *}
29.15
29.16 -lemma aux: "Numeral1 < m ==> Suc (nat (m - 2)) = nat (m - Numeral1)"
29.17 +lemma aux: "1 < m ==> Suc (nat (m - 2)) = nat (m - 1)"
29.18 apply (subst int_int_eq [symmetric])
29.19 apply auto
29.20 done
29.21
29.22 lemma inv_is_inv:
29.23 - "p \<in> zprime \<Longrightarrow> Numeral0 < a \<Longrightarrow> a < p ==> [a * inv p a = Numeral1] (mod p)"
29.24 + "p \<in> zprime \<Longrightarrow> 0 < a \<Longrightarrow> a < p ==> [a * inv p a = 1] (mod p)"
29.25 apply (unfold inv_def)
29.26 apply (subst zcong_zmod)
29.27 apply (subst zmod_zmult1_eq [symmetric])
29.28 @@ -52,71 +52,71 @@
29.29 done
29.30
29.31 lemma inv_distinct:
29.32 - "p \<in> zprime \<Longrightarrow> Numeral1 < a \<Longrightarrow> a < p - Numeral1 ==> a \<noteq> inv p a"
29.33 + "p \<in> zprime \<Longrightarrow> 1 < a \<Longrightarrow> a < p - 1 ==> a \<noteq> inv p a"
29.34 apply safe
29.35 apply (cut_tac a = a and p = p in zcong_square)
29.36 apply (cut_tac [3] a = a and p = p in inv_is_inv)
29.37 apply auto
29.38 - apply (subgoal_tac "a = Numeral1")
29.39 + apply (subgoal_tac "a = 1")
29.40 apply (rule_tac [2] m = p in zcong_zless_imp_eq)
29.41 - apply (subgoal_tac [7] "a = p - Numeral1")
29.42 + apply (subgoal_tac [7] "a = p - 1")
29.43 apply (rule_tac [8] m = p in zcong_zless_imp_eq)
29.44 apply auto
29.45 done
29.46
29.47 lemma inv_not_0:
29.48 - "p \<in> zprime \<Longrightarrow> Numeral1 < a \<Longrightarrow> a < p - Numeral1 ==> inv p a \<noteq> Numeral0"
29.49 + "p \<in> zprime \<Longrightarrow> 1 < a \<Longrightarrow> a < p - 1 ==> inv p a \<noteq> 0"
29.50 apply safe
29.51 apply (cut_tac a = a and p = p in inv_is_inv)
29.52 apply (unfold zcong_def)
29.53 apply auto
29.54 - apply (subgoal_tac "\<not> p dvd Numeral1")
29.55 + apply (subgoal_tac "\<not> p dvd 1")
29.56 apply (rule_tac [2] zdvd_not_zless)
29.57 - apply (subgoal_tac "p dvd Numeral1")
29.58 + apply (subgoal_tac "p dvd 1")
29.59 prefer 2
29.60 apply (subst zdvd_zminus_iff [symmetric])
29.61 apply auto
29.62 done
29.63
29.64 lemma inv_not_1:
29.65 - "p \<in> zprime \<Longrightarrow> Numeral1 < a \<Longrightarrow> a < p - Numeral1 ==> inv p a \<noteq> Numeral1"
29.66 + "p \<in> zprime \<Longrightarrow> 1 < a \<Longrightarrow> a < p - 1 ==> inv p a \<noteq> 1"
29.67 apply safe
29.68 apply (cut_tac a = a and p = p in inv_is_inv)
29.69 prefer 4
29.70 apply simp
29.71 - apply (subgoal_tac "a = Numeral1")
29.72 + apply (subgoal_tac "a = 1")
29.73 apply (rule_tac [2] zcong_zless_imp_eq)
29.74 apply auto
29.75 done
29.76
29.77 -lemma aux: "[a * (p - Numeral1) = Numeral1] (mod p) = [a = p - Numeral1] (mod p)"
29.78 +lemma aux: "[a * (p - 1) = 1] (mod p) = [a = p - 1] (mod p)"
29.79 apply (unfold zcong_def)
29.80 apply (simp add: zdiff_zdiff_eq zdiff_zdiff_eq2 zdiff_zmult_distrib2)
29.81 - apply (rule_tac s = "p dvd -((a + Numeral1) + (p * -a))" in trans)
29.82 + apply (rule_tac s = "p dvd -((a + 1) + (p * -a))" in trans)
29.83 apply (simp add: zmult_commute zminus_zdiff_eq)
29.84 apply (subst zdvd_zminus_iff)
29.85 apply (subst zdvd_reduce)
29.86 - apply (rule_tac s = "p dvd (a + Numeral1) + (p * -Numeral1)" in trans)
29.87 + apply (rule_tac s = "p dvd (a + 1) + (p * -1)" in trans)
29.88 apply (subst zdvd_reduce)
29.89 apply auto
29.90 done
29.91
29.92 lemma inv_not_p_minus_1:
29.93 - "p \<in> zprime \<Longrightarrow> Numeral1 < a \<Longrightarrow> a < p - Numeral1 ==> inv p a \<noteq> p - Numeral1"
29.94 + "p \<in> zprime \<Longrightarrow> 1 < a \<Longrightarrow> a < p - 1 ==> inv p a \<noteq> p - 1"
29.95 apply safe
29.96 apply (cut_tac a = a and p = p in inv_is_inv)
29.97 apply auto
29.98 apply (simp add: aux)
29.99 - apply (subgoal_tac "a = p - Numeral1")
29.100 + apply (subgoal_tac "a = p - 1")
29.101 apply (rule_tac [2] zcong_zless_imp_eq)
29.102 apply auto
29.103 done
29.104
29.105 lemma inv_g_1:
29.106 - "p \<in> zprime \<Longrightarrow> Numeral1 < a \<Longrightarrow> a < p - Numeral1 ==> Numeral1 < inv p a"
29.107 - apply (case_tac "Numeral0\<le> inv p a")
29.108 - apply (subgoal_tac "inv p a \<noteq> Numeral1")
29.109 - apply (subgoal_tac "inv p a \<noteq> Numeral0")
29.110 + "p \<in> zprime \<Longrightarrow> 1 < a \<Longrightarrow> a < p - 1 ==> 1 < inv p a"
29.111 + apply (case_tac "0\<le> inv p a")
29.112 + apply (subgoal_tac "inv p a \<noteq> 1")
29.113 + apply (subgoal_tac "inv p a \<noteq> 0")
29.114 apply (subst order_less_le)
29.115 apply (subst zle_add1_eq_le [symmetric])
29.116 apply (subst order_less_le)
29.117 @@ -128,7 +128,7 @@
29.118 done
29.119
29.120 lemma inv_less_p_minus_1:
29.121 - "p \<in> zprime \<Longrightarrow> Numeral1 < a \<Longrightarrow> a < p - Numeral1 ==> inv p a < p - Numeral1"
29.122 + "p \<in> zprime \<Longrightarrow> 1 < a \<Longrightarrow> a < p - 1 ==> inv p a < p - 1"
29.123 apply (case_tac "inv p a < p")
29.124 apply (subst order_less_le)
29.125 apply (simp add: inv_not_p_minus_1)
29.126 @@ -138,23 +138,23 @@
29.127 done
29.128
29.129 lemma aux: "5 \<le> p ==>
29.130 - nat (p - 2) * nat (p - 2) = Suc (nat (p - Numeral1) * nat (p - 3))"
29.131 + nat (p - 2) * nat (p - 2) = Suc (nat (p - 1) * nat (p - 3))"
29.132 apply (subst int_int_eq [symmetric])
29.133 apply (simp add: zmult_int [symmetric])
29.134 apply (simp add: zdiff_zmult_distrib zdiff_zmult_distrib2)
29.135 done
29.136
29.137 lemma zcong_zpower_zmult:
29.138 - "[x^y = Numeral1] (mod p) \<Longrightarrow> [x^(y * z) = Numeral1] (mod p)"
29.139 + "[x^y = 1] (mod p) \<Longrightarrow> [x^(y * z) = 1] (mod p)"
29.140 apply (induct z)
29.141 apply (auto simp add: zpower_zadd_distrib)
29.142 - apply (subgoal_tac "zcong (x^y * x^(y * n)) (Numeral1 * Numeral1) p")
29.143 + apply (subgoal_tac "zcong (x^y * x^(y * n)) (1 * 1) p")
29.144 apply (rule_tac [2] zcong_zmult)
29.145 apply simp_all
29.146 done
29.147
29.148 lemma inv_inv: "p \<in> zprime \<Longrightarrow>
29.149 - 5 \<le> p \<Longrightarrow> Numeral0 < a \<Longrightarrow> a < p ==> inv p (inv p a) = a"
29.150 + 5 \<le> p \<Longrightarrow> 0 < a \<Longrightarrow> a < p ==> inv p (inv p a) = a"
29.151 apply (unfold inv_def)
29.152 apply (subst zpower_zmod)
29.153 apply (subst zpower_zpower)
29.154 @@ -165,7 +165,7 @@
29.155 apply (subst zcong_zmod [symmetric])
29.156 apply (subst aux)
29.157 apply (subgoal_tac [2]
29.158 - "zcong (a * a^(nat (p - Numeral1) * nat (p - 3))) (a * Numeral1) p")
29.159 + "zcong (a * a^(nat (p - 1) * nat (p - 3))) (a * 1) p")
29.160 apply (rule_tac [3] zcong_zmult)
29.161 apply (rule_tac [4] zcong_zpower_zmult)
29.162 apply (erule_tac [4] Little_Fermat)
29.163 @@ -180,7 +180,7 @@
29.164
29.165 lemma wset_induct:
29.166 "(!!a p. P {} a p) \<Longrightarrow>
29.167 - (!!a p. Numeral1 < (a::int) \<Longrightarrow> P (wset (a - Numeral1, p)) (a - Numeral1) p
29.168 + (!!a p. 1 < (a::int) \<Longrightarrow> P (wset (a - 1, p)) (a - 1) p
29.169 ==> P (wset (a, p)) a p)
29.170 ==> P (wset (u, v)) u v"
29.171 proof -
29.172 @@ -188,7 +188,7 @@
29.173 show ?thesis
29.174 apply (rule wset.induct)
29.175 apply safe
29.176 - apply (case_tac [2] "Numeral1 < a")
29.177 + apply (case_tac [2] "1 < a")
29.178 apply (rule_tac [2] rule_context)
29.179 apply simp_all
29.180 apply (simp_all add: wset.simps rule_context)
29.181 @@ -196,27 +196,27 @@
29.182 qed
29.183
29.184 lemma wset_mem_imp_or [rule_format]:
29.185 - "Numeral1 < a \<Longrightarrow> b \<notin> wset (a - Numeral1, p)
29.186 + "1 < a \<Longrightarrow> b \<notin> wset (a - 1, p)
29.187 ==> b \<in> wset (a, p) --> b = a \<or> b = inv p a"
29.188 apply (subst wset.simps)
29.189 apply (unfold Let_def)
29.190 apply simp
29.191 done
29.192
29.193 -lemma wset_mem_mem [simp]: "Numeral1 < a ==> a \<in> wset (a, p)"
29.194 +lemma wset_mem_mem [simp]: "1 < a ==> a \<in> wset (a, p)"
29.195 apply (subst wset.simps)
29.196 apply (unfold Let_def)
29.197 apply simp
29.198 done
29.199
29.200 -lemma wset_subset: "Numeral1 < a \<Longrightarrow> b \<in> wset (a - Numeral1, p) ==> b \<in> wset (a, p)"
29.201 +lemma wset_subset: "1 < a \<Longrightarrow> b \<in> wset (a - 1, p) ==> b \<in> wset (a, p)"
29.202 apply (subst wset.simps)
29.203 apply (unfold Let_def)
29.204 apply auto
29.205 done
29.206
29.207 lemma wset_g_1 [rule_format]:
29.208 - "p \<in> zprime --> a < p - Numeral1 --> b \<in> wset (a, p) --> Numeral1 < b"
29.209 + "p \<in> zprime --> a < p - 1 --> b \<in> wset (a, p) --> 1 < b"
29.210 apply (induct a p rule: wset_induct)
29.211 apply auto
29.212 apply (case_tac "b = a")
29.213 @@ -230,7 +230,7 @@
29.214 done
29.215
29.216 lemma wset_less [rule_format]:
29.217 - "p \<in> zprime --> a < p - Numeral1 --> b \<in> wset (a, p) --> b < p - Numeral1"
29.218 + "p \<in> zprime --> a < p - 1 --> b \<in> wset (a, p) --> b < p - 1"
29.219 apply (induct a p rule: wset_induct)
29.220 apply auto
29.221 apply (case_tac "b = a")
29.222 @@ -245,7 +245,7 @@
29.223
29.224 lemma wset_mem [rule_format]:
29.225 "p \<in> zprime -->
29.226 - a < p - Numeral1 --> Numeral1 < b --> b \<le> a --> b \<in> wset (a, p)"
29.227 + a < p - 1 --> 1 < b --> b \<le> a --> b \<in> wset (a, p)"
29.228 apply (induct a p rule: wset.induct)
29.229 apply auto
29.230 apply (subgoal_tac "b = a")
29.231 @@ -256,7 +256,7 @@
29.232 done
29.233
29.234 lemma wset_mem_inv_mem [rule_format]:
29.235 - "p \<in> zprime --> 5 \<le> p --> a < p - Numeral1 --> b \<in> wset (a, p)
29.236 + "p \<in> zprime --> 5 \<le> p --> a < p - 1 --> b \<in> wset (a, p)
29.237 --> inv p b \<in> wset (a, p)"
29.238 apply (induct a p rule: wset_induct)
29.239 apply auto
29.240 @@ -274,7 +274,7 @@
29.241 done
29.242
29.243 lemma wset_inv_mem_mem:
29.244 - "p \<in> zprime \<Longrightarrow> 5 \<le> p \<Longrightarrow> a < p - Numeral1 \<Longrightarrow> Numeral1 < b \<Longrightarrow> b < p - Numeral1
29.245 + "p \<in> zprime \<Longrightarrow> 5 \<le> p \<Longrightarrow> a < p - 1 \<Longrightarrow> 1 < b \<Longrightarrow> b < p - 1
29.246 \<Longrightarrow> inv p b \<in> wset (a, p) \<Longrightarrow> b \<in> wset (a, p)"
29.247 apply (rule_tac s = "inv p (inv p b)" and t = b in subst)
29.248 apply (rule_tac [2] wset_mem_inv_mem)
29.249 @@ -292,7 +292,7 @@
29.250
29.251 lemma wset_zcong_prod_1 [rule_format]:
29.252 "p \<in> zprime -->
29.253 - 5 \<le> p --> a < p - Numeral1 --> [setprod (wset (a, p)) = Numeral1] (mod p)"
29.254 + 5 \<le> p --> a < p - 1 --> [setprod (wset (a, p)) = 1] (mod p)"
29.255 apply (induct a p rule: wset_induct)
29.256 prefer 2
29.257 apply (subst wset.simps)
29.258 @@ -301,13 +301,13 @@
29.259 apply (subst setprod_insert)
29.260 apply (tactic {* stac (thm "setprod_insert") 3 *})
29.261 apply (subgoal_tac [5]
29.262 - "zcong (a * inv p a * setprod (wset (a - Numeral1, p))) (Numeral1 * Numeral1) p")
29.263 + "zcong (a * inv p a * setprod (wset (a - 1, p))) (1 * 1) p")
29.264 prefer 5
29.265 apply (simp add: zmult_assoc)
29.266 apply (rule_tac [5] zcong_zmult)
29.267 apply (rule_tac [5] inv_is_inv)
29.268 apply (tactic "Clarify_tac 4")
29.269 - apply (subgoal_tac [4] "a \<in> wset (a - Numeral1, p)")
29.270 + apply (subgoal_tac [4] "a \<in> wset (a - 1, p)")
29.271 apply (rule_tac [5] wset_inv_mem_mem)
29.272 apply (simp_all add: wset_fin)
29.273 apply (rule inv_distinct)
29.274 @@ -323,7 +323,7 @@
29.275 apply (erule_tac [4] wset_g_1)
29.276 prefer 6
29.277 apply (subst zle_add1_eq_le [symmetric])
29.278 - apply (subgoal_tac "p - 2 + Numeral1 = p - Numeral1")
29.279 + apply (subgoal_tac "p - 2 + 1 = p - 1")
29.280 apply (simp (no_asm_simp))
29.281 apply (erule wset_less)
29.282 apply auto
29.283 @@ -348,12 +348,12 @@
29.284 done
29.285
29.286 theorem Wilson_Russ:
29.287 - "p \<in> zprime ==> [zfact (p - Numeral1) = -1] (mod p)"
29.288 - apply (subgoal_tac "[(p - Numeral1) * zfact (p - 2) = -1 * Numeral1] (mod p)")
29.289 + "p \<in> zprime ==> [zfact (p - 1) = -1] (mod p)"
29.290 + apply (subgoal_tac "[(p - 1) * zfact (p - 2) = -1 * 1] (mod p)")
29.291 apply (rule_tac [2] zcong_zmult)
29.292 apply (simp only: zprime_def)
29.293 apply (subst zfact.simps)
29.294 - apply (rule_tac t = "p - Numeral1 - Numeral1" and s = "p - 2" in subst)
29.295 + apply (rule_tac t = "p - 1 - 1" and s = "p - 2" in subst)
29.296 apply auto
29.297 apply (simp only: zcong_def)
29.298 apply (simp (no_asm_simp))
30.1 --- a/src/HOL/Numeral.thy Mon Oct 22 11:01:30 2001 +0200
30.2 +++ b/src/HOL/Numeral.thy Mon Oct 22 11:54:22 2001 +0200
30.3 @@ -40,10 +40,10 @@
30.4 lemma Let_number_of [simp]: "Let (number_of v) f == f (number_of v)"
30.5 by (simp add: Let_def)
30.6
30.7 -(*The condition "True" is a hack to prevent looping.
30.8 - Conditional rewrite rules are tried after unconditional ones, so a rule
30.9 - like eq_nat_number_of will be tried first to eliminate #mm=#nn. *)
30.10 -lemma number_of_reorient [simp]: "True ==> (number_of w = x) = (x = number_of w)"
30.11 - by auto
30.12 +lemma Let_0 [simp]: "Let 0 f == f 0"
30.13 + by (simp add: Let_def)
30.14 +
30.15 +lemma Let_1 [simp]: "Let 1 f == f 1"
30.16 + by (simp add: Let_def)
30.17
30.18 end
31.1 --- a/src/HOL/ROOT.ML Mon Oct 22 11:01:30 2001 +0200
31.2 +++ b/src/HOL/ROOT.ML Mon Oct 22 11:54:22 2001 +0200
31.3 @@ -29,6 +29,7 @@
31.4 use "~~/src/Provers/Arith/abel_cancel.ML";
31.5 use "~~/src/Provers/Arith/assoc_fold.ML";
31.6 use "~~/src/Provers/quantifier1.ML";
31.7 +use "~~/src/Provers/Arith/abstract_numerals.ML";
31.8 use "~~/src/Provers/Arith/cancel_numerals.ML";
31.9 use "~~/src/Provers/Arith/combine_numerals.ML";
31.10 use "~~/src/Provers/Arith/cancel_numeral_factor.ML";
32.1 --- a/src/HOL/Real/ex/Sqrt_Irrational.thy Mon Oct 22 11:01:30 2001 +0200
32.2 +++ b/src/HOL/Real/ex/Sqrt_Irrational.thy Mon Oct 22 11:54:22 2001 +0200
32.3 @@ -119,7 +119,7 @@
32.4 {
32.5 fix m :: nat assume dvd: "m dvd 2"
32.6 hence "m \<le> 2" by (simp add: dvd_imp_le)
32.7 - moreover from dvd have "m \<noteq> 0" by (auto dest: dvd_0_left iff del: neq0_conv)
32.8 + moreover from dvd have "m \<noteq> 0" by (auto iff del: neq0_conv)
32.9 ultimately have "m = 1 \<or> m = 2" by arith
32.10 }
32.11 thus "2 \<in> prime" by (simp add: prime_def)
33.1 --- a/src/HOL/SVC_Oracle.ML Mon Oct 22 11:01:30 2001 +0200
33.2 +++ b/src/HOL/SVC_Oracle.ML Mon Oct 22 11:54:22 2001 +0200
33.3 @@ -41,30 +41,29 @@
33.4 | _ => (case gen_assoc Pattern.aeconv (!pairs, t) of
33.5 Some v => v
33.6 | None => insert t)
33.7 + (*abstraction of a numeric literal*)
33.8 + fun lit (t as Const("0", _)) = t
33.9 + | lit (t as Const("1", _)) = t
33.10 + | lit (t as Const("Numeral.number_of", _) $ w) = t
33.11 + | lit t = replace t
33.12 (*abstraction of a real/rational expression*)
33.13 fun rat ((c as Const("op +", _)) $ x $ y) = c $ (rat x) $ (rat y)
33.14 | rat ((c as Const("op -", _)) $ x $ y) = c $ (rat x) $ (rat y)
33.15 | rat ((c as Const("op /", _)) $ x $ y) = c $ (rat x) $ (rat y)
33.16 | rat ((c as Const("op *", _)) $ x $ y) = c $ (rat x) $ (rat y)
33.17 | rat ((c as Const("uminus", _)) $ x) = c $ (rat x)
33.18 - | rat ((c as Const("0", _))) = c
33.19 - | rat ((c as Const("1", _))) = c
33.20 - | rat (t as Const("Numeral.number_of", _) $ w) = t
33.21 - | rat t = replace t
33.22 + | rat t = lit t
33.23 (*abstraction of an integer expression: no div, mod*)
33.24 fun int ((c as Const("op +", _)) $ x $ y) = c $ (int x) $ (int y)
33.25 | int ((c as Const("op -", _)) $ x $ y) = c $ (int x) $ (int y)
33.26 | int ((c as Const("op *", _)) $ x $ y) = c $ (int x) $ (int y)
33.27 | int ((c as Const("uminus", _)) $ x) = c $ (int x)
33.28 - | int (t as Const("Numeral.number_of", _) $ w) = t
33.29 - | int t = replace t
33.30 + | int t = lit t
33.31 (*abstraction of a natural number expression: no minus*)
33.32 fun nat ((c as Const("op +", _)) $ x $ y) = c $ (nat x) $ (nat y)
33.33 | nat ((c as Const("op *", _)) $ x $ y) = c $ (nat x) $ (nat y)
33.34 | nat ((c as Const("Suc", _)) $ x) = c $ (nat x)
33.35 - | nat (t as Const("0", _)) = t
33.36 - | nat (t as Const("Numeral.number_of", _) $ w) = t
33.37 - | nat t = replace t
33.38 + | nat t = lit t
33.39 (*abstraction of a relation: =, <, <=*)
33.40 fun rel (T, c $ x $ y) =
33.41 if T = HOLogic.realT then c $ (rat x) $ (rat y)
34.1 --- a/src/HOL/UNITY/Comp/Counter.ML Mon Oct 22 11:01:30 2001 +0200
34.2 +++ b/src/HOL/UNITY/Comp/Counter.ML Mon Oct 22 11:54:22 2001 +0200
34.3 @@ -100,7 +100,7 @@
34.4
34.5 (* Compositional Proof *)
34.6
34.7 -Goal "(ALL i. i < I --> s (c i) = Numeral0) --> sum I s = Numeral0";
34.8 +Goal "(ALL i. i < I --> s (c i) = 0) --> sum I s = 0";
34.9 by (induct_tac "I" 1);
34.10 by Auto_tac;
34.11 qed "sum_0'";
35.1 --- a/src/HOL/UNITY/Comp/Counter.thy Mon Oct 22 11:01:30 2001 +0200
35.2 +++ b/src/HOL/UNITY/Comp/Counter.thy Mon Oct 22 11:54:22 2001 +0200
35.3 @@ -21,21 +21,21 @@
35.4 sumj :: "[nat, nat, state]=>int"
35.5
35.6 primrec (* sum I s = sigma_{i<I}. s (c i) *)
35.7 - "sum 0 s = Numeral0"
35.8 + "sum 0 s = 0"
35.9 "sum (Suc i) s = s (c i) + sum i s"
35.10
35.11 primrec
35.12 - "sumj 0 i s = Numeral0"
35.13 + "sumj 0 i s = 0"
35.14 "sumj (Suc n) i s = (if n=i then sum n s else s (c n) + sumj n i s)"
35.15
35.16 types command = "(state*state)set"
35.17
35.18 constdefs
35.19 a :: "nat=>command"
35.20 - "a i == {(s, s'). s'=s(c i:= s (c i) + Numeral1, C:= s C + Numeral1)}"
35.21 + "a i == {(s, s'). s'=s(c i:= s (c i) + 1, C:= s C + 1)}"
35.22
35.23 Component :: "nat => state program"
35.24 "Component i ==
35.25 - mk_program({s. s C = Numeral0 & s (c i) = Numeral0}, {a i},
35.26 + mk_program({s. s C = 0 & s (c i) = 0}, {a i},
35.27 UN G: preserves (%s. s (c i)). Acts G)"
35.28 end
36.1 --- a/src/HOL/UNITY/Comp/Counterc.ML Mon Oct 22 11:01:30 2001 +0200
36.2 +++ b/src/HOL/UNITY/Comp/Counterc.ML Mon Oct 22 11:54:22 2001 +0200
36.3 @@ -38,7 +38,7 @@
36.4 qed_spec_mp "sumj_ext";
36.5
36.6
36.7 -Goal "(ALL i. i<I --> c s i = Numeral0) --> sum I s = Numeral0";
36.8 +Goal "(ALL i. i<I --> c s i = 0) --> sum I s = 0";
36.9 by (induct_tac "I" 1);
36.10 by Auto_tac;
36.11 qed "sum0";
37.1 --- a/src/HOL/UNITY/Comp/Counterc.thy Mon Oct 22 11:01:30 2001 +0200
37.2 +++ b/src/HOL/UNITY/Comp/Counterc.thy Mon Oct 22 11:54:22 2001 +0200
37.3 @@ -24,20 +24,20 @@
37.4 sumj :: "[nat, nat, state]=>int"
37.5
37.6 primrec (* sum I s = sigma_{i<I}. c s i *)
37.7 - "sum 0 s = Numeral0"
37.8 + "sum 0 s = 0"
37.9 "sum (Suc i) s = (c s) i + sum i s"
37.10
37.11 primrec
37.12 - "sumj 0 i s = Numeral0"
37.13 + "sumj 0 i s = 0"
37.14 "sumj (Suc n) i s = (if n=i then sum n s else (c s) n + sumj n i s)"
37.15
37.16 types command = "(state*state)set"
37.17
37.18 constdefs
37.19 a :: "nat=>command"
37.20 - "a i == {(s, s'). (c s') i = (c s) i + Numeral1 & (C s') = (C s) + Numeral1}"
37.21 + "a i == {(s, s'). (c s') i = (c s) i + 1 & (C s') = (C s) + 1}"
37.22
37.23 Component :: "nat => state program"
37.24 - "Component i == mk_program({s. C s = Numeral0 & (c s) i = Numeral0}, {a i},
37.25 + "Component i == mk_program({s. C s = 0 & (c s) i = 0}, {a i},
37.26 UN G: preserves (%s. (c s) i). Acts G)"
37.27 end
38.1 --- a/src/HOL/UNITY/Simple/Lift.ML Mon Oct 22 11:01:30 2001 +0200
38.2 +++ b/src/HOL/UNITY/Simple/Lift.ML Mon Oct 22 11:54:22 2001 +0200
38.3 @@ -142,7 +142,7 @@
38.4
38.5
38.6 (*lem_lift_4_1 *)
38.7 -Goal "Numeral0 < N ==> \
38.8 +Goal "0 < N ==> \
38.9 \ Lift : (moving Int Req n Int {s. metric n s = N} Int \
38.10 \ {s. floor s ~: req s} Int {s. up s}) \
38.11 \ LeadsTo \
38.12 @@ -157,7 +157,7 @@
38.13
38.14
38.15 (*lem_lift_4_3 *)
38.16 -Goal "Numeral0 < N ==> \
38.17 +Goal "0 < N ==> \
38.18 \ Lift : (moving Int Req n Int {s. metric n s = N} Int \
38.19 \ {s. floor s ~: req s} - {s. up s}) \
38.20 \ LeadsTo (moving Int Req n Int {s. metric n s < N})";
38.21 @@ -170,7 +170,7 @@
38.22 qed "E_thm12b";
38.23
38.24 (*lift_4*)
38.25 -Goal "Numeral0<N ==> Lift : (moving Int Req n Int {s. metric n s = N} Int \
38.26 +Goal "0<N ==> Lift : (moving Int Req n Int {s. metric n s = N} Int \
38.27 \ {s. floor s ~: req s}) LeadsTo \
38.28 \ (moving Int Req n Int {s. metric n s < N})";
38.29 by (rtac ([subset_imp_LeadsTo, [E_thm12a, E_thm12b] MRS LeadsTo_Un]
38.30 @@ -182,7 +182,7 @@
38.31 (** towards lift_5 **)
38.32
38.33 (*lem_lift_5_3*)
38.34 -Goal "Numeral0<N \
38.35 +Goal "0<N \
38.36 \ ==> Lift : (closed Int Req n Int {s. metric n s = N} Int goingup) LeadsTo \
38.37 \ (moving Int Req n Int {s. metric n s < N})";
38.38 by (cut_facts_tac [bounded] 1);
38.39 @@ -192,7 +192,7 @@
38.40
38.41
38.42 (*lem_lift_5_1 has ~goingup instead of goingdown*)
38.43 -Goal "Numeral0<N ==> \
38.44 +Goal "0<N ==> \
38.45 \ Lift : (closed Int Req n Int {s. metric n s = N} Int goingdown) LeadsTo \
38.46 \ (moving Int Req n Int {s. metric n s < N})";
38.47 by (cut_facts_tac [bounded] 1);
38.48 @@ -203,14 +203,14 @@
38.49
38.50 (*lem_lift_5_0 proves an intersection involving ~goingup and goingup,
38.51 i.e. the trivial disjunction, leading to an asymmetrical proof.*)
38.52 -Goal "Numeral0<N ==> Req n Int {s. metric n s = N} <= goingup Un goingdown";
38.53 +Goal "0<N ==> Req n Int {s. metric n s = N} <= goingup Un goingdown";
38.54 by (Clarify_tac 1);
38.55 by (auto_tac (claset(), metric_ss));
38.56 qed "E_thm16c";
38.57
38.58
38.59 (*lift_5*)
38.60 -Goal "Numeral0<N ==> Lift : (closed Int Req n Int {s. metric n s = N}) LeadsTo \
38.61 +Goal "0<N ==> Lift : (closed Int Req n Int {s. metric n s = N}) LeadsTo \
38.62 \ (moving Int Req n Int {s. metric n s < N})";
38.63 by (rtac ([subset_imp_LeadsTo, [E_thm16a, E_thm16b] MRS LeadsTo_Un]
38.64 MRS LeadsTo_Trans) 1);
38.65 @@ -222,7 +222,7 @@
38.66 (** towards lift_3 **)
38.67
38.68 (*lemma used to prove lem_lift_3_1*)
38.69 -Goal "[| metric n s = Numeral0; Min <= floor s; floor s <= Max |] ==> floor s = n";
38.70 +Goal "[| metric n s = 0; Min <= floor s; floor s <= Max |] ==> floor s = n";
38.71 by (auto_tac (claset(), metric_ss));
38.72 qed "metric_eq_0D";
38.73
38.74 @@ -230,7 +230,7 @@
38.75
38.76
38.77 (*lem_lift_3_1*)
38.78 -Goal "Lift : (moving Int Req n Int {s. metric n s = Numeral0}) LeadsTo \
38.79 +Goal "Lift : (moving Int Req n Int {s. metric n s = 0}) LeadsTo \
38.80 \ (stopped Int atFloor n)";
38.81 by (cut_facts_tac [bounded] 1);
38.82 by (ensures_tac "request_act" 1);
38.83 @@ -246,7 +246,7 @@
38.84 qed "E_thm13";
38.85
38.86 (*lem_lift_3_6*)
38.87 -Goal "Numeral0 < N ==> \
38.88 +Goal "0 < N ==> \
38.89 \ Lift : \
38.90 \ (stopped Int Req n Int {s. metric n s = N} Int {s. floor s : req s}) \
38.91 \ LeadsTo (opened Int Req n Int {s. metric n s = N})";
38.92 @@ -264,7 +264,7 @@
38.93
38.94 (** the final steps **)
38.95
38.96 -Goal "Numeral0 < N ==> \
38.97 +Goal "0 < N ==> \
38.98 \ Lift : \
38.99 \ (moving Int Req n Int {s. metric n s = N} Int {s. floor s : req s}) \
38.100 \ LeadsTo (moving Int Req n Int {s. metric n s < N})";
38.101 @@ -274,7 +274,7 @@
38.102
38.103
38.104 (*Now we observe that our integer metric is really a natural number*)
38.105 -Goal "Lift : Always {s. Numeral0 <= metric n s}";
38.106 +Goal "Lift : Always {s. 0 <= metric n s}";
38.107 by (rtac (bounded RS Always_weaken) 1);
38.108 by (auto_tac (claset(), metric_ss));
38.109 qed "Always_nonneg";
38.110 @@ -283,8 +283,8 @@
38.111
38.112 Goal "Lift : (moving Int Req n) LeadsTo (stopped Int atFloor n)";
38.113 by (rtac (Always_nonneg RS integ_0_le_induct) 1);
38.114 -by (case_tac "Numeral0 < z" 1);
38.115 -(*If z <= Numeral0 then actually z = Numeral0*)
38.116 +by (case_tac "0 < z" 1);
38.117 +(*If z <= 0 then actually z = 0*)
38.118 by (force_tac (claset() addIs [R_thm11, order_antisym],
38.119 simpset() addsimps [linorder_not_less]) 2);
38.120 by (rtac ([asm_rl, Un_upper1] MRS LeadsTo_weaken_R) 1);
39.1 --- a/src/HOL/UNITY/Simple/Lift.thy Mon Oct 22 11:01:30 2001 +0200
39.2 +++ b/src/HOL/UNITY/Simple/Lift.thy Mon Oct 22 11:54:22 2001 +0200
39.3 @@ -87,25 +87,25 @@
39.4 req_up :: "(state*state) set"
39.5 "req_up ==
39.6 {(s,s'). s' = s (|stop :=False,
39.7 - floor := floor s + Numeral1,
39.8 + floor := floor s + 1,
39.9 up := True|)
39.10 & s : (ready Int goingup)}"
39.11
39.12 req_down :: "(state*state) set"
39.13 "req_down ==
39.14 {(s,s'). s' = s (|stop :=False,
39.15 - floor := floor s - Numeral1,
39.16 + floor := floor s - 1,
39.17 up := False|)
39.18 & s : (ready Int goingdown)}"
39.19
39.20 move_up :: "(state*state) set"
39.21 "move_up ==
39.22 - {(s,s'). s' = s (|floor := floor s + Numeral1|)
39.23 + {(s,s'). s' = s (|floor := floor s + 1|)
39.24 & ~ stop s & up s & floor s ~: req s}"
39.25
39.26 move_down :: "(state*state) set"
39.27 "move_down ==
39.28 - {(s,s'). s' = s (|floor := floor s - Numeral1|)
39.29 + {(s,s'). s' = s (|floor := floor s - 1|)
39.30 & ~ stop s & ~ up s & floor s ~: req s}"
39.31
39.32 (*This action is omitted from prior treatments, which therefore are
39.33 @@ -156,7 +156,7 @@
39.34 else
39.35 if n < floor s then (if up s then (Max - floor s) + (Max-n)
39.36 else floor s - n)
39.37 - else Numeral0"
39.38 + else 0"
39.39
39.40 locale floor =
39.41 fixes
40.1 --- a/src/HOL/UNITY/Simple/Mutex.ML Mon Oct 22 11:01:30 2001 +0200
40.2 +++ b/src/HOL/UNITY/Simple/Mutex.ML Mon Oct 22 11:54:22 2001 +0200
40.3 @@ -42,7 +42,7 @@
40.4 getgoal 1;
40.5
40.6
40.7 -Goal "((Numeral1::int) <= i & i <= 3) = (i = Numeral1 | i = 2 | i = 3)";
40.8 +Goal "((1::int) <= i & i <= 3) = (i = 1 | i = 2 | i = 3)";
40.9 by (arith_tac 1);
40.10 qed "eq_123";
40.11
40.12 @@ -53,7 +53,7 @@
40.13 by (constrains_tac 1);
40.14 qed "U_F0";
40.15
40.16 -Goal "Mutex : {s. m s=Numeral1} LeadsTo {s. p s = v s & m s = 2}";
40.17 +Goal "Mutex : {s. m s=1} LeadsTo {s. p s = v s & m s = 2}";
40.18 by (ensures_tac "U1" 1);
40.19 qed "U_F1";
40.20
40.21 @@ -75,12 +75,12 @@
40.22 by (auto_tac (claset() addSEs [less_SucE], simpset()));
40.23 val U_lemma2 = result();
40.24
40.25 -Goal "Mutex : {s. m s = Numeral1} LeadsTo {s. p s}";
40.26 +Goal "Mutex : {s. m s = 1} LeadsTo {s. p s}";
40.27 by (rtac ([U_F1 RS LeadsTo_weaken_R, U_lemma2] MRS LeadsTo_Trans) 1);
40.28 by (Blast_tac 1);
40.29 val U_lemma1 = result();
40.30
40.31 -Goal "Mutex : {s. Numeral1 <= m s & m s <= 3} LeadsTo {s. p s}";
40.32 +Goal "Mutex : {s. 1 <= m s & m s <= 3} LeadsTo {s. p s}";
40.33 by (simp_tac (simpset() addsimps [eq_123, Collect_disj_eq, LeadsTo_Un_distrib,
40.34 U_lemma1, U_lemma2, U_F3] ) 1);
40.35 val U_lemma123 = result();
40.36 @@ -99,7 +99,7 @@
40.37 by (constrains_tac 1);
40.38 qed "V_F0";
40.39
40.40 -Goal "Mutex : {s. n s=Numeral1} LeadsTo {s. p s = (~ u s) & n s = 2}";
40.41 +Goal "Mutex : {s. n s=1} LeadsTo {s. p s = (~ u s) & n s = 2}";
40.42 by (ensures_tac "V1" 1);
40.43 qed "V_F1";
40.44
40.45 @@ -121,12 +121,12 @@
40.46 by (auto_tac (claset() addSEs [less_SucE], simpset()));
40.47 val V_lemma2 = result();
40.48
40.49 -Goal "Mutex : {s. n s = Numeral1} LeadsTo {s. ~ p s}";
40.50 +Goal "Mutex : {s. n s = 1} LeadsTo {s. ~ p s}";
40.51 by (rtac ([V_F1 RS LeadsTo_weaken_R, V_lemma2] MRS LeadsTo_Trans) 1);
40.52 by (Blast_tac 1);
40.53 val V_lemma1 = result();
40.54
40.55 -Goal "Mutex : {s. Numeral1 <= n s & n s <= 3} LeadsTo {s. ~ p s}";
40.56 +Goal "Mutex : {s. 1 <= n s & n s <= 3} LeadsTo {s. ~ p s}";
40.57 by (simp_tac (simpset() addsimps [eq_123, Collect_disj_eq, LeadsTo_Un_distrib,
40.58 V_lemma1, V_lemma2, V_F3] ) 1);
40.59 val V_lemma123 = result();
40.60 @@ -142,7 +142,7 @@
40.61 (** Absence of starvation **)
40.62
40.63 (*Misra's F6*)
40.64 -Goal "Mutex : {s. m s = Numeral1} LeadsTo {s. m s = 3}";
40.65 +Goal "Mutex : {s. m s = 1} LeadsTo {s. m s = 3}";
40.66 by (rtac (LeadsTo_cancel2 RS LeadsTo_Un_duplicate) 1);
40.67 by (rtac U_F2 2);
40.68 by (simp_tac (simpset() addsimps [Collect_conj_eq] ) 1);
40.69 @@ -154,7 +154,7 @@
40.70 qed "m1_Leadsto_3";
40.71
40.72 (*The same for V*)
40.73 -Goal "Mutex : {s. n s = Numeral1} LeadsTo {s. n s = 3}";
40.74 +Goal "Mutex : {s. n s = 1} LeadsTo {s. n s = 3}";
40.75 by (rtac (LeadsTo_cancel2 RS LeadsTo_Un_duplicate) 1);
40.76 by (rtac V_F2 2);
40.77 by (simp_tac (simpset() addsimps [Collect_conj_eq] ) 1);
41.1 --- a/src/HOL/UNITY/Simple/Mutex.thy Mon Oct 22 11:01:30 2001 +0200
41.2 +++ b/src/HOL/UNITY/Simple/Mutex.thy Mon Oct 22 11:54:22 2001 +0200
41.3 @@ -22,10 +22,10 @@
41.4 (** The program for process U **)
41.5
41.6 U0 :: command
41.7 - "U0 == {(s,s'). s' = s (|u:=True, m:=Numeral1|) & m s = Numeral0}"
41.8 + "U0 == {(s,s'). s' = s (|u:=True, m:=1|) & m s = 0}"
41.9
41.10 U1 :: command
41.11 - "U1 == {(s,s'). s' = s (|p:= v s, m:=2|) & m s = Numeral1}"
41.12 + "U1 == {(s,s'). s' = s (|p:= v s, m:=2|) & m s = 1}"
41.13
41.14 U2 :: command
41.15 "U2 == {(s,s'). s' = s (|m:=3|) & ~ p s & m s = 2}"
41.16 @@ -34,15 +34,15 @@
41.17 "U3 == {(s,s'). s' = s (|u:=False, m:=4|) & m s = 3}"
41.18
41.19 U4 :: command
41.20 - "U4 == {(s,s'). s' = s (|p:=True, m:=Numeral0|) & m s = 4}"
41.21 + "U4 == {(s,s'). s' = s (|p:=True, m:=0|) & m s = 4}"
41.22
41.23 (** The program for process V **)
41.24
41.25 V0 :: command
41.26 - "V0 == {(s,s'). s' = s (|v:=True, n:=Numeral1|) & n s = Numeral0}"
41.27 + "V0 == {(s,s'). s' = s (|v:=True, n:=1|) & n s = 0}"
41.28
41.29 V1 :: command
41.30 - "V1 == {(s,s'). s' = s (|p:= ~ u s, n:=2|) & n s = Numeral1}"
41.31 + "V1 == {(s,s'). s' = s (|p:= ~ u s, n:=2|) & n s = 1}"
41.32
41.33 V2 :: command
41.34 "V2 == {(s,s'). s' = s (|n:=3|) & p s & n s = 2}"
41.35 @@ -51,10 +51,10 @@
41.36 "V3 == {(s,s'). s' = s (|v:=False, n:=4|) & n s = 3}"
41.37
41.38 V4 :: command
41.39 - "V4 == {(s,s'). s' = s (|p:=False, n:=Numeral0|) & n s = 4}"
41.40 + "V4 == {(s,s'). s' = s (|p:=False, n:=0|) & n s = 4}"
41.41
41.42 Mutex :: state program
41.43 - "Mutex == mk_program ({s. ~ u s & ~ v s & m s = Numeral0 & n s = Numeral0},
41.44 + "Mutex == mk_program ({s. ~ u s & ~ v s & m s = 0 & n s = 0},
41.45 {U0, U1, U2, U3, U4, V0, V1, V2, V3, V4},
41.46 UNIV)"
41.47
41.48 @@ -62,15 +62,15 @@
41.49 (** The correct invariants **)
41.50
41.51 IU :: state set
41.52 - "IU == {s. (u s = (Numeral1 <= m s & m s <= 3)) & (m s = 3 --> ~ p s)}"
41.53 + "IU == {s. (u s = (1 <= m s & m s <= 3)) & (m s = 3 --> ~ p s)}"
41.54
41.55 IV :: state set
41.56 - "IV == {s. (v s = (Numeral1 <= n s & n s <= 3)) & (n s = 3 --> p s)}"
41.57 + "IV == {s. (v s = (1 <= n s & n s <= 3)) & (n s = 3 --> p s)}"
41.58
41.59 (** The faulty invariant (for U alone) **)
41.60
41.61 bad_IU :: state set
41.62 - "bad_IU == {s. (u s = (Numeral1 <= m s & m s <= 3)) &
41.63 + "bad_IU == {s. (u s = (1 <= m s & m s <= 3)) &
41.64 (3 <= m s & m s <= 4 --> ~ p s)}"
41.65
41.66 end
42.1 --- a/src/HOL/UNITY/SubstAx.ML Mon Oct 22 11:01:30 2001 +0200
42.2 +++ b/src/HOL/UNITY/SubstAx.ML Mon Oct 22 11:54:22 2001 +0200
42.3 @@ -341,9 +341,9 @@
42.4 by (auto_tac (claset() addIs prems, simpset()));
42.5 qed "LessThan_induct";
42.6
42.7 -(*Integer version. Could generalize from Numeral0 to any lower bound*)
42.8 +(*Integer version. Could generalize from 0 to any lower bound*)
42.9 val [reach, prem] =
42.10 -Goal "[| F : Always {s. (Numeral0::int) <= f s}; \
42.11 +Goal "[| F : Always {s. (0::int) <= f s}; \
42.12 \ !! z. F : (A Int {s. f s = z}) LeadsTo \
42.13 \ ((A Int {s. f s < z}) Un B) |] \
42.14 \ ==> F : A LeadsTo B";
43.1 --- a/src/HOL/UNITY/Union.ML Mon Oct 22 11:01:30 2001 +0200
43.2 +++ b/src/HOL/UNITY/Union.ML Mon Oct 22 11:54:22 2001 +0200
43.3 @@ -352,7 +352,7 @@
43.4
43.5 bind_thm ("ok_sym", ok_commute RS iffD1);
43.6
43.7 -Goal "OK {(Numeral0::int,F),(Numeral1,G),(2,H)} snd = (F ok G & (F Join G) ok H)";
43.8 +Goal "OK {(0::int,F),(1,G),(2,H)} snd = (F ok G & (F Join G) ok H)";
43.9 by (asm_full_simp_tac
43.10 (simpset() addsimps [Ball_def, conj_disj_distribR, ok_def, Join_def,
43.11 OK_def, insert_absorb, all_conj_distrib, eq_commute]) 1);
44.1 --- a/src/HOL/ex/BinEx.thy Mon Oct 22 11:01:30 2001 +0200
44.2 +++ b/src/HOL/ex/BinEx.thy Mon Oct 22 11:54:22 2001 +0200
44.3 @@ -60,7 +60,7 @@
44.4 lemma "(13557456::int) < 18678654"
44.5 by simp
44.6
44.7 -lemma "(999999::int) \<le> (1000001 + Numeral1) - 2"
44.8 +lemma "(999999::int) \<le> (1000001 + 1) - 2"
44.9 by simp
44.10
44.11 lemma "(1234567::int) \<le> 1234567"
44.12 @@ -72,7 +72,7 @@
44.13 lemma "(10::int) div 3 = 3"
44.14 by simp
44.15
44.16 -lemma "(10::int) mod 3 = Numeral1"
44.17 +lemma "(10::int) mod 3 = 1"
44.18 by simp
44.19
44.20 text {* A negative divisor *}
44.21 @@ -104,7 +104,7 @@
44.22
44.23 text {* A few bigger examples *}
44.24
44.25 -lemma "(8452::int) mod 3 = Numeral1"
44.26 +lemma "(8452::int) mod 3 = 1"
44.27 by simp
44.28
44.29 lemma "(59485::int) div 434 = 137"
44.30 @@ -119,7 +119,7 @@
44.31 lemma "10000000 div 2 = (5000000::int)"
44.32 by simp
44.33
44.34 -lemma "10000001 mod 2 = (Numeral1::int)"
44.35 +lemma "10000001 mod 2 = (1::int)"
44.36 by simp
44.37
44.38 lemma "10000055 div 32 = (312501::int)"
44.39 @@ -161,10 +161,10 @@
44.40 lemma "(32::nat) - 14 = 18"
44.41 by simp
44.42
44.43 -lemma "(14::nat) - 15 = Numeral0"
44.44 +lemma "(14::nat) - 15 = 0"
44.45 by simp
44.46
44.47 -lemma "(14::nat) - 1576644 = Numeral0"
44.48 +lemma "(14::nat) - 1576644 = 0"
44.49 by simp
44.50
44.51 lemma "(48273776::nat) - 3873737 = 44400039"
44.52 @@ -185,49 +185,49 @@
44.53 lemma "(10::nat) div 3 = 3"
44.54 by simp
44.55
44.56 -lemma "(10::nat) mod 3 = Numeral1"
44.57 +lemma "(10::nat) mod 3 = 1"
44.58 by simp
44.59
44.60 lemma "(10000::nat) div 9 = 1111"
44.61 by simp
44.62
44.63 -lemma "(10000::nat) mod 9 = Numeral1"
44.64 +lemma "(10000::nat) mod 9 = 1"
44.65 by simp
44.66
44.67 lemma "(10000::nat) div 16 = 625"
44.68 by simp
44.69
44.70 -lemma "(10000::nat) mod 16 = Numeral0"
44.71 +lemma "(10000::nat) mod 16 = 0"
44.72 by simp
44.73
44.74
44.75 text {* \medskip Testing the cancellation of complementary terms *}
44.76
44.77 -lemma "y + (x + -x) = (Numeral0::int) + y"
44.78 +lemma "y + (x + -x) = (0::int) + y"
44.79 by simp
44.80
44.81 -lemma "y + (-x + (- y + x)) = (Numeral0::int)"
44.82 +lemma "y + (-x + (- y + x)) = (0::int)"
44.83 by simp
44.84
44.85 -lemma "-x + (y + (- y + x)) = (Numeral0::int)"
44.86 +lemma "-x + (y + (- y + x)) = (0::int)"
44.87 by simp
44.88
44.89 -lemma "x + (x + (- x + (- x + (- y + - z)))) = (Numeral0::int) - y - z"
44.90 +lemma "x + (x + (- x + (- x + (- y + - z)))) = (0::int) - y - z"
44.91 by simp
44.92
44.93 -lemma "x + x - x - x - y - z = (Numeral0::int) - y - z"
44.94 +lemma "x + x - x - x - y - z = (0::int) - y - z"
44.95 by simp
44.96
44.97 -lemma "x + y + z - (x + z) = y - (Numeral0::int)"
44.98 +lemma "x + y + z - (x + z) = y - (0::int)"
44.99 by simp
44.100
44.101 -lemma "x + (y + (y + (y + (-x + -x)))) = (Numeral0::int) + y - x + y + y"
44.102 +lemma "x + (y + (y + (y + (-x + -x)))) = (0::int) + y - x + y + y"
44.103 by simp
44.104
44.105 -lemma "x + (y + (y + (y + (-y + -x)))) = y + (Numeral0::int) + y"
44.106 +lemma "x + (y + (y + (y + (-y + -x)))) = y + (0::int) + y"
44.107 by simp
44.108
44.109 -lemma "x + y - x + z - x - y - z + x < (Numeral1::int)"
44.110 +lemma "x + y - x + z - x - y - z + x < (1::int)"
44.111 by simp
44.112
44.113
44.114 @@ -302,7 +302,7 @@
44.115 apply simp_all
44.116 done
44.117
44.118 -lemma normal_Pls_eq_0: "w \<in> normal ==> (w = Pls) = (number_of w = (Numeral0::int))"
44.119 +lemma normal_Pls_eq_0: "w \<in> normal ==> (w = Pls) = (number_of w = (0::int))"
44.120 apply (erule normal.induct)
44.121 apply auto
44.122 done
44.123 @@ -313,7 +313,7 @@
44.124 apply (rule normal.intros)
44.125 apply assumption
44.126 apply (simp add: normal_Pls_eq_0)
44.127 - apply (simp only: number_of_minus iszero_def zminus_equation [of _ "int 0"])
44.128 + apply (simp only: number_of_minus iszero_def zminus_equation [of _ "0"])
44.129 apply (rule not_sym)
44.130 apply simp
44.131 done
45.1 --- a/src/HOL/ex/IntRing.thy Mon Oct 22 11:01:30 2001 +0200
45.2 +++ b/src/HOL/ex/IntRing.thy Mon Oct 22 11:54:22 2001 +0200
45.3 @@ -10,7 +10,7 @@
45.4 IntRing = Ring + Lagrange +
45.5
45.6 instance int :: add_semigroup (zadd_assoc)
45.7 -instance int :: add_monoid (Zero_int_def,zadd_int0,zadd_int0_right)
45.8 +instance int :: add_monoid (zadd_0,zadd_0_right)
45.9 instance int :: add_group {|Auto_tac|}
45.10 instance int :: add_agroup (zadd_commute)
45.11 instance int :: ring (zmult_assoc,zadd_zmult_distrib2,zadd_zmult_distrib)
46.1 --- a/src/HOL/ex/svc_test.ML Mon Oct 22 11:01:30 2001 +0200
46.2 +++ b/src/HOL/ex/svc_test.ML Mon Oct 22 11:54:22 2001 +0200
46.3 @@ -233,12 +233,12 @@
46.4
46.5 Goal "x ~= 14 & x ~= 13 & x ~= 12 & x ~= 11 & x ~= 10 & x ~= 9 & \
46.6 \ x ~= 8 & x ~= 7 & x ~= 6 & x ~= 5 & x ~= 4 & x ~= 3 & \
46.7 -\ x ~= 2 & x ~= Numeral1 & Numeral0 < x & x < 16 --> 15 = (x::int)";
46.8 +\ x ~= 2 & x ~= 1 & 0 < x & x < 16 --> 15 = (x::int)";
46.9 by (svc_tac 1);
46.10 qed "";
46.11
46.12 (*merely to test polarity handling in the presence of biconditionals*)
46.13 -Goal "(x < (y::int)) = (x+Numeral1 <= y)";
46.14 +Goal "(x < (y::int)) = (x+1 <= y)";
46.15 by (svc_tac 1);
46.16 qed "";
46.17
46.18 @@ -249,6 +249,6 @@
46.19 by (svc_tac 1);
46.20 qed "";
46.21
46.22 -Goal "(n::nat) < 2 ==> (n = Numeral0) | (n = Numeral1)";
46.23 +Goal "(n::nat) < 2 ==> (n = 0) | (n = 1)";
46.24 by (svc_tac 1);
46.25 qed "";