예제 #1
0
    def __init__(self, direct_subclasses=None, any_also_is_bottom=True):
        """Construct.

    Args:
      direct_subclasses: A dictionary, mapping pytd.Type to lists of pytd.Type.
      any_also_is_bottom: Whether we should, (if True) consider
        pytd.AnythingType() to also be at the bottom of the type hierarchy,
        thus making it a subclass of everything, or (if False) to be only
        at the top.
    """
        self.direct_subclasses = direct_subclasses or {}
        self.any_also_is_bottom = any_also_is_bottom
        self.solver = booleq.Solver()
        self._implications = {}
예제 #2
0
 def testNested(self):
     solver = booleq.Solver()
     solver.register_variable("x")
     solver.register_variable("y")
     solver.register_variable("z")
     solver.implies(Eq("x", "b"), Eq("y", "b"))
     solver.implies(Eq("x", "d"), Eq("y", "z"))
     solver.implies(Eq("x", "e"), Eq("y", "e"))
     solver.implies(Eq("y", "a"), TRUE)
     solver.implies(Eq("y", "b"), TRUE)
     solver.implies(Eq("y", "d"), FALSE)
     solver.implies(Eq("y", "e"), FALSE)
     m = solver.solve()
     six.assertCountEqual(self, m["z"], {"a", "b"})
예제 #3
0
 def testConjunction(self):
     solver = booleq.Solver()
     solver.register_variable("x")
     solver.register_variable("y")
     solver.register_variable("y.T")
     solver.register_variable("z")
     solver.register_variable("z.T")
     solver.register_variable("w")
     solver.implies(Eq("x", "1"), And([Eq("y", "2"), Eq("y.T", "1")]))
     solver.implies(Eq("y", "2"), And([Eq("z", "3"), Eq("z.T", "y.T")]))
     solver.implies(Eq("z", "3"), Eq("w", "z.T"))
     solver.implies(Eq("w", "1"), TRUE)
     solver.implies(Eq("w", "4"), TRUE)
     m = solver.solve()
     six.assertCountEqual(self, m["x"], {"1"})
     six.assertCountEqual(self, m["y"], {"2"})
     six.assertCountEqual(self, m["z"], {"3"})
     six.assertCountEqual(self, m["z.T"], {"1"})
     self.assertIn("1", m["y.T"])
     self.assertNotIn("4", m["y.T"])
예제 #4
0
 def _MakeSolver(self, variables=("x", "y")):
     solver = booleq.Solver()
     for variable in variables:
         solver.register_variable(variable)
     return solver
예제 #5
0
 def __init__(self, direct_subclasses=None):
     self.direct_subclasses = direct_subclasses or {}
     self.solver = booleq.Solver()
     self._implications = {}