src/HOL/Tools/Presburger/cooper_dec.ML
changeset 15164 5d7c96e0f9dc
parent 15107 f233706d9fce
child 15267 96c59666a0bf
equal deleted inserted replaced
15163:73386e0319a2 15164:5d7c96e0f9dc
    12   exception COOPER
    12   exception COOPER
    13   exception COOPER_ORACLE of term
    13   exception COOPER_ORACLE of term
    14   val is_arith_rel : term -> bool
    14   val is_arith_rel : term -> bool
    15   val mk_numeral : int -> term
    15   val mk_numeral : int -> term
    16   val dest_numeral : term -> int
    16   val dest_numeral : term -> int
       
    17   val is_numeral : term -> bool
    17   val zero : term
    18   val zero : term
    18   val one : term
    19   val one : term
    19   val linear_cmul : int -> term -> term
    20   val linear_cmul : int -> term -> term
    20   val linear_add : string list -> term -> term -> term 
    21   val linear_add : string list -> term -> term -> term 
    21   val linear_sub : string list -> term -> term -> term 
    22   val linear_sub : string list -> term -> term -> term 
   206 (* Linearize the atoms in a formula, and eliminate non-strict inequalities.  *) 
   207 (* Linearize the atoms in a formula, and eliminate non-strict inequalities.  *) 
   207 (* ------------------------------------------------------------------------- *) 
   208 (* ------------------------------------------------------------------------- *) 
   208  
   209  
   209 fun mkatom vars p t = Const(p,HOLogic.intT --> HOLogic.intT --> HOLogic.boolT) $ zero $ (lint vars t); 
   210 fun mkatom vars p t = Const(p,HOLogic.intT --> HOLogic.intT --> HOLogic.boolT) $ zero $ (lint vars t); 
   210  
   211  
   211 fun linform vars (Const ("Divides.op dvd",_) $ c $ t) =  
   212 fun linform vars (Const ("Divides.op dvd",_) $ c $ t) =
       
   213     if is_numeral c then   
   212       let val c' = (mk_numeral(abs(dest_numeral c)))  
   214       let val c' = (mk_numeral(abs(dest_numeral c)))  
   213       in (HOLogic.mk_binrel "Divides.op dvd" (c,lint vars t)) 
   215       in (HOLogic.mk_binrel "Divides.op dvd" (c,lint vars t)) 
   214       end 
   216       end 
       
   217     else (warning "Nonlinear term --- Non numeral leftside at dvd"
       
   218       ;raise COOPER)
   215   |linform vars  (Const("op =",Type ("fun",[Type ("IntDef.int", []),_])) $ s $ t ) = (mkatom vars "op =" (Const ("op -",HOLogic.intT --> HOLogic.intT --> HOLogic.intT) $ t $ s) ) 
   219   |linform vars  (Const("op =",Type ("fun",[Type ("IntDef.int", []),_])) $ s $ t ) = (mkatom vars "op =" (Const ("op -",HOLogic.intT --> HOLogic.intT --> HOLogic.intT) $ t $ s) ) 
   216   |linform vars  (Const("op <",_)$ s $t ) = (mkatom vars "op <" (Const ("op -",HOLogic.intT --> HOLogic.intT --> HOLogic.intT) $ t $ s))
   220   |linform vars  (Const("op <",_)$ s $t ) = (mkatom vars "op <" (Const ("op -",HOLogic.intT --> HOLogic.intT --> HOLogic.intT) $ t $ s))
   217   |linform vars  (Const("op >",_) $ s $ t ) = (mkatom vars "op <" (Const ("op -",HOLogic.intT --> HOLogic.intT --> HOLogic.intT) $ s $ t)) 
   221   |linform vars  (Const("op >",_) $ s $ t ) = (mkatom vars "op <" (Const ("op -",HOLogic.intT --> HOLogic.intT --> HOLogic.intT) $ s $ t)) 
   218   |linform vars  (Const("op <=",_)$ s $ t ) = 
   222   |linform vars  (Const("op <=",_)$ s $ t ) = 
   219         (mkatom vars "op <" (Const ("op -",HOLogic.intT --> HOLogic.intT --> HOLogic.intT) $ (Const("op +",HOLogic.intT --> HOLogic.intT --> HOLogic.intT) $t $(mk_numeral 1)) $ s)) 
   223         (mkatom vars "op <" (Const ("op -",HOLogic.intT --> HOLogic.intT --> HOLogic.intT) $ (Const("op +",HOLogic.intT --> HOLogic.intT --> HOLogic.intT) $t $(mk_numeral 1)) $ s))