def test_sat(self): ctx = Context() ctx.SetLogic(Logic.QF_NRA) ctx.DeclareVariable(x, -10, 10) ctx.DeclareVariable(y, -10, 10) ctx.Assert(x == y + 5) ctx.Assert(y == 2) result = ctx.CheckSat() self.assertTrue(result) self.assertEqual(result[y].mid(), 2) self.assertEqual(result[x].mid(), 2 + 5) ctx.Exit()
def test_unsat(self): ctx = Context() ctx.SetLogic(Logic.QF_NRA) x = Variable("x") y = Variable("y") ctx.DeclareVariable(x, -10, 10) ctx.DeclareVariable(y, -10, 10) ctx.Assert(x == y + 5) ctx.Assert(y == x - 3) result = ctx.CheckSat() self.assertFalse(result) ctx.Exit()
def test_config(self): ctx = Context() config1 = ctx.config self.assertEqual(config1.precision, 0.001) config1.precision = 0.0001 self.assertEqual(ctx.config.precision, 0.0001)
def test_push_pop(self): ctx = Context() ctx.SetLogic(Logic.QF_NRA) x = Variable("x") y = Variable("y") ctx.DeclareVariable(x) ctx.SetInterval(x, -10, 10) ctx.DeclareVariable(y, -10, 10) ctx.Assert(x == y + 5) ctx.Push(1) ctx.Assert(y == x - 3) result = ctx.CheckSat() self.assertFalse(result) ctx.Pop(1) result = ctx.CheckSat() self.assertTrue(result) ctx.Exit() self.assertTrue(ctx.box)