def test_get_strict_formula(self): smtlib_single = """ (set-logic UF_LIRA) (declare-fun x () Bool) (declare-fun y () Bool) (declare-fun r () Real) (assert (> r 0.0)) (assert x) (check-sat) """ smtlib_double = smtlib_single + """ (assert (not y)) (check-sat) """ r = Symbol("r", REAL) x, y = Symbol("x"), Symbol("y") target_one = And(GT(r, Real(0)), x) target_two = And(GT(r, Real(0)), x, Not(y)) stream_in = cStringIO(smtlib_single) f = get_formula(stream_in) self.assertEqual(f, target_one) stream_in = cStringIO(smtlib_double) f = get_formula(stream_in) self.assertEqual(f, target_two) stream_in = cStringIO(smtlib_double) with self.assertRaises(PysmtValueError): f = get_formula_strict(stream_in)
def test_get_strict_formula(self): smtlib_single = """ (set-logic UF_LIRA) (declare-fun x () Bool) (declare-fun y () Bool) (declare-fun r () Real) (assert (> r 0.0)) (assert x) (check-sat) """ smtlib_double = smtlib_single + """ (assert (not y)) (check-sat) """ r = Symbol("r", REAL) x, y = Symbol("x"), Symbol("y") target_one = And(GT(r, Real(0)), x) target_two = And(GT(r, Real(0)), x, Not(y)) stream_in = cStringIO(smtlib_single) f = get_formula(stream_in) self.assertEqual(f, target_one) stream_in = cStringIO(smtlib_double) f = get_formula(stream_in) self.assertEqual(f, target_two) stream_in = cStringIO(smtlib_double) with self.assertRaises(PysmtValueError): f = get_formula_strict(stream_in)
def test_yices_bv_no_overflow(self): smt_script = ''' (set-logic QF_BV) (declare-fun s0 () (_ BitVec 64)) (define-fun s1 () (_ BitVec 64) #x7FFFFFFFFFFFFFFF) (define-fun s2 () Bool (= s1 s0)) (assert s2) (check-sat) ''' from pysmt.smtlib.parser import get_formula_strict f = get_formula_strict(cStringIO(smt_script)) self.assertSat(f, solver_name='yices')