Exemplo n.º 1
0
 def test_push_pop(self):
     self.assertTrue(solver.check())
     solver.push()
     self.assertTrue(solver.check())
     solver.add(z3False)
     self.assertFalse(solver.check())
     solver.pop()
     self.assertTrue(solver.check())
Exemplo n.º 2
0
 def test_push_pop(self):
     self.assertTrue(solver.check())
     solver.push()
     self.assertTrue(solver.check())
     solver.add(z3False)
     self.assertFalse(solver.check())
     solver.pop()
     self.assertTrue(solver.check())
Exemplo n.º 3
0
 def test_add(self):
     with solver.context():
         self.assertTrue(solver.check())
         solver.add(z3True)
         self.assertTrue(solver.check())
         x = z3.Const('x', z3.IntSort())
         solver.add(x == 2)
         self.assertTrue(solver.check())
         solver.add(x == 3)
         self.assertFalse(solver.check())
         solver.add(z3False)
         self.assertFalse(solver.check())
Exemplo n.º 4
0
 def test_add(self):
     with solver.context():
         self.assertTrue(solver.check())
         solver.add(z3True)
         self.assertTrue(solver.check())
         x = z3.Const('x', z3.IntSort())
         solver.add(x == 2)
         self.assertTrue(solver.check())
         solver.add(x == 3)
         self.assertFalse(solver.check())
         solver.add(z3False)
         self.assertFalse(solver.check())
Exemplo n.º 5
0
    def test_equal_transitive(self):
        v1 = datatypes.new_variable()
        v2 = datatypes.new_variable()
        v3 = datatypes.new_variable()
        pred1 = atomic_predicate.Equal(v1, v2)
        pred2 = atomic_predicate.Equal(v2, v3)
        pred3 = atomic_predicate.Equal(v1, v3)

        with solver.context():
            solver.add(pred1._assert(self.submodel, self.interpretation))
            solver.add(pred2._assert(self.submodel, self.interpretation))
            sat = solver.check()
            self.assertTrue(sat)

            solver.add(
                z3.Not(pred3._assert(self.submodel, self.interpretation)))
            unsat = solver.check()
            self.assertFalse(unsat)
Exemplo n.º 6
0
 def check_sat(self):
     # returns a boolean
     with solver.context():
         modelset = new_modelset()
         interpretation = z3.Function('interpretation', Variable, Node)
         predicate = self._assert(modelset, interpretation)
         #if DEBUG:
         #    import pdb; pdb.set_trace()
         solver.add(predicate)
         return solver.check()
Exemplo n.º 7
0
 def get_model(self):
     # returns a set of sets of <graph, action> pairs, or at the very least
     # something that behaves on the surface as such. It might not
     # necessarily be a complete set. Actions should also behave as sets
     # (sets of atomic actions).
     with solver.context():
         predicate = self.get_predicate()
         solver.add(predicate)
         if not solver.check():
             raise ValueError("Tried to get model of unsat predicate")
         return solver.model()
Exemplo n.º 8
0
 def get_model(self):
     # returns a set of sets of <graph, action> pairs, or at the very least
     # something that behaves on the surface as such. It might not
     # necessarily be a complete set. Actions should also behave as sets
     # (sets of atomic actions).
     with solver.context():
         predicate = self.get_predicate()
         solver.add(predicate)
         if not solver.check():
             raise ValueError("Tried to get model of unsat predicate")
         return solver.model()
Exemplo n.º 9
0
 def test_validity_of_name_implies_name(self):
     v = datatypes.new_variable()
     s1 = "Same Name"
     s2 = "Same Name"
     pred1 = atomic_predicate.Named(v, s1)
     pred2 = atomic_predicate.Named(v, s2)
     with solver.context():
         solver.add(pred1._assert(self.submodel, self.interpretation))
         self.assertTrue(solver.check())
         status = solver.quick_check_implied(
             pred2._assert(self.submodel, self.interpretation))
         self.assertTrue(status)
Exemplo n.º 10
0
 def get_model(self):
     # returns a set of sets of <graph, action> pairs, or at the very least
     # something that behaves on the surface as such. It might not
     # necessarily be a complete set. Actions should also behave as sets
     # (sets of atomic actions).
     with solver.context():
         modelset = new_modelset()
         interpretation = z3.Function('interpretation', Variable, Node)
         predicate = self._assert(modelset, interpretation)
         #if DEBUG:
         #    import pdb; pdb.set_trace()
         solver.add(predicate)
         if not solver.check():
             raise ValueError("Tried to get model of unsat predicate")
         return solver.model()
Exemplo n.º 11
0
 def test_context(self):
     with solver.context():
         solver.add(z3False)
         self.assertFalse(solver.check())
     self.assertTrue(solver.check())
Exemplo n.º 12
0
 def test_quick_check_pushes_and_pops(self):
     self.assertTrue(solver.check())
     self.assertFalse(solver.quick_check(z3False))
     self.assertTrue(solver.check())
Exemplo n.º 13
0
 def test_context(self):
     with solver.context():
         solver.add(z3False)
         self.assertFalse(solver.check())
     self.assertTrue(solver.check())
Exemplo n.º 14
0
 def test_quick_check_pushes_and_pops(self):
     self.assertTrue(solver.check())
     self.assertFalse(solver.quick_check(z3False))
     self.assertTrue(solver.check())