If you have a truth table for a formula $F$, SAT solving is easy - just look for a row in which the result column has "true". If such a row exists, you can read off the satisfying interpretation, if no such row exists the formula is not satisfiable. Moreover, if the formula is UNSAT (i.e. not SAT), the truth table is a proof of that fact (though perhaps a very large proof if the truth table is large).
(a xor b) & (c xor d) & (e xor f) & (b => d) & (a => d) & (e => f) & (~(u=>(v xor w)) & ~v)
to determine whether or not it is SAT. Are you still happy
with this method for SAT-solving? What is the critical
factor in determining the size of the truth table? Can you
quantify the size dependency?
How SAT solvers like Minisat work is a fascinating topic, but one that is well outside of this course. The point is that if you can model a real-world domain in propositional logic, you can leverage the power of SAT Solvers to discover new facts about that domain.
Problem: Suppose we have Alice, Bob, Cathy and Don, and two cars - a Civic and Mustang. We have some constraints:
Our first step will be to model this problem in propositional logic. To model a problem in algebra we first state what the variables are and what they *mean* in the context of the problem we are modeling. Same with modeling in propositional logic. In fact, the name "propositional" hints at this. Each variable stands for a "proposition", a statement that is either true or false.
| variable name | proposition (meaning) | note |
|---|---|---|
| a | "Alice in Civic" | since Alice must be in one or the other, ~a means Alice is in the Mustang |
| b | "Bob in Civic" | same! |
| c | "Cathy in Civic" | same! |
| d | "Don in Civic" | same! |
So here are facts 1,2,3,4 stated in our propositional variables:
(a <=> ~b) & ( (c <=> ~d) => (a <=> ~d)) & (~c xor ~d) & (b => c)
\________/ \_________________________/ \_________/ \______/
1 2 3 4
Note: To see why
"Alice and Bob in different cars" can be modeled by
$a \Leftrightarrow \neg b$, remember that "Alice and Bob in different
cars" is equivalent to saying "$a$ and $b$ have different
values", and since there are only two possible values
(true/false), "$a$ and $b$ have different values" means
"$a$ and $b$ have opposite values" — i.e. $a \Leftrightarrow \neg b$.
We could equally well have written it as
"$\neg(a \Leftrightarrow b)$", which you can verify with the
propositional logic tool is equivalent.
This formula, which we will call $F$, is our translation of the Civic/Mustang-World problem to Propositional Logic World. Now, if we can learn anything about $F$ using the tools of propositional logic, we can reverse-translate these new facts to Civic/Mustang World, and the whole point of logic is that these reverse-translations must hold in Civic/Mustang World! So ... what can we learn about the formula $F$? If you use the tool to create a truth table (or if you just use the SAT-solver) you will find that {a=true,b=false,c=true,d=false} is a satisfying interpretation for $F$. If we map this interpretation back, we get that putting Alice and Cathy in the Civic and Bob and Don in the Mustang satisfies the constraints! Great, right? The following picture is how you want to think about this process.
Discussion:
The solution we get has Alice, Bob, Cathy
and Don all in the Mustang. What if we really want to have at
least one person in each car? How could we encode that as a
new constraint or set of constraints?
ac : true means Alice in Civic, false means Alice not in Civic
am : true means Alice in Mustang, false means Alice not in Mustang
This is great:
(ac,am) = (true,false) means Alice is in the Civic,
(ac,am) = (false,true) means Alice is in the Mustang, and
(ac,am) = (false,false) means Alice is in neither car.
However, what about (ac,am) = (true,true)? This would mean
Alice is in both cars, which we (of course) cannot allow. So we
also need to add
~(ac & am)... to our list of constraints, since this constraint disallows the situation where Alice is in both cars.
~(ac & am) & ~(bc & bm) & ~(cc & cm) & ~(dc & dm) & # nobody is in both cars at the same time
((ac | bc) => cc) & # If Alice or Bob are in the Civic, then so is Cathy
((cc xor dc) => ~(ac & bc | am & bm)) & # If Cathy or Don (but not both) are in the Civic, then Alice and Bob are in separate cars
cm & # Cathy is in the Mustang
(ac | bc | cc | dc) & (am | bm | cm | dm) # neither car is empty