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