Tutorial 5
Boolean SAT
Truth-function representations
Apply both techniques from Chapter 5 · Boolean SAT to each function below:
Use INPUT₁ for the input down the left and INPUT₂ for the input across the top.
- Describe each row with output 1 by a conjunction, then disjoin the descriptions to obtain DNF (glossary, opens in a new tab) .
- Exclude each row with output 0 by a disjunction, then conjoin these clauses to obtain CNF (glossary, opens in a new tab) .
- Simplify where possible. Explain why the two descriptions have the same truth-values.
| AND | 0 | 1 |
|---|---|---|
| 0 | 0 | 0 |
| 1 | 0 | 1 |
| XOR | 0 | 1 |
|---|---|---|
| 0 | 0 | 1 |
| 1 | 1 | 0 |
| XNOR | 0 | 1 |
|---|---|---|
| 0 | 1 | 0 |
| 1 | 0 | 1 |
| NOR | 0 | 1 |
|---|---|---|
| 0 | 1 | 0 |
| 1 | 0 | 0 |
Check your descriptions below. Both fully bracketed formulas and the chapter’s bracketing conventions are accepted. Equivalent answers count, provided they are in the requested normal form.
Choose a level to begin.
Solution
The descriptions read directly from the rows are:
| Function | DNF | CNF |
|---|---|---|
| AND | INPUT₁ ∧ INPUT₂ | (INPUT₁ ∨ INPUT₂) ∧ (INPUT₁ ∨ ¬INPUT₂) ∧ (¬INPUT₁ ∨ INPUT₂) |
| XOR | (¬INPUT₁ ∧ INPUT₂) ∨ (INPUT₁ ∧ ¬INPUT₂) | (INPUT₁ ∨ INPUT₂) ∧ (¬INPUT₁ ∨ ¬INPUT₂) |
| XNOR | (¬INPUT₁ ∧ ¬INPUT₂) ∨ (INPUT₁ ∧ INPUT₂) | (INPUT₁ ∨ ¬INPUT₂) ∧ (¬INPUT₁ ∨ INPUT₂) |
| NOR | ¬INPUT₁ ∧ ¬INPUT₂ | (INPUT₁ ∨ ¬INPUT₂) ∧ (¬INPUT₁ ∨ INPUT₂) ∧ (¬INPUT₁ ∨ ¬INPUT₂) |
The CNF for AND simplifies to INPUT₁ ∧ INPUT₂; that for NOR simplifies to ¬INPUT₁ ∧ ¬INPUT₂. Both are also DNFs. The XOR and XNOR descriptions already have two clauses or terms. DNF includes exactly the rows requiring 1; CNF excludes exactly the rows requiring 0. They therefore describe the same function.
Circuit representations
Read each circuit from its inputs to its lamp. Write a formula using only ¬ and ∧ to describe the lamp’s output. A default-off relay conjoins its magnet input and signal supply; a powered default-on relay negates its magnet input. Treat the fixed supply as 1.
Use the level buttons to move between the five circuits. Enter your description above the circuit; Check compares it with the lamp on every input. You can also try the switches yourself. Which descriptions are already in DNF or CNF?
Choose a level to begin.
Solution
-
The default-off relay gives INPUT₁ ∧ INPUT₂. This is both DNF and CNF.
-
The first relay gives INPUT₁ ∧ INPUT₂. The powered default-on relay negates it, giving ¬(INPUT₁ ∧ INPUT₂). This is neither normal form as written. De Morgan’s law gives ¬INPUT₁ ∨ ¬INPUT₂, which is both DNF and CNF.
-
The default-on relay gives ¬INPUT₁. This becomes the magnet input of the default-off relay, whose signal supply is INPUT₂. The output is ¬INPUT₁ ∧ INPUT₂, both DNF and CNF.
-
The first two relays give ¬(INPUT₁ ∧ INPUT₂). Conjoining this with INPUT₃ gives ¬(INPUT₁ ∧ INPUT₂) ∧ INPUT₃. De Morgan gives the CNF (¬INPUT₁ ∨ ¬INPUT₂) ∧ INPUT₃.
-
The two branches give ¬(INPUT₁ ∧ INPUT₂) and ¬(INPUT₂ ∧ INPUT₃). Their outputs feed the final default-off relay, giving ¬(INPUT₁ ∧ INPUT₂) ∧ ¬(INPUT₂ ∧ INPUT₃). De Morgan gives the CNF (¬INPUT₁ ∨ ¬INPUT₂) ∧ (¬INPUT₂ ∨ ¬INPUT₃).
Equivalence
The XNOR function returns 1 iff its inputs agree. What happens when we change the inputs, or use it to compare more than two values?
- Negate one input of SUN ↔ RAIN. Describe the resulting function using ¬, ∧, and ∨.
- Negate both inputs. How does the resulting function compare with the original? Give a formula for it.
- Find a formula which is true iff SUN, RAIN, and WIND all have the same value. Does (SUN ↔ RAIN) ↔ WIND do this? If not, give an assignment on which it fails.
The three levels show the required tables. Enter your formula in the final column heading to check it. Explain your answers on paper as well.
Choose a level to begin.
Solution
- Negating one input switches agreement and disagreement. We obtain XOR, described by (SUN ∧ ¬RAIN) ∨ (¬SUN ∧ RAIN).
- Negating both preserves agreement: ¬SUN ↔ ¬RAIN is equivalent to SUN ↔ RAIN.
- One answer is (SUN ↔ RAIN) ∧ (RAIN ↔ WIND). If both comparisons hold, all three values agree. Another is (SUN ∧ RAIN ∧ WIND) ∨ (¬SUN ∧ ¬RAIN ∧ ¬WIND). Chaining ↔ does something different: when all three values are 0, (SUN ↔ RAIN) ↔ WIND evaluates to 1 ↔ 0, hence 0. The values agree, but the chained formula is false.
Working with pseudocode
The algorithms in this chapter use a few ideas beyond the first parsing example. Practise them here before combining them in a SAT algorithm.
while condition:repeats its indented instructions while the condition holds. Something in the loop must bring us closer to stopping.empty_list()creates a list with no entries.add(list, item)adds one item at its end;add_all(list, items)adds each supplied item.first_member(pair)andsecond_member(pair)return the two members of a pair, one at a time. For example, the members of(1, 2)are 1 and 2.record_name(node, name)keeps a name beside a tree node;name_of(node)reads it back. This lets later steps use an earlier result.
Remember: = assigns a value, while == tests equality. The app prompts
explain the helpers used in each example.
-
Complete the four examples. Explain what each takes as input and returns.
-
Trace
count_down(3)by writing down which calculation steps it performs. Include the value ofnumberafter each assignment. What happens with input 0? What happens with input 3 if we remove the assignment inside the loop? -
Write a procedure
count_ones(values)which returns the number of ones in a finite list of zeros and ones. Use a counter,for, andif. Trace it on[0, 1, 1]and on an empty list. Why does it finish? -
Trace
check_pairson[(1, 2), (1, 3)]. What is incheckedafter each iteration? What would change ifreturn checkedwere indented inside the loop? -
Trace
name_partson ¬SUN ∨ RAIN, visiting the left child before the right and using fresh names u₁, u₂, … . List the nodes in visit order and their names. Does naming them alone make the original formula true?
Solution
-
The gaps, in order, are:
- Repeat while needed:
while,=. It takes a nonnegative whole number and returns 0. - Collect matching values:
empty_list,==,add. It takes a list of zeros and ones and returns a list containing its ones. - Record checked pairs:
for,in,add. It takes pairs of clause numbers, checks each, and returns the list of checked pairs. - Name the parts first:
for,if,else. It takes a parse tree, records names for its nodes, and returns the root’s name.
- Repeat while needed:
-
The successive values are 2, 1, and 0. The procedure returns 0. With input 0, the loop is skipped. Without the assignment, input 3 keeps satisfying
number > 0, so the procedure never finishes. -
One solution is:
The counter starts at 0, then has values 0, 1, and 2 after the three iterations. The answer is 2. An empty list gives 0. Each iteration handles one entry of a finite list.
-
The list is first
[(1, 2)], then[(1, 2), (1, 3)]. Areturninside the loop would finish after the first pair, leaving the second unchecked. With an empty input, that misplacedreturnwould never be reached. -
The visit order and names are SUN: SUN; ¬SUN: u₁; RAIN: RAIN; ¬SUN ∨ RAIN: u₂. The procedure returns u₂. Names alone impose no truth-value requirements. Tseytin (glossary, opens in a new tab) conversion must also add the local constraints and the root clause.
Truth tables
Use the app to construct a truth-table (glossary, opens in a new tab)
for each of the formulas shown
in its level buttons. First identify the distinct variables: enter their
names separated by commas, for example SUN, RAIN. How many rows do we need?
The app supplies these rows and the parse tree. Match each empty column heading to a compound node in the tree, working from the smallest subformulas upward. Then calculate the entries yourself. Selecting a cell highlights its subformula and shows that row’s variable values in the tree. Which formulas are satisfiable? Which are tautologies?
Choose a level to begin.
Solution
There are four rows for levels 1–4 and 6, and eight for level 5. The formulas in levels 1–5 are satisfiable; level 6 is unsatisfiable. None is a tautology (glossary, opens in a new tab) . Here are the completed tables, with variables in the same alphabetical order as the app:
Level 1:
| RAIN | SUN | ¬RAIN | SUN ∧ ¬RAIN |
|---|---|---|---|
| 0 | 0 | 1 | 0 |
| 0 | 1 | 1 | 1 |
| 1 | 0 | 0 | 0 |
| 1 | 1 | 0 | 0 |
Level 2:
| RAIN | SUN | SUN ∧ RAIN | ¬(SUN ∧ RAIN) |
|---|---|---|---|
| 0 | 0 | 0 | 1 |
| 0 | 1 | 0 | 1 |
| 1 | 0 | 0 | 1 |
| 1 | 1 | 1 | 0 |
Level 3:
| RAIN | SUN | SUN ∨ RAIN | ¬SUN | (SUN ∨ RAIN) ∧ ¬SUN |
|---|---|---|---|---|
| 0 | 0 | 0 | 1 | 0 |
| 0 | 1 | 1 | 0 | 0 |
| 1 | 0 | 1 | 1 | 1 |
| 1 | 1 | 1 | 0 | 0 |
Level 4:
| RAIN | SUN | SUN ↔ RAIN |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
Level 5:
| RAIN | SUN | WIND | ¬RAIN | ¬RAIN ∧ WIND | SUN ∨ (¬RAIN ∧ WIND) |
|---|---|---|---|---|---|
| 0 | 0 | 0 | 1 | 0 | 0 |
| 0 | 0 | 1 | 1 | 1 | 1 |
| 0 | 1 | 0 | 1 | 0 | 1 |
| 0 | 1 | 1 | 1 | 1 | 1 |
| 1 | 0 | 0 | 0 | 0 | 0 |
| 1 | 0 | 1 | 0 | 0 | 0 |
| 1 | 1 | 0 | 0 | 0 | 1 |
| 1 | 1 | 1 | 0 | 0 | 1 |
Level 6:
| RAIN | SUN | SUN ∨ RAIN | ¬SUN | (SUN ∨ RAIN) ∧ ¬SUN | ¬RAIN | (SUN ∨ RAIN) ∧ ¬SUN ∧ ¬RAIN |
|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 1 | 0 | 1 | 0 |
| 0 | 1 | 1 | 0 | 0 | 1 | 0 |
| 1 | 0 | 1 | 1 | 1 | 0 | 0 |
| 1 | 1 | 1 | 0 | 0 | 0 | 0 |
Missing truth-values
Complete the gaps. The given entries are correct. For each missing value, identify the connective whose function table determines it.
Choose a level to begin.
Select a formula above the table to change levels. Selecting a missing entry highlights the corresponding part of the parse tree.
Solution
Negation switches 0 and 1. Conjunction gives 1 iff both inputs are 1; disjunction gives 1 iff at least one is 1. The biconditional gives 1 iff its inputs agree. Applying these rules gives:
Level 1:
| RAIN | SUN | SUN ∧ RAIN | ¬(SUN ∧ RAIN) |
|---|---|---|---|
| 0 | 0 | 0 | 1 |
| 0 | 1 | 0 | 1 |
| 1 | 0 | 0 | 1 |
| 1 | 1 | 1 | 0 |
Level 2:
| RAIN | SUN | SUN ∨ RAIN | ¬SUN | (SUN ∨ RAIN) ∧ ¬SUN |
|---|---|---|---|---|
| 0 | 0 | 0 | 1 | 0 |
| 0 | 1 | 1 | 0 | 0 |
| 1 | 0 | 1 | 1 | 1 |
| 1 | 1 | 1 | 0 | 0 |
Level 3:
| RAIN | SUN | ¬RAIN | SUN ↔ ¬RAIN |
|---|---|---|---|
| 0 | 0 | 1 | 0 |
| 0 | 1 | 1 | 1 |
| 1 | 0 | 0 | 1 |
| 1 | 1 | 0 | 0 |
Level 4:
| RAIN | SUN | WIND | SUN ∧ WIND | ¬RAIN | (SUN ∧ WIND) ∨ ¬RAIN |
|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 1 | 1 |
| 0 | 0 | 1 | 0 | 1 | 1 |
| 0 | 1 | 0 | 0 | 1 | 1 |
| 0 | 1 | 1 | 1 | 1 | 1 |
| 1 | 0 | 0 | 0 | 0 | 0 |
| 1 | 0 | 1 | 0 | 0 | 0 |
| 1 | 1 | 0 | 0 | 0 | 0 |
| 1 | 1 | 1 | 1 | 0 | 1 |
Mystery formula
Find a formula for each table. Any formula with the right truth-values counts; different spellings can describe the same function. Try to find a short one. You may leave out variables that do not affect the result. Enter your formula in the final column heading. The app gives a counterexample whenever it disagrees with the table.
Choose a level to begin.
Solution
One answer for each level is:
- ¬SUN
- SUN ∧ RAIN
- SUN ∨ RAIN
- ¬(SUN ∧ RAIN)
- (SUN ∧ ¬RAIN) ∨ (¬SUN ∧ RAIN)
- SUN ↔ RAIN
- SUN ∨ ¬WIND
- (SUN ∧ RAIN) ∨ WIND
For level 7, changing RAIN never changes the result. This is why it need not occur in the answer. Reading off DNF or CNF gives an answer for every level, though it need not be the shortest one.
Normal Forms
Rewrite each formula into DNF and CNF. Name the laws you use. You may simplify repetitions, contradictions, and tautological clauses (glossary, opens in a new tab) , but these simplifications are not required merely to reach normal form.
- RAIN ∧ ¬(SUN ∨ ¬RAIN)
- ¬RAIN ∨ ¬(¬RAIN ∨ WIND)
- (RAIN ∧ ¬SUN) ∨ (¬RAIN ∧ ¬SUN)
- SUN ∨ (RAIN ∧ WIND)
- (SUN ∨ RAIN) ∧ (¬SUN ∨ WIND)
- ¬(SUN ↔ RAIN)
Solution
-
De Morgan and double negation give RAIN ∧ ¬SUN ∧ RAIN. Idempotence gives RAIN ∧ ¬SUN, both DNF and CNF.
-
De Morgan and double negation give the DNF ¬RAIN ∨ (RAIN ∧ ¬WIND). Distribution gives the CNF (¬RAIN ∨ RAIN) ∧ (¬RAIN ∨ ¬WIND). Its first clause is a tautology, so ¬RAIN ∨ ¬WIND is also an answer in both forms.
-
Factoring out ¬SUN gives (RAIN ∨ ¬RAIN) ∧ ¬SUN, equivalent to ¬SUN. This is both DNF and CNF. The original is already a DNF.
-
The original is DNF. Distribution gives the CNF (SUN ∨ RAIN) ∧ (SUN ∨ WIND).
-
The original is CNF. Distribution gives the DNF
(SUN ∧ ¬SUN) ∨ (SUN ∧ WIND) ∨ (RAIN ∧ ¬SUN) ∨ (RAIN ∧ WIND).The first term can be removed because it is always false.
-
Eliminate ↔, then push the negation inward. The result is the DNF (SUN ∧ ¬RAIN) ∨ (¬SUN ∧ RAIN). Distribution gives four clauses; discard the two tautologies to obtain the CNF (SUN ∨ RAIN) ∧ (¬SUN ∨ ¬RAIN).
Resolution
Each level starts with a CNF. Its conjuncts appear as numbered disjunctive clauses (glossary, opens in a new tab) . Select two clauses, choose one pivot (glossary, opens in a new tab) , and apply resolution (glossary, opens in a new tab) . Keep going until you derive ⊥, or until every possible resolution has been checked. In the latter case, use the Saturated? button. The app keeps the parents and records checks which give tautologies or clauses already present.
Choose a level to begin.
For each satisfiable input, also give a satisfying valuation on paper.
Solution
-
Resolve SUN ∨ RAIN with ¬SUN on SUN, obtaining RAIN. Resolve with ¬RAIN to derive ⊥.
-
Resolve the two input clauses on RAIN, obtaining SUN ∨ ¬WIND. There are no further complementary pairs. A satisfying valuation is SUN = 1, RAIN = 0, WIND = 0.
-
Resolve on WIND, obtaining ¬SUN ∨ ¬RAIN. There are no further complementary pairs. Take SUN = RAIN = WIND = 0.
-
Resolve the first two clauses on RAIN to obtain SUN, and the last two on RAIN to obtain ¬SUN. Resolving these gives ⊥.
-
No clauses contain complementary literals. The input is already saturated; take SUN = RAIN = 1.
-
Resolving on SUN gives RAIN ∨ ¬RAIN; resolving on RAIN gives SUN ∨ ¬SUN. Both are tautologies and impose no new requirement. After both checks, the input is saturated. Take SUN = 1, RAIN = 0. Removing both complementary pairs in one step would be unsound.
-
The first two clauses have two possible pivots, but either choice gives a tautology. A shorter route uses the units: resolve ¬SUN ∨ ¬RAIN with SUN to get ¬RAIN, then with RAIN to get ⊥.
-
Resolve ¬WIND ∨ SNOW with ¬SNOW to get ¬WIND. Resolving this with ¬SUN ∨ WIND and with ¬RAIN ∨ WIND gives ¬SUN and ¬RAIN. Resolve SUN ∨ RAIN with ¬SUN to get RAIN, then with ¬RAIN to get ⊥.
Countermodels after resolution
The following refutation searches are complete. Every possible resolution has been checked, and none adds a new non-tautological clause. No search derives ⊥.
For each inference, use the final clauses to find a countermodel (glossary, opens in a new tab) . Begin with any unit clauses (glossary, opens in a new tab) , then choose values for the remaining atoms. Check that all the clauses are true, all the original premises are true, and the conclusion is false. You don’t need to construct a full truth-table.
-
SUN → RAIN, ¬SUN ∴ ¬RAIN
Line Clause Source 1 ¬SUN ∨ RAIN First premise 2 ¬SUN Second premise 3 RAIN Negated conclusion There are no complementary literals between clauses.
-
SUN ↔ RAIN ∴ SUN
Line Clause Source 1 ¬SUN ∨ RAIN Premise, in CNF 2 SUN ∨ ¬RAIN Premise, in CNF 3 ¬SUN Negated conclusion 4 ¬RAIN Lines 2 and 3, pivot SUN The other resolutions produce tautologies or clauses already listed.
-
SUN ∨ RAIN ∴ SUN ∧ RAIN
Line Clause Source 1 SUN ∨ RAIN Premise 2 ¬SUN ∨ ¬RAIN Negated conclusion, in CNF Resolving on either variable gives a tautology. There are no unit clauses. Find both countermodels. Why does setting both atoms false fail? Why does setting both true fail?
Would finding no contradiction after just a few resolution steps have been enough to conclude that these inferences are invalid? Explain.
Solution
- Line 2 fixes SUN = 0; line 3 fixes RAIN = 1. Line 1 is true because both its literals are true. In the original inference, SUN → RAIN and ¬SUN are true, but ¬RAIN is false.
- Line 3 fixes SUN = 0. Line 2 then requires RAIN = 0, which line 4 also tells us. Line 1 is true because ¬SUN is true. The two atoms agree, so the premise SUN ↔ RAIN is true, while the conclusion SUN is false.
- The first clause requires at least one atom to be true. The second requires at least one to be false. Choose SUN = 1, RAIN = 0, or SUN = 0, RAIN = 1. Each choice makes the premise true and the conclusion false. Setting both false violates line 1; setting both true violates line 2. We cannot choose values independently for each clause: one valuation must satisfy them all.
An unfinished search might still derive ⊥ later. Saturation without ⊥ establishes satisfiability; a checked countermodel directly establishes invalidity, even if we haven’t completed the search.
Valid inference
Check each inference shown in the app by truth-table and by resolution. Decide which SAT problem will tell you whether the inference is valid. For an invalid inference, give a countermodel (glossary, opens in a new tab) .
For resolution, convert your SAT formula to CNF and enter its clauses in
the input field. You can join them with ∧, or separate them with commas.
For example, (SUN ∨ RAIN), ¬SUN supplies two clauses. The app checks
that your clauses express the right SAT problem; you then choose the
resolution steps yourself.
Choose a level to begin.
You may use the rewriting app below to help with conversion. Decide which formula to put in before you start.
CNF rewriting
Text tree
Solution
-
Test ¬RAIN ∧ ¬(RAIN ∨ (¬RAIN ∧ SUN)). Its CNF simplifies to ¬RAIN ∧ (RAIN ∨ ¬SUN). Resolution gives ¬SUN and then saturates (glossary, opens in a new tab) . The countermodel RAIN = SUN = 0 makes the premise true and conclusion false.
-
Test (RAIN ∨ (RAIN ∧ WIND)) ∧ ¬(RAIN ∨ SUN). Its CNF is RAIN ∧ (RAIN ∨ WIND) ∧ ¬RAIN ∧ ¬SUN. Resolve RAIN and ¬RAIN to obtain ⊥. The inference is valid.
-
The SAT formula is already CNF: (SUN ∨ RAIN) ∧ (¬SUN ∨ WIND) ∧ (¬RAIN ∨ WIND) ∧ ¬WIND. Resolve the second and third clauses with ¬WIND to get ¬SUN and ¬RAIN. These refute the first clause. The inference is valid.
-
The CNF is (SUN ∨ RAIN) ∧ (¬SUN ∨ WIND) ∧ ¬WIND. Resolution gives ¬SUN, then RAIN, and saturates. Take SUN = WIND = 0 and RAIN = 1: both premises are true, but the conclusion is false.
-
The CNF is (SUN ∨ RAIN) ∧ (¬SUN ∨ WIND) ∧ (¬RAIN ∨ SNOW) ∧ ¬WIND ∧ ¬SNOW. The last two clauses give ¬SUN and ¬RAIN by resolution with the second and third. These refute SUN ∨ RAIN. The inference is valid.
For the truth-table check, the final columns of these two SAT formulas are as follows. A 1 marks a countermodel:
| RAIN | SUN | First SAT formula |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 0 |
The second SAT formula is 0 on all eight assignments to RAIN, SUN, and WIND: its first part requires RAIN = 1, while its second requires RAIN = 0. The third and fifth SAT formulas are likewise always 0. The fourth has just one satisfying row: RAIN = 1, SUN = WIND = 0.
Comparing the algorithms
- Does resolution always outperform truth-table search? Explain the difference between a worst-case bound and the work on a particular input.
- Suppose truth-table search tries the all-zero assignment first. Compare it with resolution on (¬SUN ∨ RAIN) ∧ (SUN ∨ ¬RAIN) and on ¬SUN ∨ ¬RAIN. Count rows examined and resolution steps separately. Is that enough to compare running times?
- A formula has 10 variables. How many rows does its full table have? What if we add 5 variables? Must a SAT search always examine them all?
- Why can an input with few symbols still be expensive to prepare for resolution? Use (SUN ∧ WARM) ∨ (RAIN ∧ WIND) as a starting point.
Solution
- No. Both algorithms have expensive worst cases, but that does not determine which is faster on a given input. Resolution may find a short refutation; truth-table search may find a satisfying row early. General results about SAT do not give all algorithms identical costs.
- For the first formula, 00 already succeeds, so truth-table search examines one row. Resolution checks the two pivots; both resolvents are tautologies, so it saturates. For the second formula, the first row already satisfies it. Resolution has one clause and no pair to examine. Neither count includes all the work: parsing, evaluation, CNF preparation, and finding or checking clause pairs also take time. These examples give no universal speed ranking.
- The tables have 2¹⁰ = 1024 and 2¹⁵ = 32768 rows, respectively. A SAT search can stop at a satisfying row. If none exists, the chapter’s straightforward table search examines every row.
- Distribution copies parts of formulas. The displayed input gives four CNF clauses. Adding another disjunct consisting of two fresh atoms doubles this to eight. With n such pairs, there are 2ⁿ clauses, although the input grows only by one pair at a time.
Tseytin transformation
Apply the Tseytin transformation (glossary, opens in a new tab) to the formulas below. Work from the leaves upward, visiting the left child before the right. Use fresh names u₁, u₂, … in that order. Write the local constraints and the final clause which requires the root to be true.
- ¬(SUN ∧ RAIN)
- (SUN ∨ RAIN) ∧ ¬WIND
- (SUN ∧ RAIN) ∨ (¬SUN ∧ WIND)
- (SUN ∧ RAIN) ∨ (WIND ∧ SNOW)
- (SUN ∨ RAIN) ∧ (¬SUN ∧ ¬RAIN)
For each satisfiable formula, extend one satisfying valuation to the fresh variables. Explain why we cannot omit the final root clause, and why the result is equisatisfiable (glossary, opens in a new tab) rather than logically equivalent over the expanded vocabulary. For formula 4, also compare the result with the CNF obtained by distribution: which uses fewer clauses here? What if we keep adding disjuncts consisting of two fresh atoms?
Solution
Each row below gives one naming step and its local constraints. Conjoin all the constraints for that formula and add the stated root clause.
-
For ¬(SUN ∧ RAIN):
Name Subformula, using earlier names Local constraints u₁ SUN ∧ RAIN (¬u₁ ∨ SUN) ∧ (¬u₁ ∨ RAIN) ∧ (u₁ ∨ ¬SUN ∨ ¬RAIN) u₂ ¬u₁ (¬u₂ ∨ ¬u₁) ∧ (u₂ ∨ u₁) Add the root clause u₂. Take SUN = RAIN = 0, u₁ = 0, and u₂ = 1.
-
For (SUN ∨ RAIN) ∧ ¬WIND:
Name Subformula, using earlier names Local constraints u₁ SUN ∨ RAIN (u₁ ∨ ¬SUN) ∧ (u₁ ∨ ¬RAIN) ∧ (¬u₁ ∨ SUN ∨ RAIN) u₂ ¬WIND (¬u₂ ∨ ¬WIND) ∧ (u₂ ∨ WIND) u₃ u₁ ∧ u₂ (¬u₃ ∨ u₁) ∧ (¬u₃ ∨ u₂) ∧ (u₃ ∨ ¬u₁ ∨ ¬u₂) Add the root clause u₃. Take SUN = 1, RAIN = WIND = 0, and u₁ = u₂ = u₃ = 1.
-
For (SUN ∧ RAIN) ∨ (¬SUN ∧ WIND):
Name Subformula, using earlier names Local constraints u₁ SUN ∧ RAIN (¬u₁ ∨ SUN) ∧ (¬u₁ ∨ RAIN) ∧ (u₁ ∨ ¬SUN ∨ ¬RAIN) u₂ ¬SUN (¬u₂ ∨ ¬SUN) ∧ (u₂ ∨ SUN) u₃ u₂ ∧ WIND (¬u₃ ∨ u₂) ∧ (¬u₃ ∨ WIND) ∧ (u₃ ∨ ¬u₂ ∨ ¬WIND) u₄ u₁ ∨ u₃ (u₄ ∨ ¬u₁) ∧ (u₄ ∨ ¬u₃) ∧ (¬u₄ ∨ u₁ ∨ u₃) Add the root clause u₄. Take SUN = RAIN = 0, WIND = 1, u₁ = 0, and u₂ = u₃ = u₄ = 1.
-
For (SUN ∧ RAIN) ∨ (WIND ∧ SNOW):
Name Subformula, using earlier names Local constraints u₁ SUN ∧ RAIN (¬u₁ ∨ SUN) ∧ (¬u₁ ∨ RAIN) ∧ (u₁ ∨ ¬SUN ∨ ¬RAIN) u₂ WIND ∧ SNOW (¬u₂ ∨ WIND) ∧ (¬u₂ ∨ SNOW) ∧ (u₂ ∨ ¬WIND ∨ ¬SNOW) u₃ u₁ ∨ u₂ (u₃ ∨ ¬u₁) ∧ (u₃ ∨ ¬u₂) ∧ (¬u₃ ∨ u₁ ∨ u₂) Add the root clause u₃. Take SUN = RAIN = 1, WIND = SNOW = 0, u₁ = u₃ = 1, and u₂ = 0.
-
For (SUN ∨ RAIN) ∧ (¬SUN ∧ ¬RAIN):
Name Subformula, using earlier names Local constraints u₁ SUN ∨ RAIN (u₁ ∨ ¬SUN) ∧ (u₁ ∨ ¬RAIN) ∧ (¬u₁ ∨ SUN ∨ RAIN) u₂ ¬SUN (¬u₂ ∨ ¬SUN) ∧ (u₂ ∨ SUN) u₃ ¬RAIN (¬u₃ ∨ ¬RAIN) ∧ (u₃ ∨ RAIN) u₄ u₂ ∧ u₃ (¬u₄ ∨ u₂) ∧ (¬u₄ ∨ u₃) ∧ (u₄ ∨ ¬u₂ ∨ ¬u₃) u₅ u₁ ∧ u₄ (¬u₅ ∨ u₁) ∧ (¬u₅ ∨ u₄) ∧ (u₅ ∨ ¬u₁ ∨ ¬u₄) Add the root clause u₅. The root requires both u₁ = 1 and u₄ = 1. The latter requires u₂ = u₃ = 1, hence SUN = RAIN = 0. But this makes u₁ = 0. There is no satisfying valuation.
For formula 4, distribution gives just four clauses:
Tseytin uses ten clauses here, so it is not the shorter answer on this input. With n disjuncts each containing two fresh atoms, distribution gives 2ⁿ clauses. Tseytin gives 3(2n - 1) + 1 = 6n - 2 clauses: three for each of the n conjunctions and n - 1 disjunctions, plus the root. The difference matters as n grows.
Without the root clause, all five groups of local constraints are satisfiable: assign each name the calculated value of its subformula, even when the whole formula is false. The original formulas say nothing about the fresh names, whereas the constraints restrict them. Every satisfying valuation of the original can be extended to satisfy the encoding; every model of the encoding restricts to a model of the original. That gives equisatisfiability. For the first four formulas, arbitrary values of the fresh variables can violate the encoding while the original remains true, so they are not logically equivalent over the expanded vocabulary. The fifth is a special case: both formulas are unsatisfiable, and hence equivalent.