Esempio n. 1
0
    def testIsSolution(self):
        cnf = [[('x', False), ('y', True)], [('y', False), ('z', True)]]

        inst1 = {'x': True, 'y': True, 'z': True}
        self.assertTrue(sat.is_solution(cnf, inst1))

        inst2 = {'x': False, 'y': True, 'z': True}
        self.assertTrue(sat.is_solution(cnf, inst2))

        inst3 = {'x': True, 'y': False, 'z': True}
        self.assertFalse(sat.is_solution(cnf, inst3))

        inst4 = dict()
        self.assertRaises(sat.SATSolverException, sat.is_solution, cnf, inst4)
Esempio n. 2
0
 def testSolveCNF5(self):
     cnf = []
     res, cert = sat.solve_cnf(cnf)
     self.assertEqual(res, 'satisfiable')
     self.assertTrue(sat.is_solution(cnf, cert))
Esempio n. 3
0
 def testSolveCNF1(self):
     cnf = [[('x', False), ('y', True)], [('y', False), ('z', True)]]
     res, cert = sat.solve_cnf(cnf)
     self.assertEqual(res, 'satisfiable')
     self.assertTrue(sat.is_solution(cnf, cert))
Esempio n. 4
0
 def testSolveCNF5(self):
     cnf = []
     res = sat.solve_cnf(cnf)
     self.assertTrue(sat.is_solution(cnf, res))
Esempio n. 5
0
 def testSolveCNF1(self):
     cnf = [[('x', False), ('y', True)], [('y', False), ('z', True)]]
     res = sat.solve_cnf(cnf)
     self.assertTrue(sat.is_solution(cnf, res))