Esempio n. 1
0
    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))
Esempio n. 2
0
    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')
Esempio n. 3
0
 def testSolveCNF5(self):
     cnf = []
     res, cert = sat.solve_cnf(cnf)
     self.assertEqual(res, 'satisfiable')
     self.assertTrue(sat.is_solution(cnf, cert))
Esempio n. 4
0
 def testSolveCNF4(self):
     cnf = [[]]
     res, cert = sat.solve_cnf(cnf)
     self.assertEqual(res, 'unsatisfiable')
     self.assertEqual(cert, {1: [0]})
Esempio n. 5
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')
Esempio n. 6
0
 def testSolveCNF2(self):
     cnf = [[('x', True)], [('x', False)]]
     res, cert = sat.solve_cnf(cnf)
     self.assertEqual(res, 'unsatisfiable')
     self.assertEqual(cert, {2: [1, 0]})
Esempio n. 7
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. 8
0
 def testSolveCNF5(self):
     cnf = []
     res = sat.solve_cnf(cnf)
     self.assertTrue(sat.is_solution(cnf, res))
Esempio n. 9
0
 def testSolveCNF4(self):
     cnf = [[]]
     self.assertIsNone(sat.solve_cnf(cnf))
Esempio n. 10
0
 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))
Esempio n. 11
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))