Ejemplo n.º 1
0
 def test_one_hole(self):
     dimacs = """\
     p cnf 0 0
     """
     for functional in (True,False):
             F = PigeonholePrinciple(0,1,functional,False)
             self.assertCnfEqualsDimacs(F,dimacs)
Ejemplo n.º 2
0
 def test_empty(self):
     dimacs = """\
     p cnf 0 0
     """
     for functional in (True,False):
         for onto in (True,False):
             F = PigeonholePrinciple(0,0,functional,onto)
             self.assertCnfEqualsDimacs(F,dimacs)
Ejemplo n.º 3
0
 def test_one_pigeon_one_hole_onto(self):
     dimacs = """\
     p cnf 1 2
     1 0
     1 0
     """
     for functional in (True,False):
             F = PigeonholePrinciple(1,1,functional,True)
             self.assertCnfEqualsDimacs(F,dimacs)
Ejemplo n.º 4
0
 def test_complete(self):
     for pigeons in range(2,5):
         for holes in range(2,5):
             for functional in (True,False):
                 for onto in (True,False):
                     graph = complete_bipartite_graph_proper(pigeons,holes)
                     F = GraphPigeonholePrinciple(graph,functional,onto)
                     G = PigeonholePrinciple(pigeons,holes,functional,onto)
                     self.assertCnfEquivalentModuloVariables(F,G)
Ejemplo n.º 5
0
 def test_parameters(self):
     for pigeons in range(2,5):
         for holes in range(2,5):
             for functional in (True,False):
                 for onto in (True,False):
                     parameters = ["cnfgen","-q","php", pigeons, holes]
                     if functional : parameters.append("--functional")
                     if onto : parameters.append("--onto")
                     F = PigeonholePrinciple(pigeons,holes,functional,onto)
                     self.checkFormula(sys.stdin,F, parameters)
Ejemplo n.º 6
0
 def test_two_pigeons_three_holes(self):
     F = PigeonholePrinciple(2,3,False,False)
     dimacs = """\
     p cnf 6 5
     1 2 3 0
     4 5 6 0
     -1 -4 0
     -2 -5 0
     -3 -6 0
     """
     self.assertCnfEqualsDimacs(F,dimacs)
Ejemplo n.º 7
0
 def test_two_pigeons_two_holes_functional(self):
     F = PigeonholePrinciple(2,2,True,False)
     dimacs = """\
     p cnf 4 6
     1 2 0
     3 4 0
     -1 -3 0
     -2 -4 0
     -1 -2 0
     -3 -4 0
     """
     self.assertCnfEqualsDimacs(F,dimacs)