def testPelletier(self): with open('prover/tests/pelletier.json', 'r', encoding='utf-8') as f: f_data = json.load(f) for problem in f_data: ctxt = parser.parse_vars(thy, problem['vars']) prop = parser.parse_term(thy, ctxt, problem['prop']) cnf, _ = encode.encode(logic.neg(prop)) self.assertIsNone(sat.solve_cnf(cnf))
def testPelletier(self): with open('prover/tests/pelletier.json', 'r', encoding='utf-8') as f: f_data = json.load(f) for problem in f_data: context.set_context('sat', vars=problem['vars']) prop = parser.parse_term(problem['prop']) cnf = tseitin.convert_cnf(tseitin.encode(Not(prop)).prop) res, cert = sat.solve_cnf(cnf) self.assertEqual(res, 'unsatisfiable')
def testSolveCNF5(self): cnf = [] res, cert = sat.solve_cnf(cnf) self.assertEqual(res, 'satisfiable') self.assertTrue(sat.is_solution(cnf, cert))
def testSolveCNF4(self): cnf = [[]] res, cert = sat.solve_cnf(cnf) self.assertEqual(res, 'unsatisfiable') self.assertEqual(cert, {1: [0]})
def testSolveCNF3(self): cnf = [[('x', True), ('y', True)], [('x', True), ('y', False)], [('x', False), ('y', True)], [('x', False), ('y', False)]] res, cert = sat.solve_cnf(cnf) self.assertEqual(res, 'unsatisfiable')
def testSolveCNF2(self): cnf = [[('x', True)], [('x', False)]] res, cert = sat.solve_cnf(cnf) self.assertEqual(res, 'unsatisfiable') self.assertEqual(cert, {2: [1, 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))
def testSolveCNF5(self): cnf = [] res = sat.solve_cnf(cnf) self.assertTrue(sat.is_solution(cnf, res))
def testSolveCNF4(self): cnf = [[]] self.assertIsNone(sat.solve_cnf(cnf))
def testSolveCNF3(self): cnf = [[('x', True), ('y', True)], [('x', True), ('y', False)], [('x', False), ('y', True)], [('x', False), ('y', False)]] self.assertIsNone(sat.solve_cnf(cnf))
def testSolveCNF1(self): cnf = [[('x', False), ('y', True)], [('y', False), ('z', True)]] res = sat.solve_cnf(cnf) self.assertTrue(sat.is_solution(cnf, res))