1.1 --- a/src/Provers/Arith/cancel_factor.ML Wed Jul 28 11:42:48 2010 +0200
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,70 +0,0 @@
1.4 -(* Title: Provers/Arith/cancel_factor.ML
1.5 - Author: Markus Wenzel and Stefan Berghofer, TU Muenchen
1.6 -
1.7 -Cancel common constant factor from balanced exression (e.g. =, <=, < of sums).
1.8 -*)
1.9 -
1.10 -signature CANCEL_FACTOR_DATA =
1.11 -sig
1.12 - (*abstract syntax*)
1.13 - val mk_sum: term list -> term
1.14 - val dest_sum: term -> term list
1.15 - val mk_bal: term * term -> term
1.16 - val dest_bal: term -> term * term
1.17 - (*rules*)
1.18 - val prove_conv: tactic -> tactic -> Proof.context -> term * term -> thm
1.19 - val norm_tac: tactic (*AC0 etc.*)
1.20 - val multiply_tac: integer -> tactic
1.21 - (*apply a ~~ b == k * a ~~ k * b (for k > 0)*)
1.22 -end;
1.23 -
1.24 -signature CANCEL_FACTOR =
1.25 -sig
1.26 - val proc: simpset -> term -> thm option
1.27 -end;
1.28 -
1.29 -
1.30 -functor CancelFactorFun(Data: CANCEL_FACTOR_DATA): CANCEL_FACTOR =
1.31 -struct
1.32 -
1.33 -
1.34 -(* count terms *)
1.35 -
1.36 -fun ins_term (t, []) = [(t, 1)]
1.37 - | ins_term (t, (u, k) :: uks) =
1.38 - if t aconv u then (u, k + 1) :: uks
1.39 - else (t, 1) :: (u, k) :: uks;
1.40 -
1.41 -fun count_terms ts = foldr ins_term (sort Term_Ord.term_ord ts, []);
1.42 -
1.43 -
1.44 -(* divide sum *)
1.45 -
1.46 -fun div_sum d =
1.47 - Data.mk_sum o maps (fn (t, k) => replicate (k div d) t);
1.48 -
1.49 -
1.50 -(* the simplification procedure *)
1.51 -
1.52 -fun proc ss t =
1.53 - (case try Data.dest_bal t of
1.54 - NONE => NONE
1.55 - | SOME bal =>
1.56 - (case pairself Data.dest_sum bal of
1.57 - ([_], _) => NONE
1.58 - | (_, [_]) => NONE
1.59 - | ts_us =>
1.60 - let
1.61 - val (tks, uks) = pairself count_terms ts_us;
1.62 - val d = 0
1.63 - |> fold (Integer.gcd o snd) tks
1.64 - |> fold (Integer.gcd o snd) uks;
1.65 - in
1.66 - if d = 0 orelse d = 1 then NONE
1.67 - else SOME
1.68 - (Data.prove_conv (Data.multiply_tac d) Data.norm_tac (Simplifier.the_context ss)
1.69 - (t, Data.mk_bal (div_sum d tks, div_sum d uks)))
1.70 - end));
1.71 -
1.72 -
1.73 -end;
2.1 --- a/src/Provers/Arith/cancel_sums.ML Wed Jul 28 11:42:48 2010 +0200
2.2 +++ b/src/Provers/Arith/cancel_sums.ML Wed Jul 28 14:09:56 2010 +0200
2.3 @@ -35,7 +35,6 @@
2.4
2.5 fun cons1 x (xs, y, z) = (x :: xs, y, z);
2.6 fun cons2 y (x, ys, z) = (x, y :: ys, z);
2.7 -fun cons12 x y (xs, ys, z) = (x :: xs, y :: ys, z);
2.8
2.9 (*symmetric difference of multisets -- assumed to be sorted wrt. Term_Ord.term_ord*)
2.10 fun cancel ts [] vs = (ts, [], vs)
3.1 --- a/src/Provers/Arith/fast_lin_arith.ML Wed Jul 28 11:42:48 2010 +0200
3.2 +++ b/src/Provers/Arith/fast_lin_arith.ML Wed Jul 28 14:09:56 2010 +0200
3.3 @@ -211,7 +211,7 @@
3.4 fun ratexact up (r, exact) =
3.5 if exact then r else
3.6 let
3.7 - val (p, q) = Rat.quotient_of_rat r;
3.8 + val (_, q) = Rat.quotient_of_rat r;
3.9 val nth = Rat.inv (Rat.rat_of_int q);
3.10 in Rat.add r (if up then nth else Rat.neg nth) end;
3.11
3.12 @@ -306,7 +306,7 @@
3.13 (* Add together (in)equations. *)
3.14 (* ------------------------------------------------------------------------- *)
3.15
3.16 -fun add_ineq (i1 as Lineq(k1,ty1,l1,just1)) (i2 as Lineq(k2,ty2,l2,just2)) =
3.17 +fun add_ineq (Lineq (k1,ty1,l1,just1)) (Lineq (k2,ty2,l2,just2)) =
3.18 let val l = map2 Integer.add l1 l2
3.19 in Lineq(k1+k2,find_add_type(ty1,ty2),l,Added(just1,just2)) end;
3.20
3.21 @@ -335,7 +335,7 @@
3.22
3.23 fun is_trivial (Lineq(_,_,l,_)) = forall (fn i => i=0) l;
3.24
3.25 -fun is_contradictory (ans as Lineq(k,ty,l,_)) =
3.26 +fun is_contradictory (Lineq(k,ty,_,_)) =
3.27 case ty of Eq => k <> 0 | Le => k > 0 | Lt => k >= 0;
3.28
3.29 fun calc_blowup l =
3.30 @@ -550,7 +550,7 @@
3.31 in (t,i * (m div j)) end
3.32 in (m,(map mult rlhs, rn*(m div rd), rel, map mult rrhs, sn*(m div sd), d)) end
3.33
3.34 -fun mklineq n atoms =
3.35 +fun mklineq atoms =
3.36 fn (item, k) =>
3.37 let val (m, (lhs,i,rel,rhs,j,discrete)) = integ item
3.38 val lhsa = map (coeff lhs) atoms
3.39 @@ -705,7 +705,7 @@
3.40 let
3.41 val atoms = atoms_of (map fst initems)
3.42 val n = length atoms
3.43 - val mkleq = mklineq n atoms
3.44 + val mkleq = mklineq atoms
3.45 val ixs = 0 upto (n - 1)
3.46 val iatoms = atoms ~~ ixs
3.47 val natlineqs = map_filter (mknat Ts ixs) iatoms
4.1 --- a/src/Provers/README Wed Jul 28 11:42:48 2010 +0200
4.2 +++ b/src/Provers/README Wed Jul 28 14:09:56 2010 +0200
4.3 @@ -13,10 +13,8 @@
4.4 typedsimp.ML basic simplifier for explicitly typed logics
4.5
4.6 directory Arith:
4.7 - abel_cancel.ML cancel complementary terms in sums of Abelian groups
4.8 assoc_fold.ML fold numerals in nested products
4.9 cancel_numerals.ML cancel common coefficients in balanced expressions
4.10 - cancel_factor.ML cancel common constant factor
4.11 cancel_sums.ML cancel common summands
4.12 combine_numerals.ML combine coefficients in expressions
4.13 fast_lin_arith.ML generic linear arithmetic package