This is an old revision of the document!


Lab 10: SAT

0. Recap Conjunctive Normal

CNF is a form of boolean logic formulae that consists of a conjunction of one or more clauses. A clause is a disjunction of literals.

A good analogy for conjunction is product and for disjunction is sum. Thus, a formula in CNF can be seen as a product of sums.

Examples of terminals:

  • $ X, Y, Z, a, b, X_{1}, X_{2}, \ldots, X_{n}$

Examples of disjunctions:

  • $ X\vee Y\vee Z$
  • $ a\vee b$
  • $ X_{1}\vee X_{2}\vee X_{3}\vee \ldots \vee X_{n - 1}\vee X_{n}$

Examples of conjunctions:

  • $ a\wedge b\wedge c$
  • $ X\wedge Z$

Examples of CNF:

  • $ a\wedge (b\vee c)\wedge d$
  • $ (X_{1}\vee X_{2})\wedge (Y_{1}\vee Y_{2})\wedge (Z_{1}\vee Z_{2})$
  • $ (X\vee Y)\wedge (Y\vee Z)\wedge (Z\vee X)$


1. Conjunctive Normal Form

Rewrite the following formulae in Conjunctive Normal Form:

1.1. $ \neg (a\leftrightarrow b)\wedge (b\vee c)$

1.2. $ \neg ((a\vee c)\to (b \wedge \neg (a\vee c)))$


2. Interpretations

2.1. Write an interpretation which makes each of the previous formulae:

  • true
  • false


3. Satisfiability and validity

Write down a formula with 3 variables which is:

  • valid
  • satisfiable
  • invalid


4. Binary Decision Diagrams

Write binary decision diagrams for the formulae at 1.


5. Encodings

5.1. Express the following as CNF SAT formulae:

  • $ a\oplus b$ (xor)
  • if c then t else p
  • exactly one of $ {X_{1}, X_{2}, \ldots, X_{n}}$ is true.

5.2. Encode the n-queens problem as a SAT formula. In the n-queens problem, we have a n x n board and we need to find a position for each n queens such that no queen is attacking another.

5.3. What is 3SAT ? Construct a transformation that takes a SAT formula and builds a 3SAT formula. Motivation: a lot of SAT solvers use as input 3SAT .