src/Provers/Arith/fast_lin_arith.ML
changeset 18330 444f16d232a2
parent 18011 685d95c793ff
child 18572 dab1dd61e59d
equal deleted inserted replaced
18329:221d47d17a81 18330:444f16d232a2
   277 (* ------------------------------------------------------------------------- *)
   277 (* ------------------------------------------------------------------------- *)
   278 (* Add together (in)equations.                                               *)
   278 (* Add together (in)equations.                                               *)
   279 (* ------------------------------------------------------------------------- *)
   279 (* ------------------------------------------------------------------------- *)
   280 
   280 
   281 fun add_ineq (i1 as Lineq(k1,ty1,l1,just1)) (i2 as Lineq(k2,ty2,l2,just2)) =
   281 fun add_ineq (i1 as Lineq(k1,ty1,l1,just1)) (i2 as Lineq(k2,ty2,l2,just2)) =
   282   let val l = map2 (op +) (l1,l2)
   282   let val l = map2 (curry (op +)) l1 l2
   283   in Lineq(k1+k2,find_add_type(ty1,ty2),l,Added(just1,just2)) end;
   283   in Lineq(k1+k2,find_add_type(ty1,ty2),l,Added(just1,just2)) end;
   284 
   284 
   285 (* ------------------------------------------------------------------------- *)
   285 (* ------------------------------------------------------------------------- *)
   286 (* Elimination of variable between a single pair of (in)equations.           *)
   286 (* Elimination of variable between a single pair of (in)equations.           *)
   287 (* If they're both inequalities, 1st coefficient must be +ve, 2nd -ve.       *)
   287 (* If they're both inequalities, 1st coefficient must be +ve, 2nd -ve.       *)
   502 fun mklineq n atoms =
   502 fun mklineq n atoms =
   503   fn (item,k) =>
   503   fn (item,k) =>
   504   let val (m,(lhs,i,rel,rhs,j,discrete)) = integ item
   504   let val (m,(lhs,i,rel,rhs,j,discrete)) = integ item
   505       val lhsa = map (coeff lhs) atoms
   505       val lhsa = map (coeff lhs) atoms
   506       and rhsa = map (coeff rhs) atoms
   506       and rhsa = map (coeff rhs) atoms
   507       val diff = map2 (op -) (rhsa,lhsa)
   507       val diff = map2 (curry (op -)) rhsa lhsa
   508       val c = i-j
   508       val c = i-j
   509       val just = Asm k
   509       val just = Asm k
   510       fun lineq(c,le,cs,j) = Lineq(c,le,cs, if m=1 then j else Multiplied2(m,j))
   510       fun lineq(c,le,cs,j) = Lineq(c,le,cs, if m=1 then j else Multiplied2(m,j))
   511   in case rel of
   511   in case rel of
   512       "<="   => lineq(c,Le,diff,just)
   512       "<="   => lineq(c,Le,diff,just)