src/Provers/Arith/fast_lin_arith.ML
changeset 17496 26535df536ae
parent 17325 d9d50222808e
child 17515 830bc15e692c
equal deleted inserted replaced
17495:ddb14cbec6a2 17496:26535df536ae
   276 
   276 
   277 fun multiply_ineq n (i as Lineq(k,ty,l,just)) =
   277 fun multiply_ineq n (i as Lineq(k,ty,l,just)) =
   278   if n = 1 then i
   278   if n = 1 then i
   279   else if n = 0 andalso ty = Lt then sys_error "multiply_ineq"
   279   else if n = 0 andalso ty = Lt then sys_error "multiply_ineq"
   280   else if n < 0 andalso (ty=Le orelse ty=Lt) then sys_error "multiply_ineq"
   280   else if n < 0 andalso (ty=Le orelse ty=Lt) then sys_error "multiply_ineq"
   281   else Lineq(n * k,ty,map (apl(n,op * )) l,Multiplied(n,just));
   281   else Lineq (n * k, ty, map (curry (op *) n) l, Multiplied (n, just));
   282 
   282 
   283 (* ------------------------------------------------------------------------- *)
   283 (* ------------------------------------------------------------------------- *)
   284 (* Add together (in)equations.                                               *)
   284 (* Add together (in)equations.                                               *)
   285 (* ------------------------------------------------------------------------- *)
   285 (* ------------------------------------------------------------------------- *)
   286 
   286 
   315 
   315 
   316 fun is_answer (ans as Lineq(k,ty,l,_)) =
   316 fun is_answer (ans as Lineq(k,ty,l,_)) =
   317   case ty  of Eq => k <> 0 | Le => k > 0 | Lt => k >= 0;
   317   case ty  of Eq => k <> 0 | Le => k > 0 | Lt => k >= 0;
   318 
   318 
   319 fun calc_blowup (l:IntInf.int list) =
   319 fun calc_blowup (l:IntInf.int list) =
   320   let val (p,n) = List.partition (apl(0,op<)) (List.filter (apl(0,op<>)) l)
   320   let val (p,n) = List.partition (curry (op <) 0) (List.filter (curry (op <>) 0) l)
   321   in (length p) * (length n) end;
   321   in (length p) * (length n) end;
   322 
   322 
   323 (* ------------------------------------------------------------------------- *)
   323 (* ------------------------------------------------------------------------- *)
   324 (* Main elimination code:                                                    *)
   324 (* Main elimination code:                                                    *)
   325 (*                                                                           *)
   325 (*                                                                           *)
   536               if p = 0 then "0"
   536               if p = 0 then "0"
   537               else IntInf.toString p ^ "/" ^ IntInf.toString q
   537               else IntInf.toString p ^ "/" ^ IntInf.toString q
   538   in a ^ " = " ^ s end;
   538   in a ^ " = " ^ s end;
   539 
   539 
   540 fun print_ex sds =
   540 fun print_ex sds =
   541   tracing o
   541   curry (op ~~) sds
   542   apl("Counter example:\n",op ^) o
   542   #> map print_atom
   543   commas o
   543   #> commas
   544   map print_atom o
   544   #> curry (op ^) "Counter example:\n"
   545   apl(sds, op ~~);
   545   #> tracing;
   546 
   546 
   547 fun trace_ex(sg,params,atoms,discr,n,hist:history) =
   547 fun trace_ex(sg,params,atoms,discr,n,hist:history) =
   548   if null hist then ()
   548   if null hist then ()
   549   else let val frees = map Free params;
   549   else let val frees = map Free params;
   550            fun s_of_t t = Sign.string_of_term sg (subst_bounds(frees,t));
   550            fun s_of_t t = Sign.string_of_term sg (subst_bounds(frees,t));