| author | webertj | 
| Thu, 28 Oct 2004 19:40:22 +0200 | |
| changeset 15269 | f856f4f3258f | 
| parent 15233 | c55a12162944 | 
| child 15272 | 79a7a4f20f50 | 
| permissions | -rw-r--r-- | 
| 15232 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 1 | (**************************************************************) | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 2 | (* *) | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 3 | (* *) | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 4 | (* Trying to implement an Bounded arithmetic *) | 
| 15233 | 5 | (* Chaieb Amine *) | 
| 15232 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 6 | (* *) | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 7 | (**************************************************************) | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 8 | |
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 9 | signature BARITH = | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 10 | sig | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 11 | val barith_tac : int -> tactic | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 12 | val setup : (theory -> theory) list | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 13 | |
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 14 | end; | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 15 | |
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 16 | |
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 17 | structure Barith = | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 18 | struct | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 19 | |
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 20 | (* Theorems we use from Barith.thy*) | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 21 | val abs_const = thm "abs_const"; | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 22 | val abs_var = thm "abs_var"; | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 23 | val abs_neg = thm "abs_neg"; | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 24 | val abs_add = thm "abs_add"; | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 25 | val abs_sub = thm "abs_sub"; | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 26 | val abs_sub_x = thm "abs_sub_x"; | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 27 | val abs_mul = thm "abs_mul"; | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 28 | val abs_mul_x = thm "abs_mul_x"; | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 29 | val subinterval = thm "subinterval"; | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 30 | val imp_commute = thm "imp_commute"; | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 31 | val imp_simplify = thm "imp_simplify"; | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 32 | |
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 33 | exception NORMCONJ of string; | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 34 | |
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 35 | fun interval_of_conj t = case t of | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 36 |  Const("op &",_) $
 | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 37 |   (Const("op <=",_) $ l1 $(x as Free(xn,xT)))$
 | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 38 |   (Const("op <=",_) $ y $ u1) => 
 | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 39 | if (x = y andalso type_of x = HOLogic.intT) | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 40 | then (x,(l1,u1)) | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 41 | else raise | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 42 | (NORMCONJ "Not in normal form -- not the same variable") | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 43 | | Const("op &",_) $(Const("op <=",_) $ y $ u1)$
 | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 44 |   (Const("op <=",_) $ l1 $(x as Free(xn,xT))) =>
 | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 45 | if (x = y andalso type_of x = HOLogic.intT) | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 46 | then (x,(l1,u1)) | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 47 | else raise | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 48 | (NORMCONJ "Not in normal form -- not the same variable") | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 49 | |(Const("op <=",_) $ l $(x as Free(xn,xT))) => (x,(l,x))
 | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 50 | |(Const("op <=",_) $ (x as Free(xn,xT))$ u) => (x,(x,u))
 | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 51 | |_ => raise (NORMCONJ "Not in normal form - unknown conjunct"); | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 52 | |
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 53 | |
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 54 | (* The input to this function should be a list *) | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 55 | (*of meta-implications of the following form:*) | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 56 | (* l1 <= x1 & x1 <= u1 ==> ... ==> ln <= xn & xn <= un*) | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 57 | (* the output will be a list of Var*interval*) | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 58 | |
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 59 | val iT = HOLogic.intT; | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 60 | fun maxterm t1 t2 = Const("HOL.max",iT --> iT --> iT)$t1$t2;
 | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 61 | fun minterm t1 t2 = Const("HOL.min",iT --> iT --> iT)$t1$t2;
 | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 62 | |
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 63 | fun intervals_of_premise p = | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 64 | let val ps = map HOLogic.dest_Trueprop (Logic.strip_imp_prems p) | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 65 | fun tight [] = [] | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 66 | |tight ((x,(l,u))::ls) = | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 67 | let val ls' = tight ls in | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 68 | case assoc (ls',x) of | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 69 | None => (x,(l,u))::ls' | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 70 | |Some (l',u') => let val ln = if (CooperDec.is_numeral l) andalso (CooperDec.is_numeral l') then CooperDec.mk_numeral (Int.min (CooperDec.dest_numeral l,CooperDec.dest_numeral l')) else (maxterm l l') | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 71 | val un = if (CooperDec.is_numeral u) andalso (CooperDec.is_numeral u') then CooperDec.mk_numeral (Int.min (CooperDec.dest_numeral u,CooperDec.dest_numeral u')) else (minterm u u') | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 72 | in (x,(ln,un))::(filter (fn p => fst p = x) ls') | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 73 | end | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 74 | end | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 75 | in tight (map interval_of_conj ps) | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 76 | end ; | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 77 | |
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 78 | fun exp_of_concl p = case p of | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 79 |   Const("op &",_) $
 | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 80 |   (Const("op <=",_) $ l $ e)$
 | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 81 |   (Const("op <=",_) $ e' $ u) => 
 | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 82 | if e = e' then [(e,(Some l,Some u))] | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 83 | else raise NORMCONJ "Conclusion not in normal form-- different exp in conj" | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 84 | |Const("op &",_) $
 | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 85 |   (Const("op <=",_) $ e' $ u)$
 | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 86 |   (Const("op <=",_) $ l $ e) => 
 | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 87 | if e = e' then [(e,(Some l,Some u))] | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 88 | else raise NORMCONJ "Conclusion not in normal form-- different exp in conj" | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 89 | |(Const("op <=",_) $ e $ u) =>
 | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 90 | if (CooperDec.is_numeral u) then [(e,(None,Some u))] | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 91 | else | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 92 | if (CooperDec.is_numeral e) then [(u,(Some e,None))] | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 93 | else raise NORMCONJ "Bounds has to be numerals" | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 94 | |(Const("op &",_)$a$b) => (exp_of_concl a) @ (exp_of_concl b)
 | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 95 | |_ => raise NORMCONJ "Conclusion not in normal form---unknown connective"; | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 96 | |
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 97 | |
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 98 | fun strip_problem p = | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 99 | let | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 100 | val is = intervals_of_premise p | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 101 | val e = exp_of_concl ((HOLogic.dest_Trueprop o Logic.strip_imp_concl) p) | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 102 | in (is,e) | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 103 | end; | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 104 | |
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 105 | |
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 106 | |
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 107 | |
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 108 | (*Abstract interpretation of Intervals over theorems *) | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 109 | exception ABSEXP of string; | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 110 | |
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 111 | fun decomp_absexp sg is e = case e of | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 112 | Free(xn,_) => ([], fn [] => case assoc (is,e) of | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 113 | Some (l,u) => instantiate' [] | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 114 | (map (fn a => Some (cterm_of sg a)) [l,e,u]) abs_var | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 115 |   |_ => raise ABSEXP ("No Interval for Variable   " ^ xn) )
 | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 116 | |Const("op +",_) $ e1 $ e2 => 
 | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 117 | ([e1,e2], fn [th1,th2] => [th1,th2] MRS abs_add) | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 118 | |Const("op -",_) $ e1 $ e2 => 
 | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 119 | if e1 = e2 then | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 120 | ([e1],fn [th] => th RS abs_sub_x) | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 121 | else | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 122 | ([e1,e2], fn [th1,th2] => [th1,th2] MRS abs_sub) | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 123 | |Const("op *",_) $ e1 $ e2 => 
 | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 124 | if e1 = e2 then | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 125 | ([e1],fn [th] => th RS abs_mul_x) | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 126 | else | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 127 | ([e1,e2], fn [th1,th2] => [th1,th2] MRS abs_mul) | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 128 | |Const("op uminus",_) $ e' => 
 | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 129 | ([e'], fn [th] => th RS abs_neg) | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 130 | |_ => if CooperDec.is_numeral e then | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 131 | ([], fn [] => instantiate' [] [Some (cterm_of sg e)] abs_const) | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 132 | else raise ABSEXP "Unknown arithmetical expression"; | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 133 | |
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 134 | fun absexp sg is (e,(lo,uo)) = case (lo,uo) of | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 135 | (Some l, Some u) => | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 136 | let | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 137 | val th1 = CooperProof.thm_of sg (decomp_absexp sg is) e | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 138 | val th2 = instantiate' [] [None,None,None,Some (cterm_of sg l),Some (cterm_of sg u)] subinterval | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 139 | val ss = (simpset_of (theory "Presburger")) addsimps [max_def,min_def] | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 140 | val my_ss = HOL_basic_ss addsimps [imp_commute, imp_simplify] | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 141 | val th' = th1 | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 142 | val th = th' RS th2 | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 143 | in th | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 144 | end | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 145 | |(None, Some u) => | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 146 | let | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 147 | val th1 = CooperProof.thm_of sg (decomp_absexp sg is) e | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 148 |     val Const("op &",_)$
 | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 149 |       (Const("op <=",_)$l$_)$_= (HOLogic.dest_Trueprop o concl_of) th1
 | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 150 | val th2 = instantiate' [] [None,None,None,Some (cterm_of sg l),Some (cterm_of sg u)] subinterval | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 151 | val ss = (simpset_of (theory "Presburger")) addsimps [max_def,min_def] | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 152 | val my_ss = HOL_basic_ss addsimps [imp_commute, imp_simplify] | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 153 | val th' = th1 | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 154 | val th = th' RS th2 | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 155 | in th RS conjunct2 | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 156 | end | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 157 | |
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 158 | |(Some l, None) => let | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 159 | val th1 = CooperProof.thm_of sg (decomp_absexp sg is) e | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 160 |     val Const("op &",_)$_$
 | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 161 |       (Const("op <=",_)$_$u)= (HOLogic.dest_Trueprop o concl_of) th1
 | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 162 | val th2 = instantiate' [] [None,None,None,Some (cterm_of sg l),Some (cterm_of sg u)] subinterval | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 163 | val ss = (simpset_of (theory "Presburger")) addsimps [max_def,min_def] | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 164 | val my_ss = HOL_basic_ss addsimps [imp_commute, imp_simplify] | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 165 | val th' = th1 | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 166 | val th = th' RS th2 | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 167 | in th RS conjunct1 | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 168 | end | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 169 | |
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 170 | |(None,None) => raise ABSEXP "No bounds for conclusion"; | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 171 | |
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 172 | fun free_occ e = case e of | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 173 | Free(_,i) => if i = HOLogic.intT then 1 else 0 | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 174 | |f$a => (free_occ f) + (free_occ a) | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 175 | |Abs(_,_,p) => free_occ p | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 176 | |_ => 0; | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 177 | |
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 178 | |
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 179 | (* | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 180 | fun simp_exp sg p = | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 181 | let val (is,(e,(l,u))) = strip_problem p | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 182 | val th = absexp sg is (e,(l,u)) | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 183 | val _ = prth th | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 184 | in (th, free_occ e) | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 185 | end; | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 186 | *) | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 187 | |
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 188 | fun simp_exp sg p = | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 189 | let val (is,es) = strip_problem p | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 190 | val ths = map (absexp sg is) es | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 191 | val n = foldr (fn ((e,(_,_)),x) => (free_occ e) + x) (es,0) | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 192 | in (ths, n) | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 193 | end; | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 194 | |
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 195 | |
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 196 | |
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 197 | (* ============================ *) | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 198 | (* The barith Tactic *) | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 199 | (* ============================ *) | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 200 | |
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 201 | (* | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 202 | fun barith_tac i = ObjectLogic.atomize_tac i THEN (fn st => | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 203 | let | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 204 | fun assm_tac n j = REPEAT_DETERM_N n ((assume_tac j) ORELSE (simple_arith_tac j)) | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 205 | val g = BasisLibrary.List.nth (prems_of st, i - 1) | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 206 | val sg = sign_of_thm st | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 207 | val ss = (simpset_of (the_context())) addsimps [max_def,min_def] | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 208 | val (th,n) = simp_exp sg g | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 209 | in (rtac th i | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 210 | THEN assm_tac n i | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 211 | THEN (TRY (REPEAT_DETERM_N 2 (simp_tac ss i)))) st | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 212 | end); | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 213 | |
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 214 | *) | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 215 | |
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 216 | |
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 217 | fun barith_tac i = ObjectLogic.atomize_tac i THEN (fn st => | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 218 | let | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 219 | fun assm_tac n j = REPEAT_DETERM_N n ((assume_tac j) ORELSE (simple_arith_tac j)) | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 220 | val g = BasisLibrary.List.nth (prems_of st, i - 1) | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 221 | val sg = sign_of_thm st | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 222 | val ss = (simpset_of (theory "Barith")) addsimps [max_def,min_def] | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 223 | val (ths,n) = simp_exp sg g | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 224 | val cn = length ths - 1 | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 225 | fun conjIs thn j = EVERY (map (rtac conjI) (j upto (thn + j - 1))) | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 226 | fun thtac thms j = EVERY (map | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 227 | (fn t => rtac t j THEN assm_tac n j | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 228 | THEN (TRY (REPEAT_DETERM_N 2 (simp_tac ss j)))) thms) | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 229 | in ((conjIs cn i) THEN (thtac ths i)) st | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 230 | end); | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 231 | |
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 232 | fun barith_args meth = | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 233 | let val parse_flag = | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 234 | Args.$$$ "no_quantify" >> K (apfst (K false)) | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 235 | || Args.$$$ "abs" >> K (apsnd (K true)); | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 236 | in | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 237 | Method.simple_args | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 238 |   (Scan.optional (Args.$$$ "(" |-- Scan.repeat1 parse_flag --| Args.$$$ ")") []
 | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 239 | >> | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 240 | curry (foldl op |>) (true, false)) | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 241 | (fn (q,a) => fn _ => meth 1) | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 242 | end; | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 243 | |
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 244 | fun barith_method i = Method.METHOD (fn facts => | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 245 | Method.insert_tac facts 1 THEN barith_tac i) | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 246 | |
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 247 | val setup = | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 248 |   [Method.add_method ("barith",
 | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 249 | Method.no_args (barith_method 1), | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 250 | "VERY simple decision procedure for bounded arithmetic")]; | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 251 | |
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 252 | |
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 253 | (* End of Structure *) | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 254 | end; | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 255 | |
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 256 | (* Test *) | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 257 | (* | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 258 | open Barith; | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 259 | |
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 260 | Goal "-1 <= (x::int) & x <= 1 ==> 0 <= (y::int) & y <= 5 + 7 ==> -13 <= x*x + y*x & x*x + y*x <= 20"; | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 261 | by(barith_tac 1); | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 262 | |
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 263 | Goal "-1 <= (x::int) & x <= 1 ==> 0 <= (y::int) & y <= 5 + 7 ==> 0 <= x - x + y & x - x + y<= 12"; | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 264 | by(barith_tac 1); | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 265 | |
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 266 | Goal "-1 <= (x::int) & x <= 1 ==> 0 <= (y::int) & y <= 5 + 7 ==> 0 <= x - x + x*x & x - x + x*x<= 1"; | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 267 | by(barith_tac 1); | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 268 | |
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 269 | Goal "(x::int) <= 1& 1 <= x ==> 0 <= (y::int) & y <= 5 + 7 ==> 0 <= x - x + x*x & x - x + x*x<= 1"; | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 270 | by(barith_tac 1); | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 271 | |
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 272 | Goal "(x::int) <= 1& 1 <= x ==> (t::int) <= 8 ==>(x::int) <= 2& 0 <= x ==> 0 <= (y::int) & y <= 5 + 7 ==> 0 <= x - x + x*x & x - x + x*x<= 1"; | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 273 | by(barith_tac 1); | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 274 | |
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 275 | Goal "-1 <= (x::int) & x <= 1 ==> 0 <= (y::int) & y <= 5 + 7 ==> -4 <= x - x + x*x"; | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 276 | by(barith_tac 1); | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 277 | |
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 278 | Goal "[|(0::int) <= x & x <= 5 ; 0 <= (y::int) & y <= 7|]==> (0 <= x*x*x & x*x*x <= 125 ) & (0 <= x*x & x*x <= 100) & (0 <= x*x + x & x*x + x <= 30) & (0<= x*y & x*y <= 35)"; | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 279 | by (barith_tac 1); | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 280 | *) | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 281 | |
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 282 | |
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 283 | (* | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 284 | val st = topthm(); | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 285 | val sg = sign_of_thm st; | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 286 | val g = BasisLibrary.List.nth (prems_of st, 0); | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 287 | val (ths,n) = simp_exp sg g; | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 288 | fun assm_tac n j = REPEAT_DETERM_N n ((assume_tac j) ORELSE (simple_arith_tac j)); | 
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 289 | |
| 
388a6f431d83
a very simple decision procedure for a fragment of bounded arithmetic
 chaieb parents: diff
changeset | 290 | *) |