Esempio n. 1
0
    def _assert(self, modelset, i, g, a):
        g = new_graph('g')
        a = new_action('a')
        s = new_modelset('s')
        t = new_modelset('t')

        def is_plus(alpha, beta, a):
            # Assert that alpha + beta = a. All of these are Actions.
            # This is defined in Definition 2 of the L paper, on page 5.
            # TODO: implement this once you have a clear API for Action.
            pass

        def is_join(modelset, s, t, g, a):
            # Assert that modelset behaves, on inputs g and a, like s "joined" with t.
            # "joined" is the |><| operator.
            alpha = Action('alpha')
            beta = Action('beta')
            return z3_helpers.Iff(
                has(modelset, g, a), z3.Exists(alpha, beta),
                z3.And(has(s, g, alpha), has(t, g, beta),
                       is_plus(alpha, beta, a)))

        return z3.ForAll([g, a],
                         z3.And(self.p1._assert(s, i, g, a),
                                self.p2._assert(t, i, g, a),
                                is_join(modelset, s, t, g, a)))
Esempio n. 2
0
 def _assert(self, modelset, i):
     g = new_graph('g')
     a = new_action('a')
     s = new_modelset('s')
     t = new_modelset('t')
     return z3.Exists([s, t], z3.ForAll([g, a],
             z3.And(self.p1._assert(s, i), self.p2._assert(t, i),
                 z3_helpers.Iff(has(modelset, g, a), z3.And(has(s, g, a),
                                                            has(t, g, a))))))
Esempio n. 3
0
 def _assert(self, modelset, i):
     g = new_graph('g')
     a = new_action('a')
     s = new_modelset('s')
     return z3.Exists([s], z3.ForAll([g, a],
             z3.And(self.pred._assert(s, i),
                 z3_helpers.Iff(has(modelset, g, a), z3.Not(s(g, a))))))
Esempio n. 4
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()
Esempio n. 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():
         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()
Esempio n. 6
0
    def _assert(self, modelset, i):
        g = new_graph('g')
        a = new_action('a')
        s = new_modelset('s')
        t = new_modelset('t')

        def is_plus(alpha, beta, a):
            # Assert that alpha + beta = a. All of these are Actions.
            # This is defined in Definition 2 of the L paper, on page 5.
            # TODO: implement this once you have a clear API for Action.
            pass

        def is_join(modelset, s, t, g, a):
            # Assert that modelset behaves, on inputs g and a, like s "joined" with t.
            # "joined" is the |><| operator.
            alpha = Action('alpha')
            beta = Action('beta')
            return z3_helpers.Iff(has(modelset, g, a),
                       z3.Exists(alpha, beta),
                       z3.And(has(s, g, alpha), has(t, g, beta), is_plus(alpha, beta, a)))

        return z3.Exists([s, t], z3.ForAll([g, a],
                z3.And(self.p1._assert(s, i), self.p2._assert(t, i),
                    is_join(modelset, s, t, g, a))))
Esempio n. 7
0
 def get_predicate(self):
     modelset = new_modelset()
     interpretation = z3.Function('interpretation', Variable, Node)
     predicate = self._assert(modelset, interpretation)
     return predicate
Esempio n. 8
0
 def get_predicate(self):
     # returns a z3 predicate
     modelset = new_modelset()
     interpretation = new_interpretation()
     predicate = self._assert(modelset, interpretation, None, None)
     return predicate
Esempio n. 9
0
 def get_predicate(self):
     # returns a z3 predicate
     modelset = new_modelset()
     interpretation = new_interpretation()
     predicate = self._assert(modelset, interpretation, None, None)
     return predicate