(datatype Math (Num Rational) (Var String) (Mul Math Math)) (function hi (Math) Rational :merge (min old new)) (function lo (Math) Rational :merge (max old new)) (rule ((= mul (Mul a b))) ((set (lo mul) (min (min (* (lo a) (lo b)) (* (lo a) (hi b))) (min (* (hi a) (lo b)) (* (hi a) (hi b))))))) (let x (Var "x")) (let e (Mul x x)) (set (lo x) (rational -10 1)) (set (hi x) (rational 10 1)) (run 1) (check (= (lo e) (rational -100 1))) (rule ((= mul (Mul a a))) ((set (lo mul) (* (lo a) (lo a))))) (run 1) (check (= (lo e) (rational 100 1))) ;; testing extraction of rationals (query-extract (lo e))