SAT Exercises
SAT Exercises
3. Write the truth table of the following two formula (p ∧ ¬(q ∨ r)) and (¬p ∨ (q ∨ r)). Say for each
one if it is a tautology, satisfiable or contradiction. Say if one is a logical consequence of the
other
4. Let F and G be two formula. Is it true that F ∨ G is a tautology iff one of them is a tautology?
5. Find three formula F 1, F 2, and F 3 such that F 1 ∧ F 2 ∧ F 3 is unsatisfiable and such that the
conjunction of any pair of them is satisfiable
11. Write a satisfying interpretation and a non-satisfying interpretation for the following formula,
14. Let F = ¬(¬p ∧ ¬q ∧ ¬r) ∧ (¬p ∨ q ∨ r) and G = q ∨ r. Say which one of the following properties
hold: F |= G, G |= F , F ≡ G, F ∧ ¬G is a tautology, F ∧ ¬G is a contradiction, ¬F ∨ G is a
tautology, ¬F ∨ G is a contradiction.
15. Is the following statement true? (provide a justification for your answer). If F → G is satisfiable
and F is satisfiable, then G is satisfiable.
17. Transform the following sentence into CNF using two methods: i) via distributivity, ii) via
Tseitin.
F = ¬p ∧ q ∨ ¬(¬r ∨ ¬q)
18. A boolean formula is in disjunctive normal form (DNF) if it is a disjunction of one or more
conjunctions of one or more literals (e.g. (x ∧ ¬y ∧ z) ∨ (¬x ∧ z) ∨ (w ∧ y ∧ ¬z) ). Contradictory
conjunctions (i.e, containing a literal and its negation xi ∧ ¬xi ,) are not permitted. Say wether
the following statements are true or not:
19. Show that there is a polynomial algorithm that says if a DNF formula is satisfiable or not.
Solution: To satisfy a DNF formula, all we need is to satisfy one conjunction of literals and
the disjunction is satisied. Traverse the firs conjunction and assign 0 to all variables that appear
with ¬ sign, assign 1 to all variables without ¬ sign, assign arbitrary values to all variables that
do not appear in the clause at all.
20. Show how to transform a CNF formula into an equivalent DNF formula using the distributive
law. What is the size of the resulting DNF formula ?
Solution:
A CNF formula with m size-3 clauses is converted into a DNF formula with 3m disjunctions
22. Use resolution to prove that p → q is a logical consequence of ((t → q) ∧ (¬r → ¬s) ∧ (p →
u) ∧ (¬t → ¬r) ∧ (u → s))
23. Prove with resolution that the following formulas are tautologies:
• p → (q → p)
• (p ∧ (p → q)) → q
• ((p → q) ∧ ¬q) → ¬p
• ((p → q) ∧ ¬q) → ¬q
24. A unary clause is a clause containing only one literal (i.e. p or ¬p). Unit resolution is resolution
restricted to pairs of clauses in which at least one of them is a unary clause. Is unit resolution
correct? is refutationally complete?
25. A binary clause is a clause with no more than two literals. Binary resolution is resolution
restricted to pairs of binary clauses (i.e. from p ∨ q and ¬p ∨ r we obtain q ∨ r).
26. Let (x1 , x2 , ..., xn ) be an ordered list of propositional variables. Write Formulas (and tell their
size) with the following meanings:
27. The K-coloring problem: given a graph G and a natural number K, assign to each vertex of G
a natural between 1 and K such that adjacent vertices do not have the same number. Express
the problem in CNF.
28. There are N towns each one having a local radio station. We have to assing a radio frequency out
of Q available ones to each radio station. To avoid interferences, towns closer than 20Km can
not use the same frequency. We have a function Distance(i,j) indicating the distance between
town i and j. Is it possible to assign the frequencies? Express the problem in CNF.
29. A judge must form a jury of k people. No one in the jury should know any other member. There
are n candidates and Knows(i,j) is a boolean predicate telling whether i knows j. Express the
problem in CNF
30. Let G = (V, E) be an undirected graph. We would like to know if G is connected. Model this
problem with propositional logic. Hint: a graph is connected iff for all non-empty A ⊂ V there
are edges between A and V − A.
33. Three students A, B and C are accused of introducing a virus in the school lab. During the
interrogation they make the following claims:
Solution: To answer the following questions it is convenient to write the truth table of the
following formula
B ∧ ¬C ∧ (¬A ∨ C) ∧ ¬C ∧ (A ∨ B)
where A, B, C means being guilty. Note that the formula represents the conjunction of the three
claims.
34. Consider a chess-board (the size is 8 by 8), and 8 queens. Is it possible to place the queens in
the board in such a way that they do not attack each other?. Recall that, according to chess
rules, queens can move any number of cells along rows, columns or diagonals.
Write a propositional logic formula such that from its models, we can easily compute solutions
to the previous problem.
Solution: I use variables xij to indicate that there is a queen in cell (i, j)
I need the following constraints (indices are bounded as appropriate):
∀i 6= i′ , j, ¬xij ∨ ¬xi′ j
• For every pair of cells in the same diagonal, no two queens can be placed there
∀i, j, i′ , j ′ such that (i, j) 6= (i′ , j ′ ) and |i − i′ | = |j − j ′ |
¬xij ∨ ¬xi′ j ′
35. Supose that you have a SAT-solver, such as Minisat, available (what you have available is the
executable, not the source code). What would you do if you want to know the number of models
of a CNF formula F ? (This problem is usually called Model Counting or #SAT)
Solution: The idea is to execute the SAT-solver sequentially. At each iteration, if the SAT-
solver returns a solution we add to the formula a new clause forbidding that solution. We repeat
this process until the formula becomes unsatisfiable. The number of iterations will be the number
of solutions of the original formula. In algorithmic form, Assuming SAT − Solver(F ) returns
one model of F ,
c:=0
while SAT-Solver(F)<> Nil do
(l1, l2,...,ln):=SAT-Solver(F)
F:= F and (no l1 or no l2 or ... or no ln)
c++
endwhile
36. Supose that you have a SAT-solver, such as Minisat, available (what you have available is the
executable, not the source code). Supose as well that you have an unsatifiable CNF formula F .
What would you do if you want to know if it is possible to satisfy at least k clauses? and if
you want to know the maximum number of clauses that can be satisfied? (this is the so-called
MAX-SAT problem)
37. Let G = (V, E) be an undirected graph. A cut of size 1 exists if there is a A ⊂ V such that
exactly one edge goes between A and V − A. We would like to know if G contains a cut of size
larger than k (this is the so-called Max-CUT problem)
38. Let G = (V, E) be an undirected graph. A clique of size k exists if there is a A ⊂ V such that
|A| = k and all the vertices in A are pairwise connected by an edge. We would like to know if G
contains a clique of size larger than or equal to k (this is the so-called Max-CLIQUE problem)