@Test public void testToCNFDimacsClauses() { Formula a = new Var("a"); Formula b = new Var("b"); Formula c = new Var("c"); Formula f = new Formula(a.not()); assertTrue("!a".equals(f.toString())); List<IVecInt> clauses = f.toCNFDimacsClauses(); assertTrue(clauses.size() == 1); IVecInt literals = clauses.get(0); // expect {-1} array assertTrue(literals.get(0) == -1); f = new Formula(b.or(a.not()).or(c)); assertTrue("b or !a or c".equals(f.toString())); clauses = f.toCNFDimacsClauses(); assertTrue(clauses.size() == 1); literals = clauses.get(0); // expect {2, -1, 3} array assertTrue(literals.get(0) == 2); assertTrue(literals.get(1) == -1); assertTrue(literals.get(2) == 3); }
@Test(expected = org.sat4j.specs.ContradictionException.class) public void testGetModels_contradiction() throws ContradictionException, TimeoutException { Formula f = new Var("a"); Formula g = f.and(f.not()); Formula instance = Formula.newInstanceforSAT(g); }