Exemplo n.º 1
0
import predicate
from solver import MySolver
from unittest import TestCase

syndra_true = predicate.Top()
syndra_false = predicate.Bottom()

class SolverTestCase(TestCase):

    def setUp(self):
        self.solver = MySolver("A", "B")

    def test_quick_check_true(self):
        self.assertTrue(self.solver.quick_check(syndra_true))

    def test_quick_check_false(self):
        self.assertFalse(self.solver.quick_check(syndra_false))

    def test_quick_check_pushes_and_pops(self):
        self.assertTrue(self.solver.check())
        self.assertFalse(self.solver.quick_check(syndra_false))
        self.assertTrue(self.solver.check())

    def test_context(self):
        with self.solver.context():
            self.solver.add(syndra_false)
            self.assertFalse(self.solver.check())
        self.assertTrue(self.solver.check())

    def test_add(self):
        with self.solver.context():
Exemplo n.º 2
0
 def test_or_unsat(self):
     p1 = predicate.Bottom()
     p2 = predicate.Bottom()
     status = solver.quick_check(predicate.Or(p1, p2))
     self.assertFalse(status)
Exemplo n.º 3
0
 def test_bottom_unsat(self):
     self.assertUnsat(predicate.Bottom())
Exemplo n.º 4
0
import atomic_predicate
import datatypes
from labels import ACTIVE, PHOSPHORYLATED
from macros import directly_phosphorylates, directly_activates, phosphorylated_is_active
import predicate
from solver import solver
import z3

# Sanity checks.
assert not predicate.Bottom().check_sat()
assert predicate.Top().check_sat()
assert not predicate.And(predicate.Bottom(), predicate.Top()).check_sat()
assert not predicate.ForAll(predicate.Bottom()).check_sat()
assert predicate.ForAll(predicate.Top()).check_sat()
assert not predicate.Exists(predicate.Bottom()).check_sat()
assert predicate.Exists(predicate.Top()).check_sat()

print "Predicate I: MEK directly phosphorylates ERK in a single step.\nTranslated to z3:"
i = directly_phosphorylates("MEK", "ERK")
print i.get_predicate()

print "\nPredicate II: ERK, when phosphorylated, is always active.\nTranslated to z3:"
ii = phosphorylated_is_active("ERK")
print ii.get_predicate()

print "\nPredicate III: MEK directly activates ERK in a single step.\nTranslated to z3:"
iii = directly_activates("MEK", "ERK")
print iii.get_predicate()

print "\nEach of these predicates is satisfiable (True) on their own: checking..."
assert i.check_sat()
Exemplo n.º 5
0
 def test_or_unsat(self):
     p1 = predicate.Bottom()
     p2 = predicate.Bottom()
     status = predicate.Or(p1, p2)
     self.assertTrue(status)
Exemplo n.º 6
0
 def test_and_unsat(self):
     p1 = predicate.Top()
     p2 = predicate.Bottom()
     status = predicate.And(p1, p2)
     self.assertTrue(status)