@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
  public void testIsClause() {
    Var a = new Var("a");
    Var b = new Var("b");
    Var c = new Var("c");

    assertTrue(a.isClause());
    assertTrue(b.isClause());
    assertTrue(c.isClause());

    // if a and b are both clauses, then so is (a or b)
    Formula f = a.or(b);
    assertTrue(f.isClause());

    // if f is a literals and c is a literals, then so is (f or c)
    assertTrue(f.or(c).isClause());
    assertTrue(c.or(f).isClause());

    Formula g = a.and(b);
    assertFalse(g.isClause());

    assertFalse(g.or(c).isClause());
    assertFalse(c.or(g).isClause());
  }