ComputationWithBoundedResources / slogic

A s(imple)logic library providing interfaces to external solvers
BSD 3-Clause "New" or "Revised" License
0 stars 1 forks source link

support Real/Rat type #3

Open mischel opened 9 years ago

mischel commented 9 years ago

minismt supports Rat and Real type. In many of our applications this would be sound. For the LP solver interface (issue #1), we should have a Real type anyway.

The extension is not trivial, as we have to extend/generalize the Formula type. There are some points that should be clarified beforehand.

mischel commented 9 years ago

minismt

z3

The behavior of z3 is not quite clear to me: Following formula returns sat ((x 1) (y 2.0).

(declare-fun x () Int)
(declare-fun y () Real)
(assert (= x 1.5))
(assert (= 1 1.5))
(assert (= y 2.0))
(assert (< x y))
(check-sat)
(get-value (x y))

On the other hand, this example returns unsat.

(declare-fun x () Int)
(declare-fun y () Real)
(assert (= (to_real x) 1.5))
(assert (= y 2.0))
(assert (< x y))
(check-sat)
(get-value (x y))

It seems there is some casting going on: This example returns sat

(assert (= 1 1.1))
(check-sat)

whereas this returns unsat.

(assert (= 1.1 1))
(check-sat)
mischel commented 9 years ago

Possible Approach:

data F v k where                                                                                                                                                                                                                                                         
   BVal :: Bool -> F v Bool
   BVar :: v -> F v Bool
   And :: [F v Bool] -> F v Bool

   AVal :: k -> F v k 
   AVar :: v -> F v k
   AEq  :: Show k => F v k -> F v k -> F v Bool

ivar :: v -> F v Int
ivar = AVAR

pros

cons