src/HOL/Integ/int_arith1.ML
author paulson
Mon Oct 22 11:54:22 2001 +0200 (2001-10-22)
changeset 11868 56db9f3a6b3e
parent 11713 883d559b0b8c
child 12018 ec054019c910
permissions -rw-r--r--
Numerals now work for the integers: the binary numerals for 0 and 1 rewrite
to their abstract counterparts, while other binary numerals work correctly.
     1 (*  Title:      HOL/Integ/int_arith1.ML
     2     ID:         $Id$
     3     Authors:    Larry Paulson and Tobias Nipkow
     4 
     5 Simprocs and decision procedure for linear arithmetic.
     6 *)
     7 
     8 Addsimps [int_numeral_0_eq_0, int_numeral_1_eq_1];
     9 
    10 (*** Simprocs for numeric literals ***)
    11 
    12 (** Combining of literal coefficients in sums of products **)
    13 
    14 Goal "(x < y) = (x-y < (0::int))";
    15 by (simp_tac (simpset() addsimps zcompare_rls) 1);
    16 qed "zless_iff_zdiff_zless_0";
    17 
    18 Goal "(x = y) = (x-y = (0::int))";
    19 by (simp_tac (simpset() addsimps zcompare_rls) 1);
    20 qed "eq_iff_zdiff_eq_0";
    21 
    22 Goal "(x <= y) = (x-y <= (0::int))";
    23 by (simp_tac (simpset() addsimps zcompare_rls) 1);
    24 qed "zle_iff_zdiff_zle_0";
    25 
    26 
    27 (** For combine_numerals **)
    28 
    29 Goal "i*u + (j*u + k) = (i+j)*u + (k::int)";
    30 by (asm_simp_tac (simpset() addsimps [zadd_zmult_distrib]) 1);
    31 qed "left_zadd_zmult_distrib";
    32 
    33 
    34 (** For cancel_numerals **)
    35 
    36 val rel_iff_rel_0_rls = map (inst "y" "?u+?v")
    37                           [zless_iff_zdiff_zless_0, eq_iff_zdiff_eq_0, 
    38 			   zle_iff_zdiff_zle_0] @
    39 		        map (inst "y" "n")
    40                           [zless_iff_zdiff_zless_0, eq_iff_zdiff_eq_0, 
    41 			   zle_iff_zdiff_zle_0];
    42 
    43 Goal "!!i::int. (i*u + m = j*u + n) = ((i-j)*u + m = n)";
    44 by (asm_simp_tac (simpset() addsimps [zdiff_def, zadd_zmult_distrib]@
    45 		                     zadd_ac@rel_iff_rel_0_rls) 1);
    46 qed "eq_add_iff1";
    47 
    48 Goal "!!i::int. (i*u + m = j*u + n) = (m = (j-i)*u + n)";
    49 by (asm_simp_tac (simpset() addsimps [zdiff_def, zadd_zmult_distrib]@
    50                                      zadd_ac@rel_iff_rel_0_rls) 1);
    51 qed "eq_add_iff2";
    52 
    53 Goal "!!i::int. (i*u + m < j*u + n) = ((i-j)*u + m < n)";
    54 by (asm_simp_tac (simpset() addsimps [zdiff_def, zadd_zmult_distrib]@
    55                                      zadd_ac@rel_iff_rel_0_rls) 1);
    56 qed "less_add_iff1";
    57 
    58 Goal "!!i::int. (i*u + m < j*u + n) = (m < (j-i)*u + n)";
    59 by (asm_simp_tac (simpset() addsimps [zdiff_def, zadd_zmult_distrib]@
    60                                      zadd_ac@rel_iff_rel_0_rls) 1);
    61 qed "less_add_iff2";
    62 
    63 Goal "!!i::int. (i*u + m <= j*u + n) = ((i-j)*u + m <= n)";
    64 by (asm_simp_tac (simpset() addsimps [zdiff_def, zadd_zmult_distrib]@
    65                                      zadd_ac@rel_iff_rel_0_rls) 1);
    66 qed "le_add_iff1";
    67 
    68 Goal "!!i::int. (i*u + m <= j*u + n) = (m <= (j-i)*u + n)";
    69 by (asm_simp_tac (simpset() addsimps [zdiff_def, zadd_zmult_distrib]
    70                                      @zadd_ac@rel_iff_rel_0_rls) 1);
    71 qed "le_add_iff2";
    72 
    73 (*To tidy up the result of a simproc.  Only the RHS will be simplified.*)
    74 Goal "u = u' ==> (t==u) == (t==u')";
    75 by Auto_tac;
    76 qed "eq_cong2";
    77 
    78 
    79 structure Int_Numeral_Simprocs =
    80 struct
    81 
    82 (*Maps 0 to Numeral0 and 1 to Numeral1 so that arithmetic in simprocs
    83   isn't complicated by the abstract 0 and 1.*)
    84 val numeral_syms = [int_numeral_0_eq_0 RS sym, int_numeral_1_eq_1 RS sym];
    85 val numeral_sym_ss = HOL_ss addsimps numeral_syms;
    86 
    87 fun rename_numerals th = 
    88     simplify numeral_sym_ss (Thm.transfer (the_context ()) th);
    89 
    90 (*Utilities*)
    91 
    92 fun mk_numeral n = HOLogic.number_of_const HOLogic.intT $ HOLogic.mk_bin n;
    93 
    94 (*Decodes a binary INTEGER*)
    95 fun dest_numeral (Const("0", _)) = 0
    96   | dest_numeral (Const("1", _)) = 1
    97   | dest_numeral (Const("Numeral.number_of", _) $ w) = 
    98      (HOLogic.dest_binum w
    99       handle TERM _ => raise TERM("Int_Numeral_Simprocs.dest_numeral:1", [w]))
   100   | dest_numeral t = raise TERM("Int_Numeral_Simprocs.dest_numeral:2", [t]);
   101 
   102 fun find_first_numeral past (t::terms) =
   103 	((dest_numeral t, rev past @ terms)
   104 	 handle TERM _ => find_first_numeral (t::past) terms)
   105   | find_first_numeral past [] = raise TERM("find_first_numeral", []);
   106 
   107 val zero = mk_numeral 0;
   108 val mk_plus = HOLogic.mk_binop "op +";
   109 
   110 val uminus_const = Const ("uminus", HOLogic.intT --> HOLogic.intT);
   111 
   112 (*Thus mk_sum[t] yields t+0; longer sums don't have a trailing zero*)
   113 fun mk_sum []        = zero
   114   | mk_sum [t,u]     = mk_plus (t, u)
   115   | mk_sum (t :: ts) = mk_plus (t, mk_sum ts);
   116 
   117 (*this version ALWAYS includes a trailing zero*)
   118 fun long_mk_sum []        = zero
   119   | long_mk_sum (t :: ts) = mk_plus (t, mk_sum ts);
   120 
   121 val dest_plus = HOLogic.dest_bin "op +" HOLogic.intT;
   122 
   123 (*decompose additions AND subtractions as a sum*)
   124 fun dest_summing (pos, Const ("op +", _) $ t $ u, ts) =
   125         dest_summing (pos, t, dest_summing (pos, u, ts))
   126   | dest_summing (pos, Const ("op -", _) $ t $ u, ts) =
   127         dest_summing (pos, t, dest_summing (not pos, u, ts))
   128   | dest_summing (pos, t, ts) =
   129 	if pos then t::ts else uminus_const$t :: ts;
   130 
   131 fun dest_sum t = dest_summing (true, t, []);
   132 
   133 val mk_diff = HOLogic.mk_binop "op -";
   134 val dest_diff = HOLogic.dest_bin "op -" HOLogic.intT;
   135 
   136 val one = mk_numeral 1;
   137 val mk_times = HOLogic.mk_binop "op *";
   138 
   139 fun mk_prod [] = one
   140   | mk_prod [t] = t
   141   | mk_prod (t :: ts) = if t = one then mk_prod ts
   142                         else mk_times (t, mk_prod ts);
   143 
   144 val dest_times = HOLogic.dest_bin "op *" HOLogic.intT;
   145 
   146 fun dest_prod t =
   147       let val (t,u) = dest_times t 
   148       in  dest_prod t @ dest_prod u  end
   149       handle TERM _ => [t];
   150 
   151 (*DON'T do the obvious simplifications; that would create special cases*) 
   152 fun mk_coeff (k, ts) = mk_times (mk_numeral k, ts);
   153 
   154 (*Express t as a product of (possibly) a numeral with other sorted terms*)
   155 fun dest_coeff sign (Const ("uminus", _) $ t) = dest_coeff (~sign) t
   156   | dest_coeff sign t =
   157     let val ts = sort Term.term_ord (dest_prod t)
   158 	val (n, ts') = find_first_numeral [] ts
   159                           handle TERM _ => (1, ts)
   160     in (sign*n, mk_prod ts') end;
   161 
   162 (*Find first coefficient-term THAT MATCHES u*)
   163 fun find_first_coeff past u [] = raise TERM("find_first_coeff", []) 
   164   | find_first_coeff past u (t::terms) =
   165 	let val (n,u') = dest_coeff 1 t
   166 	in  if u aconv u' then (n, rev past @ terms)
   167 			  else find_first_coeff (t::past) u terms
   168 	end
   169 	handle TERM _ => find_first_coeff (t::past) u terms;
   170 
   171 
   172 (*Simplify Numeral0+n, n+Numeral0, Numeral1*n, n*Numeral1*)
   173 val add_0s =  map rename_numerals [zadd_0, zadd_0_right];
   174 val mult_1s = map rename_numerals [zmult_1, zmult_1_right] @
   175               [zmult_minus1, zmult_minus1_right];
   176 
   177 (*To perform binary arithmetic.  The "left" rewriting handles patterns
   178   created by the simprocs, such as 3 * (5 * x). *)
   179 val bin_simps = [int_numeral_0_eq_0 RS sym, int_numeral_1_eq_1 RS sym,
   180                  add_number_of_left, mult_number_of_left] @ 
   181                 bin_arith_simps @ bin_rel_simps;
   182 
   183 (*To evaluate binary negations of coefficients*)
   184 val zminus_simps = NCons_simps @
   185                    [zminus_1_eq_m1, number_of_minus RS sym, 
   186 		    bin_minus_1, bin_minus_0, bin_minus_Pls, bin_minus_Min,
   187 		    bin_pred_1, bin_pred_0, bin_pred_Pls, bin_pred_Min];
   188 
   189 (*To let us treat subtraction as addition*)
   190 val diff_simps = [zdiff_def, zminus_zadd_distrib, zminus_zminus];
   191 
   192 (*push the unary minus down: - x * y = x * - y *)
   193 val int_minus_mult_eq_1_to_2 = 
   194     [zmult_zminus, zmult_zminus_right RS sym] MRS trans |> standard;
   195 
   196 (*to extract again any uncancelled minuses*)
   197 val int_minus_from_mult_simps = 
   198     [zminus_zminus, zmult_zminus, zmult_zminus_right];
   199 
   200 (*combine unary minus with numeric literals, however nested within a product*)
   201 val int_mult_minus_simps =
   202     [zmult_assoc, zmult_zminus RS sym, int_minus_mult_eq_1_to_2];
   203 
   204 (*Apply the given rewrite (if present) just once*)
   205 fun trans_tac None      = all_tac
   206   | trans_tac (Some th) = ALLGOALS (rtac (th RS trans));
   207 
   208 fun simplify_meta_eq rules =
   209     mk_meta_eq o
   210     simplify (HOL_basic_ss addeqcongs[eq_cong2] addsimps rules)
   211 
   212 structure CancelNumeralsCommon =
   213   struct
   214   val mk_sum    	= mk_sum
   215   val dest_sum		= dest_sum
   216   val mk_coeff		= mk_coeff
   217   val dest_coeff	= dest_coeff 1
   218   val find_first_coeff	= find_first_coeff []
   219   val trans_tac         = trans_tac
   220   val norm_tac = 
   221      ALLGOALS (simp_tac (HOL_ss addsimps numeral_syms@add_0s@mult_1s@
   222                                          diff_simps@zminus_simps@zadd_ac))
   223      THEN ALLGOALS (simp_tac (HOL_ss addsimps bin_simps@int_mult_minus_simps))
   224      THEN ALLGOALS (simp_tac (HOL_ss addsimps int_minus_from_mult_simps@
   225                                               zadd_ac@zmult_ac))
   226   val numeral_simp_tac	= ALLGOALS (simp_tac (HOL_ss addsimps add_0s@bin_simps))
   227   val simplify_meta_eq  = simplify_meta_eq (add_0s@mult_1s)
   228   end;
   229 
   230 
   231 structure EqCancelNumerals = CancelNumeralsFun
   232  (open CancelNumeralsCommon
   233   val prove_conv = Bin_Simprocs.prove_conv "inteq_cancel_numerals"
   234   val mk_bal   = HOLogic.mk_eq
   235   val dest_bal = HOLogic.dest_bin "op =" HOLogic.intT
   236   val bal_add1 = eq_add_iff1 RS trans
   237   val bal_add2 = eq_add_iff2 RS trans
   238 );
   239 
   240 structure LessCancelNumerals = CancelNumeralsFun
   241  (open CancelNumeralsCommon
   242   val prove_conv = Bin_Simprocs.prove_conv "intless_cancel_numerals"
   243   val mk_bal   = HOLogic.mk_binrel "op <"
   244   val dest_bal = HOLogic.dest_bin "op <" HOLogic.intT
   245   val bal_add1 = less_add_iff1 RS trans
   246   val bal_add2 = less_add_iff2 RS trans
   247 );
   248 
   249 structure LeCancelNumerals = CancelNumeralsFun
   250  (open CancelNumeralsCommon
   251   val prove_conv = Bin_Simprocs.prove_conv "intle_cancel_numerals"
   252   val mk_bal   = HOLogic.mk_binrel "op <="
   253   val dest_bal = HOLogic.dest_bin "op <=" HOLogic.intT
   254   val bal_add1 = le_add_iff1 RS trans
   255   val bal_add2 = le_add_iff2 RS trans
   256 );
   257 
   258 val cancel_numerals = 
   259   map Bin_Simprocs.prep_simproc
   260    [("inteq_cancel_numerals",
   261      Bin_Simprocs.prep_pats
   262                ["(l::int) + m = n", "(l::int) = m + n", 
   263 		"(l::int) - m = n", "(l::int) = m - n", 
   264 		"(l::int) * m = n", "(l::int) = m * n"], 
   265      EqCancelNumerals.proc),
   266     ("intless_cancel_numerals", 
   267      Bin_Simprocs.prep_pats
   268                ["(l::int) + m < n", "(l::int) < m + n", 
   269 		"(l::int) - m < n", "(l::int) < m - n", 
   270 		"(l::int) * m < n", "(l::int) < m * n"], 
   271      LessCancelNumerals.proc),
   272     ("intle_cancel_numerals", 
   273      Bin_Simprocs.prep_pats
   274                ["(l::int) + m <= n", "(l::int) <= m + n", 
   275 		"(l::int) - m <= n", "(l::int) <= m - n", 
   276 		"(l::int) * m <= n", "(l::int) <= m * n"], 
   277      LeCancelNumerals.proc)];
   278 
   279 
   280 structure CombineNumeralsData =
   281   struct
   282   val add		= op + : int*int -> int 
   283   val mk_sum    	= long_mk_sum    (*to work for e.g. 2*x + 3*x *)
   284   val dest_sum		= dest_sum
   285   val mk_coeff		= mk_coeff
   286   val dest_coeff	= dest_coeff 1
   287   val left_distrib	= left_zadd_zmult_distrib RS trans
   288   val prove_conv        = Bin_Simprocs.prove_conv_nohyps "int_combine_numerals"
   289   val trans_tac          = trans_tac
   290   val norm_tac = 
   291      ALLGOALS (simp_tac (HOL_ss addsimps numeral_syms@add_0s@mult_1s@
   292                                          diff_simps@zminus_simps@zadd_ac))
   293      THEN ALLGOALS (simp_tac (HOL_ss addsimps bin_simps@int_mult_minus_simps))
   294      THEN ALLGOALS (simp_tac (HOL_ss addsimps int_minus_from_mult_simps@
   295                                               zadd_ac@zmult_ac))
   296   val numeral_simp_tac	= ALLGOALS 
   297                     (simp_tac (HOL_ss addsimps add_0s@bin_simps))
   298   val simplify_meta_eq  = simplify_meta_eq (add_0s@mult_1s)
   299   end;
   300 
   301 structure CombineNumerals = CombineNumeralsFun(CombineNumeralsData);
   302   
   303 val combine_numerals = Bin_Simprocs.prep_simproc
   304                  ("int_combine_numerals",
   305 		  Bin_Simprocs.prep_pats ["(i::int) + j", "(i::int) - j"],
   306 		  CombineNumerals.proc);
   307 
   308 end;
   309 
   310 Addsimprocs Int_Numeral_Simprocs.cancel_numerals;
   311 Addsimprocs [Int_Numeral_Simprocs.combine_numerals];
   312 
   313 (*The Abel_Cancel simprocs are now obsolete*)
   314 Delsimprocs [Int_Cancel.sum_conv, Int_Cancel.rel_conv];
   315 
   316 (*examples:
   317 print_depth 22;
   318 set timing;
   319 set trace_simp;
   320 fun test s = (Goal s, by (Simp_tac 1)); 
   321 
   322 test "l + 2 + 2 + 2 + (l + 2) + (oo + 2) = (uu::int)";
   323 
   324 test "2*u = (u::int)";
   325 test "(i + j + 12 + (k::int)) - 15 = y";
   326 test "(i + j + 12 + (k::int)) - 5 = y";
   327 
   328 test "y - b < (b::int)";
   329 test "y - (3*b + c) < (b::int) - 2*c";
   330 
   331 test "(2*x - (u*v) + y) - v*3*u = (w::int)";
   332 test "(2*x*u*v + (u*v)*4 + y) - v*u*4 = (w::int)";
   333 test "(2*x*u*v + (u*v)*4 + y) - v*u = (w::int)";
   334 test "u*v - (x*u*v + (u*v)*4 + y) = (w::int)";
   335 
   336 test "(i + j + 12 + (k::int)) = u + 15 + y";
   337 test "(i + j*2 + 12 + (k::int)) = j + 5 + y";
   338 
   339 test "2*y + 3*z + 6*w + 2*y + 3*z + 2*u = 2*y' + 3*z' + 6*w' + 2*y' + 3*z' + u + (vv::int)";
   340 
   341 test "a + -(b+c) + b = (d::int)";
   342 test "a + -(b+c) - b = (d::int)";
   343 
   344 (*negative numerals*)
   345 test "(i + j + -2 + (k::int)) - (u + 5 + y) = zz";
   346 test "(i + j + -3 + (k::int)) < u + 5 + y";
   347 test "(i + j + 3 + (k::int)) < u + -6 + y";
   348 test "(i + j + -12 + (k::int)) - 15 = y";
   349 test "(i + j + 12 + (k::int)) - -15 = y";
   350 test "(i + j + -12 + (k::int)) - -15 = y";
   351 *)
   352 
   353 
   354 (** Constant folding for integer plus and times **)
   355 
   356 (*We do not need
   357     structure Nat_Plus_Assoc = Assoc_Fold (Nat_Plus_Assoc_Data);
   358     structure Int_Plus_Assoc = Assoc_Fold (Int_Plus_Assoc_Data);
   359   because combine_numerals does the same thing*)
   360 
   361 structure Int_Times_Assoc_Data : ASSOC_FOLD_DATA =
   362 struct
   363   val ss		= HOL_ss
   364   val eq_reflection	= eq_reflection
   365   val sg_ref = Sign.self_ref (Theory.sign_of (the_context ()))
   366   val T	     = HOLogic.intT
   367   val plus   = Const ("op *", [HOLogic.intT,HOLogic.intT] ---> HOLogic.intT);
   368   val add_ac = zmult_ac
   369 end;
   370 
   371 structure Int_Times_Assoc = Assoc_Fold (Int_Times_Assoc_Data);
   372 
   373 Addsimprocs [Int_Times_Assoc.conv];
   374 
   375 
   376 (** The same for the naturals **)
   377 
   378 structure Nat_Times_Assoc_Data : ASSOC_FOLD_DATA =
   379 struct
   380   val ss		= HOL_ss
   381   val eq_reflection	= eq_reflection
   382   val sg_ref = Sign.self_ref (Theory.sign_of (the_context ()))
   383   val T	     = HOLogic.natT
   384   val plus   = Const ("op *", [HOLogic.natT,HOLogic.natT] ---> HOLogic.natT);
   385   val add_ac = mult_ac
   386 end;
   387 
   388 structure Nat_Times_Assoc = Assoc_Fold (Nat_Times_Assoc_Data);
   389 
   390 Addsimprocs [Nat_Times_Assoc.conv];
   391 
   392 
   393 (*** decision procedure for linear arithmetic ***)
   394 
   395 (*---------------------------------------------------------------------------*)
   396 (* Linear arithmetic                                                         *)
   397 (*---------------------------------------------------------------------------*)
   398 
   399 (*
   400 Instantiation of the generic linear arithmetic package for int.
   401 *)
   402 
   403 (* Update parameters of arithmetic prover *)
   404 local
   405 
   406 (* reduce contradictory <= to False *)
   407 val add_rules = 
   408     simp_thms @ bin_arith_simps @ bin_rel_simps @ 
   409     [int_numeral_0_eq_0, int_numeral_1_eq_1,
   410      zadd_0, zadd_0_right, zdiff_def,
   411      zadd_zminus_inverse, zadd_zminus_inverse2, 
   412      zmult_0, zmult_0_right, 
   413      zmult_1, zmult_1_right, 
   414      zmult_minus1, zmult_minus1_right,
   415      zminus_zadd_distrib, zminus_zminus, zmult_assoc,
   416      int_0, int_1, zadd_int RS sym, int_Suc];
   417 
   418 val simprocs = [Int_Times_Assoc.conv, Int_Numeral_Simprocs.combine_numerals]@
   419                Int_Numeral_Simprocs.cancel_numerals @ 
   420                Bin_Simprocs.eval_numerals;
   421 
   422 val add_mono_thms_int =
   423   map (fn s => prove_goal (the_context ()) s
   424                  (fn prems => [cut_facts_tac prems 1,
   425                       asm_simp_tac (simpset() addsimps [zadd_zle_mono]) 1]))
   426     ["(i <= j) & (k <= l) ==> i + k <= j + (l::int)",
   427      "(i  = j) & (k <= l) ==> i + k <= j + (l::int)",
   428      "(i <= j) & (k  = l) ==> i + k <= j + (l::int)",
   429      "(i  = j) & (k  = l) ==> i + k  = j + (l::int)"
   430     ];
   431 
   432 in
   433 
   434 val int_arith_setup =
   435  [Fast_Arith.map_data (fn {add_mono_thms, mult_mono_thms, inj_thms, lessD, simpset} =>
   436    {add_mono_thms = add_mono_thms @ add_mono_thms_int,
   437     mult_mono_thms = mult_mono_thms,
   438     inj_thms = [zle_int RS iffD2,int_int_eq RS iffD2] @ inj_thms,
   439     lessD = lessD @ [add1_zle_eq RS iffD2],
   440     simpset = simpset addsimps add_rules
   441                       addsimprocs simprocs
   442                       addcongs [if_weak_cong]}),
   443   arith_inj_const ("IntDef.int", HOLogic.natT --> HOLogic.intT),
   444   arith_discrete ("IntDef.int", true)];
   445 
   446 end;
   447 
   448 let
   449 val int_arith_simproc_pats =
   450   map (fn s => Thm.read_cterm (Theory.sign_of (the_context())) (s, HOLogic.boolT))
   451       ["(m::int) < n","(m::int) <= n", "(m::int) = n"];
   452 
   453 val fast_int_arith_simproc = mk_simproc
   454   "fast_int_arith" int_arith_simproc_pats Fast_Arith.lin_arith_prover;
   455 in
   456 Addsimprocs [fast_int_arith_simproc]
   457 end;
   458 
   459 (* Some test data
   460 Goal "!!a::int. [| a <= b; c <= d; x+y<z |] ==> a+c <= b+d";
   461 by (fast_arith_tac 1);
   462 Goal "!!a::int. [| a < b; c < d |] ==> a-d+ 2 <= b+(-c)";
   463 by (fast_arith_tac 1);
   464 Goal "!!a::int. [| a < b; c < d |] ==> a+c+ 1 < b+d";
   465 by (fast_arith_tac 1);
   466 Goal "!!a::int. [| a <= b; b+b <= c |] ==> a+a <= c";
   467 by (fast_arith_tac 1);
   468 Goal "!!a::int. [| a+b <= i+j; a<=b; i<=j |] \
   469 \     ==> a+a <= j+j";
   470 by (fast_arith_tac 1);
   471 Goal "!!a::int. [| a+b < i+j; a<b; i<j |] \
   472 \     ==> a+a - - -1 < j+j - 3";
   473 by (fast_arith_tac 1);
   474 Goal "!!a::int. a+b+c <= i+j+k & a<=b & b<=c & i<=j & j<=k --> a+a+a <= k+k+k";
   475 by (arith_tac 1);
   476 Goal "!!a::int. [| a+b+c+d <= i+j+k+l; a<=b; b<=c; c<=d; i<=j; j<=k; k<=l |] \
   477 \     ==> a <= l";
   478 by (fast_arith_tac 1);
   479 Goal "!!a::int. [| a+b+c+d <= i+j+k+l; a<=b; b<=c; c<=d; i<=j; j<=k; k<=l |] \
   480 \     ==> a+a+a+a <= l+l+l+l";
   481 by (fast_arith_tac 1);
   482 Goal "!!a::int. [| a+b+c+d <= i+j+k+l; a<=b; b<=c; c<=d; i<=j; j<=k; k<=l |] \
   483 \     ==> a+a+a+a+a <= l+l+l+l+i";
   484 by (fast_arith_tac 1);
   485 Goal "!!a::int. [| a+b+c+d <= i+j+k+l; a<=b; b<=c; c<=d; i<=j; j<=k; k<=l |] \
   486 \     ==> a+a+a+a+a+a <= l+l+l+l+i+l";
   487 by (fast_arith_tac 1);
   488 Goal "!!a::int. [| a+b+c+d <= i+j+k+l; a<=b; b<=c; c<=d; i<=j; j<=k; k<=l |] \
   489 \     ==> 6*a <= 5*l+i";
   490 by (fast_arith_tac 1);
   491 *)