예제 #1
0
    def test_model_is_refreshed(self):
        """
        After a push and a pop, the model should be updated.
        After adding a new assertion, the model should be updated.
        """
        TestVariable = z3.Datatype('TestVariable')
        TestVariable.declare('test_variable',
            ('number', z3.IntSort()))
        TestVariable = TestVariable.create()

        v1 = z3.Const('v1', TestVariable)
        v2 = z3.Const('v2', TestVariable)

        with solver.context():
            solver.add(TestVariable.number(v1) == 42)
            m1 = solver.model()
            self.assertIsNotNone(m1[v1])
            self.assertIsNone(m1[v2])

            solver.add(TestVariable.number(v2) == 3)
            m2 = solver.model()
            self.assertIsNotNone(m2[v1])
            self.assertIsNotNone(m2[v2])

        m3 = solver.model()
        self.assertIsNone(m3[v1])
        self.assertIsNone(m3[v2])
예제 #2
0
    def test_model_is_refreshed(self):
        """
        After a push and a pop, the model should be updated.
        After adding a new assertion, the model should be updated.
        """
        TestVariable = z3.Datatype('TestVariable')
        TestVariable.declare('test_variable', ('number', z3.IntSort()))
        TestVariable = TestVariable.create()

        v1 = z3.Const('v1', TestVariable)
        v2 = z3.Const('v2', TestVariable)

        with solver.context():
            solver.add(TestVariable.number(v1) == 42)
            m1 = solver.model()
            self.assertIsNotNone(m1[v1])
            self.assertIsNone(m1[v2])

            solver.add(TestVariable.number(v2) == 3)
            m2 = solver.model()
            self.assertIsNotNone(m2[v1])
            self.assertIsNotNone(m2[v2])

        m3 = solver.model()
        self.assertIsNone(m3[v1])
        self.assertIsNone(m3[v2])
예제 #3
0
 def test_named_get_model(self):
     v = datatypes.new_variable()
     s = "Name"
     pred = atomic_predicate.Named(v, s)
     z3pred = pred._assert(self.submodel, self.interpretation)
     with solver.context():
         solver.add(z3pred)
         model = solver.model()
         self.assertIsNotNone(model[v])
         self.assertEquals(model[v], datatypes.Variable.variable(1))
예제 #4
0
파일: predicate.py 프로젝트: bgyori/syndra
 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()
예제 #5
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()
예제 #6
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()