Maps to: Stanford CS 257 Introduction to Automated Reasoning (Winter 2026), Lecture 1 · Tue 01/06/2026 · Propositional Logic: syntax, semantics, satisfiability and validity (Caroline Trippel). Reading: Bradley & Manna, The Calculus of Computation (CC) §1.1–1.5; Enderton, A Mathematical Introduction to Logic (MI) §1.0–1.2. Basis: The Stanford slides are on Canvas and not public. This lecture follows the official topic list and reading, and the public deck Propositional Logic Basics of the Iowa course CS:4980 (Cesare Tinelli, Spring 2024), which states that it is adapted from slides by Clark Barrett, Caroline Trippel and Andrew (Haoze) Wu at Stanford. “The slides” below means that deck. Its examples are reused here:
- the formula α = (p ∧ q) ⇒ (p ∨ ¬q) and its truth table;
- “1 + 1 = 10” read in decimal and in binary;
- closed and generated sets;
- the two semantic-argument proofs;
- the Hilbert system H2.
The reading adds substitution (CC §1.5) and the induction principle (MI §1.2). These notes add the reasoning behind every definition, proofs of soundness, completeness and termination for the semantic-argument method, functional completeness via Post’s invariants, and five experiments that make each idea measurable. The experiments and their code were designed for these notes and do not reflect what was said in class. Code:
code/lecture01/(5 scripts + 4 modules; Python standard library only, matplotlib optional; from under a second to about 15 seconds each) Reading time: 4–5 hours including running the code
0. How to read this lecture
0.1 Learning goals
After this lecture you should be able to:
- Say what automated reasoning is, why it needs a formal language, and name a few places where it is used at industrial scale today.
- Define the syntax of propositional logic inductively, explain what precedence conventions abbreviate, and draw the parse tree of a formula.
- Prove properties of all formulas by structural induction, and define functions on formulas by structural recursion.
- Define the semantics of propositional logic (interpretations, compositional evaluation) and compute truth tables.
- Classify formulas as satisfiable, falsifiable, valid or unsatisfiable; decide entailment and equivalence; and explain why a single SAT procedure decides all of them (the duality theorems).
- Use substitution correctly: valid templates and substitution of equivalents (CC §1.5).
- Explain which sets of connectives are functionally complete, and prove that a set is not complete by finding an invariant.
- Run two decision procedures by hand — truth tables and semantic arguments — and argue why the latter is sound, complete and terminating.
- Translate English sentences, puzzles and small engineering questions (circuit equivalence) into formulas, and validate an encoding by counting its models.
- Explain, with measured numbers, why brute force hits an exponential wall — the motivation for the rest of the course.
0.2 Prerequisites and scope
The official prerequisite is CS154 (theory of computation), or CS103 + CS106B. This lecture needs much less:
| Assumed | Introduced here | Developed later |
|---|---|---|
| sets, functions, proof by induction on natural numbers | inductive definitions, structural induction and recursion | induction over derivations (Lecture 3) |
| “and”, “or”, “not” in everyday reasoning | the five connectives, truth tables, interpretations | first-order logic (Lectures 6–8) |
| a little Python | formulas as trees, a parser, bit-parallel truth tables | CNF, DIMACS, SAT solvers (Lectures 2, 4, 5) |
| what “NP-complete” roughly means (helpful, not required) | decision procedures, soundness, completeness | proof systems in general (Lecture 3) |
If you have never proved anything by induction, read §3 slowly; the rest of the course depends on it.
0.3 Map
§1 what automated reasoning is; why a formal language; history; applications
§2 syntax: alphabet, formula-building operators, inductive definitions, conventions, parse trees ← code 01
§3 structural induction and recursion; infinitely many formulas, finitely many meanings ← code 01
§4 semantics: interpretations, compositional evaluation, truth tables ← code 02
§5 satisfiability, validity, entailment, equivalence; duality ← code 02
§6 substitution: valid templates, substitution of equivalents, useful tautologies ← code 02
§7 how many connectives do we need? functional completeness and invariants ← code 03
§8 decision procedures: truth tables vs semantic arguments; soundness, completeness, cost ← code 04
§9 a glimpse of deductive (Hilbert) systems
§10 modeling with propositional logic, and the exponential wall ← code 05
§11 summary §12 common pitfalls §13 exercises §14 further reading §15 next lecture
Suggested order: §1 → §2 → run 01 (Parts 1–3) → §3 → run 01 (Parts 4–5) → §4–§6 → run 02 → §7 → run 03 → §8 → run 04 → §9 → §10 → run 05.
0.4 Notation (used throughout the course)
| Symbol | Meaning |
|---|---|
| propositional variables (atoms) | |
| , | the constants true and false |
| not, and, or, implies, if and only if (connectives of the language) | |
| , also | arbitrary formulas (metavariables: they are not symbols of the language) |
| or | an interpretation (variable assignment): variables → {true, false} |
| satisfies ( is true under ); : falsifies | |
| the set of formulas entails ; : is valid | |
| and are logically equivalent | |
| is provable from in some proof system (§9) | |
| the result of applying substitution to (§6) |
In code and terminal output, the same symbols appear in Unicode (¬ ∧ ∨ ⇒ ⇔ ⊤ ⊥ ⊨ ⊭); the parser also accepts ASCII (~ & | -> <->).
0.5 About CS 257
- Staff (Winter 2026): Caroline Trippel (faculty instructor), Hanna Lachnitt (student instructor), Rachel Cleaveland (TA).
- Guest lectures: Clark Barrett, Leonardo de Moura, Mathias Preiner and Nina Narodytska.
- Arc of the course: propositional logic and SAT; first-order logic and resolution; then first-order theories (arithmetic, arrays, bit-vectors, strings) and SMT solving; applications throughout (model checking, symbolic execution, proof assistants, SQL verification, program synthesis).
- Coursework: three written homeworks (two with programming parts), a take-home midterm covering lectures 1–10, and a team project.
- Learning objectives (from the course page): understand logical languages for encoding decision problems; understand and prove properties of the standard procedures (CDCL, DPLL(T), simplex, Nelson–Oppen); see their role in verification and synthesis; get hands-on experience with tools; get exposure to research.
0.6 The code of this course: build the reasoner yourself
Industrial solvers (MiniSat, CaDiCaL, Z3, cvc5) are large and fast. This course instead builds its own small reasoning stack, lecture by lecture, in plain Python, so that every algorithm can be read, traced and modified. Lecture 1 lays the foundation:
logic.py— formulas as immutable trees; a parser that accepts both Unicode and ASCII; printers (minimal parentheses, the official fully parenthesized syntax, ASCII, drawn trees); evaluation; and the truth-table method, implemented bit-parallel so that one Python integer holds a whole truth-table column (§8.3). Also substitution, random formulas and formula counting.semantic_argument.py— the semantic-argument (tableau) method with printable, numbered proof trees, three strategies, an optional improvement, and a self-check that every counterexample really is one.
Every later lecture imports these instead of re-implementing them: CNF conversion in Lecture 2, DPLL in Lecture 4, CDCL in Lecture 5, bit-blasting in Lecture 16.
1. What is automated reasoning?
1.1 Inference, made mechanical
Reasoning means deriving consequences: from “if it rains, the street is wet” and “it rains”, conclude “the street is wet”. People do this informally and make mistakes; the goal of automated reasoning is to make a machine do it, reliably (never conclude something false) and fast.
The slides put it in one line: automated reasoning tries to automate the process of inference, deriving consequences of a given set of statements, where both the given and the derived knowledge are expressed in a formal language.
Three examples of the questions such a machine answers:
| Question | As a reasoning problem |
|---|---|
| Does this 64-bit adder circuit compute for all inputs? | Is “output ≠ ” unsatisfiable? (§10.4) |
| Can these 7 regions be colored with 3 colors so that neighbours differ? | Is the coloring formula satisfiable? (§10.3) |
| A says “B is a knave”, B says “A and C are of the same kind”. What is C? | Does the knowledge base entail “C is a knave”? (§10.2) |
All three have the same shape: is there an assignment of values that makes these constraints true? That question — satisfiability — is the backbone of this course.
1.2 Why a formal language?
English is ambiguous:
- “You may have cake or ice cream” — one, or possibly both?
- “I saw the man with the telescope” — who has the telescope?
A machine cannot reason reliably about sentences whose meaning is not fixed. A formal language has a precisely defined set of sentences (its syntax) and a precisely defined meaning for each one (its semantics). Its statements are also machine-processable: a program can read them, take them apart and compute with them.
The slides name the three ingredients of a formal logic:
| Ingredient | What it fixes | In this lecture |
|---|---|---|
| syntax | a set of symbols and rules for combining them into formulas | §2–3 |
| semantics | a systematic, mathematical way of assigning meaning (truth) to formulas | §4–6 |
| proof system | formal rules of inference that derive formulas mechanically | §8–9 (and Lecture 3) |
Many logics exist, with different trade-offs between expressiveness (what can be said) and mechanizability (what can be decided automatically). The course starts with the simplest classical logic, propositional logic (PL): statements that are either true or false, combined with “not”, “and”, “or”, “if … then”, “if and only if”. Every other classical logic in the course extends it.
1.3 A short history
| When | Who | What |
|---|---|---|
| 1670s–1680s | Leibniz | dreams of a calculus ratiocinator: settle disputes by calculation (“let us calculate”) |
| 1847–1854 | Boole | an algebra of logic: truth values as 0/1 with algebraic laws |
| 1879 | Frege | the first formal logic with quantifiers (Begriffsschrift) |
| 1921 | Post; Wittgenstein | truth tables; Post proves propositional logic complete and studies which connectives suffice (§7) |
| 1928 | Hilbert & Ackermann | the Entscheidungsproblem: is there an algorithm that decides validity in first-order logic? |
| 1936 | Church; Turing | no — first-order validity is undecidable (Lecture 8). Propositional validity is decidable (truth tables). |
| 1960, 1962 | Davis & Putnam; Davis, Logemann & Loveland | the DP and DPLL procedures for propositional satisfiability (Lectures 2, 4) |
| 1965 | Robinson | resolution and unification for first-order logic (Lectures 2, 7, 8) |
| 1971 | Cook (and Levin, 1973) | SAT is NP-complete: probably no polynomial algorithm exists |
| 1979 | Nelson & Oppen | combining decision procedures for different theories (Lecture 18) |
| 1996–2001 | Marques-Silva & Sakallah (GRASP); Moskewicz et al. (Chaff) | conflict-driven clause learning (CDCL): SAT solving becomes industrially practical (Lecture 5) |
| 2000s–now | many groups | SMT solvers (Z3, cvc5, Yices, Bitwuzla, …) built on DPLL(T) (Lectures 10–18) |
The striking point is the SAT paradox. SAT is NP-complete, so we expect worst cases that take exponential time; yet CDCL solvers routinely decide formulas from industry with millions of variables. Understanding why is one goal of the first five lectures.
1.4 Where it is used today (as reported by the people who use it)
- Hardware verification. After the 1994 Pentium floating-point division bug, for which Intel reported a charge of about $475 million, formal verification became standard in processor design. Equivalence checking of circuits (§10.4, at toy scale) is routine.
- Cloud security. Amazon Web Services reports that its SMT-based tools for reasoning about access policies issue on the order of a billion SMT queries a day (Rungta, CAV 2022).
- Software. Symbolic execution and fuzzing tools ask solvers for inputs that reach buggy code (Lecture 14); bounded model checkers verify device drivers and protocols (Lecture 9).
- Mathematics. SAT solvers settled open combinatorial problems, e.g. the Boolean Pythagorean triples problem (Heule, Kullmann & Marek, 2016), with a proof reported at about 200 terabytes. Proof assistants such as Lean use decision procedures to automate formal proofs (Lecture 15).
- AI and programming. Synthesis tools generate code that provably meets a specification (Lecture 20); verification checks the output of language models, e.g. generated SQL (Lecture 19).
1.5 What “deciding” means, and the plan of this lecture
A decision procedure for a set of formulas is a procedure that, given any formula, always terminates and answers yes if the formula is in and no otherwise. This course builds decision procedures for = the valid formulas, or = the satisfiable formulas, in ever richer logics.
Before deciding anything we need the language (syntax, §2–3) and its meaning (semantics, §4–7). Then come the first two decision procedures (§8–9) and their limits (§10).
2. Syntax: what is a formula?
2.1 The alphabet
Atomic statements (atoms) are the smallest sentences. In ordinary language they might be “0 < 1”, “Iowa City is in Iowa” or “1 + 1 = 10”. Propositional logic does not look inside an atom: it only cares that an atom is either true or false. So atoms become plain names.
The alphabet of propositional logic consists of:
- atoms: the truth constants (true) and (false), and propositional variables (a countably infinite supply);
- logical symbols: the connectives and the parentheses ( and ).
The slides warn that parentheses live at three levels of discourse: inside formulas, as in ; in ordinary mathematical notation, as in ; and in English text (like this one). Keep them apart.
2.2 Formula-building operators and the inductive definition
A sentence is a finite sequence of symbols, but most sequences are nonsense: (p ∧ ∨ q), p q, )) ⇔) s. Syntax rules pick out the meaningful ones. The slides define five formula-building operators, for all formulas :
The set of well-formed formulas (wffs) is defined by three clauses:
- every atom is a wff;
- if and are wffs, so are , , …, ;
- nothing else is a wff.
Why define formulas this way? Three reasons, each of which pays off later:
- A finite description of an infinite set. There are infinitely many formulas; five operators and one base set describe all of them.
- A built-in recipe for algorithms. Any function on formulas can be defined by one case for atoms and one case per operator (structural recursion, §3.4). The evaluator, the printer, the size function and every solver of the course are written that way.
- A built-in recipe for proofs. Any property can be proved for all formulas by checking atoms and checking that each operator preserves it (structural induction, §3.1).
Clause 3 is what makes induction work: if anything else were allowed into , a property preserved by the operators might still fail for the intruders.
2.3 Closed sets and generated sets
The slides make “nothing else” precise with two notions:
- A set is closed under a set of operators if applying any operator of to elements of gives an element of . For example, is closed under and but not under negation; the odd integers are closed under and negation but not .
- A set is generated from a base set by if is the smallest set that contains and is closed under . For example, is generated from by ; is generated from by . The reals are generated from no countable base by such operators, because generated sets are always countable.
So is the set generated from the atoms by the five formula-building operators. “Smallest” is exactly clause 3.
2.4 Notational conventions
The official syntax is unreadable in bulk: . The slides adopt conventions that drop parentheses:
- outermost parentheses may be omitted;
- precedence: binds most strongly (with smallest possible scope), then , then , then and . We follow CC and also put above , so binds most weakly;
- binary connectives associate to the right: means .
These are abbreviations only: each conventional string stands for exactly one official formula. Script 01, Part 2 shows the parser’s reading of typical strings:
| you write | the parser reads (official syntax) | main connective |
|---|---|---|
| ¬p ∧ q | ((¬p) ∧ q) | ∧ |
| ¬(p ∧ q) | (¬(p ∧ q)) | ¬ |
| p1 ∧ p2 ∨ p3 | ((p1 ∧ p2) ∨ p3) | ∨ |
| p1 ∧ p2 ⇒ ¬p3 ∨ p4 | ((p1 ∧ p2) ⇒ ((¬p3) ∨ p4)) | ⇒ |
| p ⇒ q ⇒ r | (p ⇒ (q ⇒ r)) | ⇒ |
| p ⇔ q ⇒ r | (p ⇔ (q ⇒ r)) | ⇔ |
Our printer keeps the redundant parentheses in and : people misread right-nested implications far more often than parsers do.
2.5 Parse trees: the meaning belongs to the tree
The main connective of a formula is the last operator applied when building it. Drawing a formula with its main connective at the root, and recursing into the operands, gives its parse tree. Script 01 prints the tree of :
⇒
├── ∧
│ ├── p1
│ └── p2
└── ∨
├── ¬
│ └── p3
└── p4
Every algorithm in this course works on trees (or DAGs, §10.6), never on strings. The string is only a way to write the tree down.
Parentheses can change the tree, and with it the meaning. Script 01 compares three pairs, counting models (the rows of the truth table where the formula is true; §4):
| formula A | #models | formula B | #models | a row where they differ |
|---|---|---|---|---|
| (p ⇒ q) ⇒ r | 5 | p ⇒ (q ⇒ r) | 7 | p=0, q=0, r=0 |
| ¬(p ∧ q) | 3 | ¬p ∧ q | 1 | p=0, q=0 |
| (p ∨ q) ∧ r | 3 | p ∨ q ∧ r | 5 | p=1, q=0, r=0 |
2.6 Unique readability: why the language must fix one tree per string
Imagine a language without parentheses or conventions. The flat string p ∧ q ∨ r ⇒ s could then be read as any of the 5 trees with those leaves and connectives in that order (script 01, Part 3). Each tree has a different number of models (7, 5, 13, 13, 11 of 16), and in fact 5 different truth tables. The conventions select .
With binary connectives a flat string has trees: 1, 2, 5, 14, 42, …, 208,012 for . A sentence with several meanings has no single truth value, so a formal language must fix one tree per string. The official syntax does it with mandatory parentheses, the conventions with precedence and associativity.
That every wff of the official syntax is built in exactly one way is the unique readability theorem (MI §1.3). Its key lemma: every proper initial segment of a non-atomic wff has more left than right parentheses. So the parentheses balance only at the very end, and a parser always knows where the main operator’s operands stop. Script 01 checks this lemma on 5,000 random formulas (Part 4).
Run it.
python3 01_syntax_and_parse_trees.py(about 2 seconds).
- Part 1 shows the parser accepting
(p ∧ q)and((¬p) ⇒ r)and rejecting the slides’ non-formulas, with a caret under the offending symbol, e.g.expected a formula, found '∨'.- Part 2 prints the table of §2.4 and the parse tree above.
- Part 3 lists the 5 trees of
p ∧ q ∨ r ⇒ sand the Catalan numbers.
A detail of our concrete syntax: variable names may be longer than one letter, so pq (no space) is the single variable named pq. In the slides’ alphabet, pq is two symbols in a row, which no operator produces. Our parser rejects the spaced version p q with “unexpected ‘q’ after a complete formula”.
3. Structural induction and structural recursion
3.1 The principle
Let be generated from by the operators . Call a set inductive with respect to if and is closed under . Since is the smallest such set, .
To prove that every element of has a property :
- let be the set of things that have ;
- show is inductive: (a) every element of has (base case); (b) if the inputs of an operator have , so does its output (inductive step, using the induction hypothesis for the inputs);
- conclude : everything in has .
For formulas this reads: prove for atoms; prove that and each binary connective preserve ; conclude for all formulas. It is ordinary induction on natural numbers generalized from “+1” to the formula-building operators.
3.2 Example from the slides: parentheses balance
Claim. Every wff of the official syntax has as many left parentheses as right parentheses.
Proof. Let and count them, and let .
- Base: an atom has no parentheses, .
- Step : , using the induction hypothesis .
- Step : . The other binary connectives are identical.
So is inductive and contains every wff. ∎
3.3 A second example, used again in Lecture 2
Claim. In every formula (tree), the number of atom occurrences equals the number of binary connectives plus one.
Proof.
- Base: an atom has 1 atom occurrence and 0 binary connectives: .
- Step : adds neither atoms nor binary connectives.
- Step : . ∎
Script 01, Part 4 checks seven such properties on 5,000 random formulas (sizes 1 to 60 nodes, mean 27.3): the two above, the prefix lemma of §2.6, the round trips parse(print(f)) == f in three notations, and . Zero violations each.
Zero violations is evidence, not proof. Five thousand formulas are a vanishing fraction of infinitely many; structural induction covers all of them at once. Conversely, a single violation would have been a genuine counterexample — that asymmetry between proofs and tests runs through the whole course.
3.4 Structural recursion: induction’s twin
The same pattern defines functions. One case per atom kind, one case per connective, each allowed to use the function’s values on the children:
Unique readability guarantees such definitions are well defined: a formula is built in only one way, so only one case applies. In logic.py, size, depth, variables, subformulas, to_str, evaluate and table_bits are all structural recursions. So, in later lectures, are the CNF conversion, the Tseitin encoding and the bit-blaster.
3.5 Infinitely many formulas, finitely many meanings
How many formulas are there? A dynamic program over the inductive definition counts the trees of each size (script 01, Part 5). With two variables there are 312,501,026 formulas of size 13; with three, 3,707,218,155. The count grows without bound.
How many different meanings? Over variables a formula’s meaning is its truth table: one bit per row, rows, hence at most meanings — 16 for , 256 for . Running the same dynamic program on truth tables instead of formulas shows how fast the meanings are reached:
| variables | possible meanings | all reached by size | formulas of size 13 |
|---|---|---|---|
| 2 | 16 | 4 | 312,501,026 |
| 3 | 256 | 10 | 3,707,218,155 |

Most formulas are redundant rewrites of a few meanings. This finiteness is why propositional logic is decidable: a formula over variables can be judged by checking finitely many () rows (§8.3). In first-order logic (Lecture 6) the meaning of a formula can depend on infinitely many objects, and this argument breaks.
4. Semantics: when is a formula true?
4.1 Interpretations
An atom’s truth depends on what it stands for. The slides’ example: “1 + 1 = 10” is false if the numerals are read in decimal, true if they are read in binary. Propositional logic deliberately ignores why an atom is true. It only asks: given a truth value for each variable, what is the truth value of the formula?
An interpretation (variable assignment, truth assignment) is a function from variables to . It extends to all formulas by structural recursion — the compositional semantics:
| formula | true under iff |
|---|---|
| always | |
| never | |
| is false under | |
| both and are true | |
| at least one of them is true (inclusive or) | |
| is false, or is true | |
| and have the same value |
We write (” satisfies ”, ” is a model of ”) when is true under , and otherwise.
Why compositional? The value of a formula depends only on the connective and the values of its immediate subformulas. This single property is what makes truth tables possible, what lets solvers replace a subformula by an equivalent one (§6), and what lets SAT solvers reason locally, one clause at a time.
4.2 Seeing compositionality
Script 02, Part 1 evaluates the slides’ formula under , printing every subformula after its children:
| subformula | value | rule |
|---|---|---|
| p | 1 | given by |
| q | 0 | given by |
| p ∧ q | 0 | true iff both sides are true |
| ¬q | 1 | ¬ flips the value of q |
| p ∨ ¬q | 1 | true iff at least one side is true |
| p ∧ q ⇒ p ∨ ¬q | 1 | false only if left is true and right is false |
The same script evaluates a few formulas with the atom = “1 + 1 = 10” under the decimal reading ( false) and the binary reading ( true). is true under both; flips. Some formulas are true because of their form alone, whatever their atoms mean. Those are the valid formulas, and recognizing them is the central task of the course.
4.3 The puzzle of material implication
Students often object to the row “false ⇒ anything is true”. Why define that way?
- It is the only choice that makes a promise. Read as “I promise that whenever holds, holds”. The promise is broken only when holds and does not. If is false, nothing was promised, so nothing was broken.
- It makes valid patterns valid. “For every number : if then ” should be true. For the instance reads "", false ⇒ false, and it must come out true or the general statement would fail.
- It is truth-functional. Everyday “if” often carries causation or relevance (“if you heat it, it melts”). Propositional logic cannot express those, because it only sees truth values. It keeps the truth-functional core, which is what the rest of mathematics uses.
Equivalently, — a law used constantly from Lecture 2 on (script 02, Part 6 verifies it).
4.4 Truth tables
With variables there are interpretations. Listing all of them with the value of every subformula gives the truth table. The slides’ example (script 02, Part 2):
p q p ∧ q ¬q p ∨ ¬q p ∧ q ⇒ p ∨ ¬q
- - ----- -- ------ --------------
0 0 0 1 1 1
0 1 0 0 0 1
1 0 0 1 1 1
1 1 1 0 1 1
is true in all 4 rows: valid. Rows are listed in the order of the slides — all false first, the last variable changing fastest — which is also the order of the binary numbers 0 to . Our code uses that correspondence to store whole columns in one integer (§8.3).
5. Satisfiability, validity, entailment, equivalence
5.1 Four properties of a single formula
| A formula is … | if … |
|---|---|
| satisfiable | for some |
| falsifiable | for some |
| valid (a tautology), written | for every |
| unsatisfiable (a contradiction) | for every |
A set of formulas is satisfiable if one interpretation satisfies all its members at once.
Every formula is in exactly one of three classes: valid (all rows true), unsatisfiable (no row true), or contingent (some of each). So valid ⊂ satisfiable, unsatisfiable ⊂ falsifiable, and contingent = satisfiable ∩ falsifiable.
Script 02, Part 3 classifies the slides’ examples and a few more:
| formula | #vars | #models | class |
|---|---|---|---|
| p | 1 | 1/2 | contingent |
| p ⇒ q | 2 | 3/4 | contingent |
| p ∨ ¬q | 2 | 3/4 | contingent |
| (p ⇒ q) ⇒ p | 2 | 2/4 | contingent |
| p ⇒ p, p ∨ ¬p | 1 | 2/2 | valid |
| p ⇒ (q ⇒ p) | 2 | 4/4 | valid |
| ((p ⇒ q) ⇒ p) ⇒ p | 2 | 4/4 | valid (Peirce’s law) |
| ⊤ | 0 | 1/1 | valid |
| ⊥, p ∧ ¬p | 0, 1 | 0/1, 0/2 | unsatisfiable |
| (p ⇒ q) ∧ p ∧ ¬q | 2 | 0/4 | unsatisfiable |
Two small surprises:
- Peirce’s law is valid although it mentions , which seems to play no role.
- and have zero variables, so their table has row.
5.2 Entailment and equivalence
Validity is about one formula. Reasoning is about consequences:
- A set entails , written , if every interpretation that satisfies all of also satisfies . We also say is a logical consequence of .
- and are equivalent, , if and : same value in every row.
The symbol is overloaded: relates an interpretation and a formula; relates a set of formulas and a formula. Context disambiguates. Neither is a connective. and are statements about formulas (in the metalanguage), not formulas.
Script 02, Part 4 tests inference patterns. The variable version of each pattern is decided by truth table; then 1,000 random formulas are substituted for :
| pattern | holds? | counterexample | random instances that hold |
|---|---|---|---|
| {α, α ⇒ β} ⊨ β (modus ponens) | yes | – | 100.0% |
| {α ⇒ β, ¬β} ⊨ ¬α (modus tollens) | yes | – | 100.0% |
| {α ⇒ β, β ⇒ γ} ⊨ α ⇒ γ (chaining) | yes | – | 100.0% |
| {α ∨ β, ¬α} ⊨ β (disjunctive syllogism) | yes | – | 100.0% |
| {α ⇒ β, β} ⊨ α (affirming the consequent) | no | a=0, b=1 | 19.4% |
| {α ⇒ β, ¬α} ⊨ ¬β (denying the antecedent) | no | a=0, b=1 | 20.4% |
| α ∨ β ⊨ α | no | a=0, b=1 | 19.2% |
A sound pattern holds for every instance. A fallacy fails on plain variables, yet about a fifth of its random instances happen to hold — for example when the substituted is itself valid. Not a valid pattern does not mean never true; it means not true by form alone.
5.3 Duality: one procedure decides everything
The key theorems of this section (the slides prove the first; the others follow the same way):
Proof of the second. means: no row has true and false. is false exactly in the rows where is true and false. So “no such row” is ” is true in every row”. ∎
The consequence shapes the whole course: a procedure for satisfiability decides validity, entailment and equivalence too — just negate. That is why the rest of the course builds SAT and SMT solvers, and why a counterexample to a claimed entailment is simply a model of .
Script 02, Part 5 checks all five theorem forms on 4,000 random pairs: 4,000 / 4,000 agreements each. (Among those pairs held 1,158 times and 131 times, so both directions were exercised.)
5.4 How common is validity?
The same part classifies random formulas over by size (600 per size):
| #connectives | valid | contingent | unsatisfiable |
|---|---|---|---|
| 2 | 11.5% | 83.8% | 4.7% |
| 10 | 13.7% | 81.0% | 5.3% |
| 20 | 15.0% | 78.2% | 6.8% |
| 30 | 16.3% | 75.8% | 7.8% |

Most random formulas are contingent. Valid ones outnumber unsatisfiable ones about 2 : 1, because and are true in 3 of 4 rows while only is true in 1. The exact percentages depend on the generator — there is no canonical “random formula”. (Random CNF formulas, Lecture 4, have a much more dramatic behaviour: a sharp threshold between satisfiable and unsatisfiable.)
6. Substitution
6.1 Definition (CC §1.5)
A substitution is a finite map from formulas to formulas. replaces every occurrence of each in by . Two details matter:
- replacements are simultaneous: swaps and ; the put in for is not replaced again;
- when both a formula and one of its subformulas are in the domain, the larger one is replaced (the replacement works top-down).
A substitution whose domain contains only variables is a variable substitution. In code: substitute(f, {"p": parse("q ∧ r")}).
6.2 Valid templates (CC Prop. 1.18)
Theorem. If is valid and is a variable substitution, then is valid.
Why. Take any interpretation . Define the value of under . By structural induction, the value of under equals the value of under . Since is valid, that value is true. ∎
So each valid formula over is a template that stands for infinitely many valid formulas. The slides’ “useful tautologies” are such templates. Script 02, Part 6 checks each law and then 500 random instances of it:
| law | template | valid? | random instances valid |
|---|---|---|---|
| distributivity | a ∧ (b ∨ c) ⇔ (a ∧ b) ∨ (a ∧ c) | yes | 500/500 |
| implication | (a ⇒ b) ⇔ (¬a ∨ b) | yes | 500/500 |
| negated implication | ¬(a ⇒ b) ⇔ (a ∧ ¬b) | yes | 500/500 |
| contraposition | (a ⇒ b) ⇔ (¬b ⇒ ¬a) | yes | 500/500 |
| exportation | ((a ∧ b) ⇒ c) ⇔ (a ⇒ (b ⇒ c)) | yes | 500/500 |
| De Morgan | ¬(a ∧ b) ⇔ (¬a ∨ ¬b), ¬(a ∨ b) ⇔ (¬a ∧ ¬b) | yes | 500/500 |
| NOT a law: converse | (a ⇒ b) ⇔ (b ⇒ a) | no | 13/500 |
The script checks 13 laws in all, including associativity, both distributive laws, double negation, excluded middle and negated equivalence. Every valid one gives 500/500.
The same argument shows that substitution preserves unsatisfiability — but not contingency. The contingent becomes valid under , unsatisfiable under , and stays contingent under .
6.3 Substitution of equivalents (CC Prop. 1.16)
Theorem. If for all , then .
Why. By compositionality (§4.1): under any interpretation, the replaced subformulas have the same values as the originals, so every enclosing subformula has the same value too (induction on ). ∎
Script 02 tests it 2,000 times: pick a random formula, pick one of its subformulas, rewrite that subformula’s top connective with a standard law (e.g. ↦ ), and substitute. The result differs syntactically in all 2,000 cases and is equivalent in all 2,000. A control replaces by its converse inside : not equivalent.
Why solvers care. This theorem licenses every simplification and normal form a solver applies before solving (Lecture 2): rewriting away, pushing inward, flattening. Each step replaces a part by an equivalent part, so the whole keeps its meaning.
7. How many connectives do we need?
7.1 Defining connectives from others
A binary connective is defined from a set of connectives if for some built from with connectives in only. The slides show that can be defined from :
Why care?
- Proofs by structural induction get shorter: fewer connectives, fewer cases.
- Algorithms work on normal forms over a small fixed set: CNF uses ; hardware tools use and-inverter graphs, .
7.2 Functional completeness
There are truth functions of two variables (script 03, Part 1). Only four are binary connectives of our syntax; XOR, NAND, NOR and the rest must be built.
A set is functionally complete if every truth function, of any number of variables, is expressed by some formula over .
is complete. For each row where the function is true, write the conjunction of literals describing that row; take the disjunction of those conjunctions. This is the disjunctive normal form of Lecture 2. Since is definable from , so is everything.
Script 03, Part 2 computes, for each set of connectives, how many of the 256 truth tables over it can build. Each set starts from the three variable columns and applies the connectives until nothing new appears:
| connectives | reached | complete? | every reachable function is … |
|---|---|---|---|
| {¬, ∧}, {¬, ∨}, {¬, ⇒} | 256/256 | yes | – |
| {⇒, ⊥} | 256/256 | yes | – |
| {NAND}, {NOR} | 256/256 | yes | – |
| {⊕, ∧, ⊤} | 256/256 | yes | – |
| {∧, ∨} | 18/256 | no | ⊤-preserving, ⊥-preserving, monotone |
| {∧, ∨, ⇒, ⇔} | 128/256 | no | ⊤-preserving |
| {⇒} | 38/256 | no | ⊤-preserving |
| {¬, ⇔}, {⇔, ⊥} | 16/256 | no | affine |
| {∧, ∨, ⊤, ⊥} | 20/256 | no | monotone |
7.3 Proving incompleteness: find an invariant
How do we prove that no formula over expresses ? Find a property that every variable has and every connective preserves; then structural induction gives it to every formula.
Invariant: “true under the all-true interpretation”.
- Base: every variable is true there.
- Step: each of maps (true, true) to true.
So every formula over these connectives is true under the all-true interpretation, while is false there. ∎
The last column of the table lists, for each incomplete set, the invariants it cannot escape. Post’s theorem (1941) says these five invariants are the only obstacles. A set of connectives is complete iff, for each of the five classes below, some connective of the set lies outside it:
| class | property of |
|---|---|
| ⊤-preserving | |
| ⊥-preserving | |
| monotone | changing an input from 0 to 1 never changes the output from 1 to 0 |
| self-dual | |
| affine | is an XOR of some inputs, possibly negated |
For example, only builds affine functions: , and XORs of XORs stay XORs. So it can never build . This “find an invariant, prove it by induction” pattern returns in Lecture 3, where the invariant is “every derived formula is valid” (soundness of a proof system).
7.4 The price of a small basis
Every complete basis reaches everything — at a price in formula size. Script 03, Part 3 finds the smallest formula for each truth function by dynamic programming over truth tables:
| function | {¬, ∧, ∨, ⇒, ⇔} | {¬, ⇒} | {NAND} (↑) | {¬, ∧} |
|---|---|---|---|---|
| p ∧ q | 3: p ∧ q | 5: ¬(p ⇒ ¬q) | 7: (p ↑ q) ↑ (p ↑ q) | 3: p ∧ q |
| p ∨ q | 3: p ∨ q | 4: ¬p ⇒ q | 7: (p ↑ p) ↑ (q ↑ q) | 6: ¬(¬p ∧ ¬q) |
| p ⊕ q | 4: ¬(p ⇔ q) | 8: (p ⇒ q) ⇒ ¬(q ⇒ p) | 11 | 11: ¬(p ∧ q) ∧ ¬(¬p ∧ ¬q) |
Averaged over all functions:
| basis | mean smallest size, 2 variables | mean, 3 variables | largest, 3 variables |
|---|---|---|---|
| {¬, ∧, ∨, ⇒, ⇔} | 3.00 | 6.16 | 10 |
| {¬, ⇒} | 3.88 | 9.34 | 22 |
| {NAND} | 6.75 | 13.19 | 29 |
| {¬, ∧} | 4.56 | 11.75 | 30 |
The slides’ identities appear as the smallest formulas over . Solvers accept the size penalty on purpose: one small internal language means fewer cases in every algorithm and every correctness proof. Users, meanwhile, keep a rich input language.
Run it.
python3 03_connectives_and_expressiveness.py(well under a second): the 16 functions, the closure table with Post’s invariants, and the smallest formulas.
8. Decision procedures: truth tables and semantic arguments
8.1 What we want
A decision procedure for validity takes any formula and, after finitely many steps, answers valid or not valid, correctly. A procedure need not terminate; an algorithm (and a decision procedure) must.
The slides name two fundamental strategies:
- search: explore the space of interpretations, looking for a counterexample;
- deduction: apply inference rules to derive validity (or a contradiction).
Modern SAT solvers interleave both (Lectures 4–5). This section builds one pure representative of each.
8.2 The truth-table method
Enumerate all interpretations and evaluate. It is correct and always terminates, because is finite. Its costs:
- time grows like — every row must be visited to conclude valid or unsatisfiable;
- memory can be tiny: one row at a time.
8.3 The bit-parallel trick (and why it changes nothing)
logic.py implements the truth-table method with one idea from hardware simulation. Store a whole column of the truth table as a single integer, whose bit is the value in row . Then one integer operation evaluates a connective on all rows at once:
Here FULL has all bits set. The column of variable is a periodic bit pattern ( zeros, then as many ones, repeated). Python integers have unlimited size, so 24 variables means 16.7-million-bit integers.
This makes each row cost a fraction of a machine instruction instead of a Python function call — a large constant factor (§10.5 measures it). It does not touch the . Bit-parallelism moves the wall; it does not remove it.
8.4 The semantic argument method: idea
Instead of checking every row, reason about a hypothetical counterexample:
- To show is valid, assume the opposite: some interpretation has .
- Unfold what that assumption forces, one connective at a time. "" forces ” or ”: two cases. "" forces ” and ”: one case.
- A case that contains both and is impossible: it is closed.
- If every case closes, no counterexample exists: is valid. If a case can no longer be unfolded and is not closed, it is open, and its atomic facts describe an interpretation that really falsifies .
This is the semantic argument of CC §1.3.2 and the slides’ “proof by deduction”. In the literature it is called the analytic tableau method (Beth, Smullyan).
The rules (semantic_argument.py), named after the connective and the sign:
| judgement | rule | conclusions | kind |
|---|---|---|---|
| ¬⊨ | linear | ||
| ¬⊭ | linear | ||
| ∧⊨ | , | linear | |
| ∧⊭ | or | branching | |
| ∨⊨ | or | branching | |
| ∨⊭ | , | linear | |
| ⇒⊨ | or | branching | |
| ⇒⊭ | , | linear | |
| ⇔⊨ | (, ) or (, ) | branching | |
| ⇔⊭ | (, ) or (, ) | branching | |
| and on one branch (or , or ) | ⊥ | the branch is closed |
Each rule simply reads the truth table of its connective backwards. For instance, ⇒ is false in exactly one row, so "" pins down both sides. Linear rules are called α-rules and branching rules β-rules.
8.5 The slides’ two examples, built by machine
Example 1: is valid? (script 04, Part 1)
1. I ⊭ p ∧ ¬q assumption
├─ case 1 of 2 (∧⊭ on 1)
│ 2. I ⊭ p ∧⊭ on 1
│ ○ open: p ↦ false (q arbitrary)
└─ case 2 of 2 (∧⊭ on 1)
3. I ⊭ ¬q ∧⊭ on 1
4. I ⊨ q ¬⊭ on 3
○ open: q ↦ true (p arbitrary)
Both cases stay open: is not valid. The open cases describe the falsifying interpretations and , with the other variable arbitrary — three of the four rows, found without listing rows. The script checks all 4 completions by evaluation (0 failures).
Example 2: is valid?
1. I ⊭ (p ⇒ q) ∧ (q ⇒ r) ⇒ (p ⇒ r) assumption
2. I ⊨ (p ⇒ q) ∧ (q ⇒ r) ⇒⊭ on 1
3. I ⊭ p ⇒ r ⇒⊭ on 1
4. I ⊨ p ⇒ q ∧⊨ on 2
5. I ⊨ q ⇒ r ∧⊨ on 2
6. I ⊨ p ⇒⊭ on 3
7. I ⊭ r ⇒⊭ on 3
├─ case 1 of 2 (⇒⊨ on 4)
│ 8. I ⊭ p ⇒⊨ on 4
│ ✗ closed: lines 6 and 8 contradict
└─ case 2 of 2 (⇒⊨ on 4)
9. I ⊨ q ⇒⊨ on 4
├─ case 1 of 2 (⇒⊨ on 5)
│ 10. I ⊭ q ⇒⊨ on 5
│ ✗ closed: lines 9 and 10 contradict
└─ case 2 of 2 (⇒⊨ on 5)
11. I ⊨ r ⇒⊨ on 5
✗ closed: lines 7 and 11 contradict
Every case closes: valid, in 11 lines with two case splits. The slides’ version has 10 lines because it uses a derived rule: modus ponens, “from and conclude ”. That rule avoids the split whose first case closes immediately. Derived rules make proofs shorter without changing what can be proved (exercise 10).
8.6 Unsatisfiability and models with the same rules
Starting from instead of turns the method into a test for unsatisfiability. All branches closed means no interpretation satisfies ; an open branch is a model — exactly what a SAT solver returns. Script 04, Part 2:
- proves unsatisfiable (8 lines);
- finds the model of ;
- proves Peirce’s law valid in 6 lines.
8.7 Why the method is correct: termination, soundness, completeness
These three properties are what Lecture 3 demands of every proof system. Here are the proofs for this one.
Termination. Look at one branch. Each rule removes a pending judgement on a formula of size and adds judgements on its immediate subformulas, whose sizes add up to at most per case. So the total size of pending formulas on a branch strictly decreases, and a branch has at most rule applications. The tree is binary with bounded depth, hence finite (at most leaves).
Soundness (if every branch closes, is valid). Suppose some falsifies . Walk down the tree from the root, always choosing a case that satisfies. Such a case always exists, because each rule’s cases cover every way its premise can be true — the rules read the truth tables exactly. Every judgement on this path is then true of , so the path never contains both and : it never closes. Hence if every branch closes, no falsifying exists. ∎
Completeness (if is valid, every branch closes; equivalently, an open finished branch yields a real counterexample). Take an open branch where every non-atomic judgement has been unfolded. Define from the atomic judgements on it (the branch is open, so they do not conflict); give unconstrained variables any value. Claim: makes every judgement on the branch true. Proof by induction on formula size:
- atoms are true by construction;
- a non-atomic judgement was unfolded, and one of its cases lies entirely on the branch; those judgements are about smaller formulas, true by the induction hypothesis; and the rule’s cases imply the premise (again: the rules read the truth tables).
In particular : a genuine counterexample. ∎
(An open, fully unfolded branch is a Hintikka set, and the claim is Hintikka’s lemma.)
Script 04, Part 3 checks all three on 3,000 random formulas (329 valid, 2,512 contingent, 159 unsatisfiable):
- 3,000 / 3,000 verdicts agree with the truth table, for both validity and unsatisfiability;
- all 58,819 interpretations read off open branches really falsify (or satisfy) the formula as claimed: 0 failures.
8.8 Strategies: the order of rules changes the proof, not the verdict
The rules can be applied in any order; the answer never changes, but the proof size does. Script 04, Part 4 compares three strategies on six formulas:
- α-first: unfold linear rules whenever possible, split only when nothing else is left;
- in order: first in, first out;
- last first: last in, first out.
| formula | goal | α-first | in order | last first |
|---|---|---|---|---|
| (p ⇒ q) ∧ (q ⇒ r) ⇒ (p ⇒ r) | valid | 11 / 3 | 11 / 3 | 11 / 3 |
| (a ∨ b) ∧ (c ∨ d) ∧ (e ∨ f) ∧ ¬a ∧ ¬b | unsat | 13 / 2 | 57 / 8 | 25 / 8 |
| ¬(p ∧ q) ⇔ ¬p ∨ ¬q | valid | 19 / 4 | 22 / 4 | 21 / 4 |
(each cell: lines / branches; the other three formulas tie)
α-first is never worse in this table and sometimes much better. A split copies every pending judgement into both cases, so splitting late copies less. On the second formula, α-first learns and before splitting on , and both cases close at once. Use cheap, forced facts before guessing: that is the seed of unit propagation, the engine of every SAT solver (Lectures 2 and 4).
8.9 Is deduction faster than enumeration? Sometimes much faster, sometimes much slower
Script 04, Part 5 measures proof size against truth-table size on three families.
(a) Implication chains , valid:
| n | 4 | 8 | 12 | 16 | 20 |
|---|---|---|---|---|---|
| truth-table rows | 16 | 256 | 4,096 | 65,536 | 1,048,576 |
| proof lines | 15 | 31 | 47 | 63 | 79 |
The proof grows linearly, because every split has a case that closes at once. Deduction exploits structure that enumeration cannot see.
(b) All clauses over variables: the conjunction of every disjunction that contains each variable once, positively or negatively. It is unsatisfiable, since each interpretation falsifies exactly one clause. The formula itself has size about , so the truth-table work (rows × size) is polynomial in the formula size.
| n | 1 | 2 | 3 | 4 | 5 | 6 |
|---|---|---|---|---|---|---|
| truth table: rows × size | 8 | 76 | 472 | 2,544 | 12,768 | 61,376 |
| proof lines, plain rules | 4 | 26 | 705 | > 300,000 (stopped) | – | – |
| proof lines, skip fulfilled | 4 | 21 | 117 | 1,045 | 17,621 | 580,693 |
The plain proof explodes, and its growth factor itself grows (×6.5, then ×27.1, then beyond the budget). This is a known theorem: D’Agostino (1992) showed that tableaux cannot even polynomially simulate truth tables.
Why so bad? The plain method splits on a clause even when the branch already makes it true, re-deriving the same facts again and again. The variant skip_fulfilled=True drops a disjunction that already holds on the branch. That is sound and complete (exercise 11) and helps enormously, but from on even it loses to the truth table.
(c) Random 3-CNF formulas with 5 clauses per variable (median of 3; the search stops at the first model):
| n | 3 | 4 | 5 |
|---|---|---|---|
| truth-table rows | 8 | 16 | 32 |
| proof lines, plain | 1,143 | 44,254 | > 100,000 (stopped) |
| proof lines, skip fulfilled | 159 | 2,533 | 25,920 |

The plain method needs 44,254 lines where the truth table has 16 rows. The root cause is that the cases of a β-rule overlap: from the cases are "" and "", and an interpretation can satisfy both. The same assignments are explored again and again.
Plan vs reality. The plan for this experiment was to compare the two methods on random 3-CNF up to 14 variables. The plain tableau could not get past 4, which turned the experiment into a lesson about why.
The cure is previewed here and developed in Lectures 2–5:
- split on a variable — the cases / are exclusive, so each interpretation is explored once;
- drop satisfied clauses;
- propagate forced literals first.
That is the DPLL procedure (Lecture 4). Its descendant CDCL (Lecture 5) adds learning, and decides the adder of §10.5 at 64 bits in seconds.
Run it.
python3 04_semantic_arguments.py(about 15 seconds): every proof in this section, the correctness check, the strategy table and the three families.
9. A glimpse of deductive systems
The semantic argument reasons about interpretations. A different tradition derives formulas syntactically, from axioms by rules, never mentioning interpretations. A deductive system has a set of axioms (valid formulas) and rules. A proof of is a sequence of formulas, each an axiom or the result of a rule applied to earlier ones, ending in . We write , and when the members of may be used as extra axioms (a sequent).
The slides present the Hilbert system H2: three axiom schemas and one rule (any formulas may be substituted for ):
Even takes five steps:
- A2 with , , ;
- A1 with ;
- MP on 1, 2;
- A1 with ;
- MP on 3, 4.
Derived rules make life easier. The most important is the deduction theorem: if then . With it, follows in two lines from the assumption rule.
The three properties a deductive system should have:
| property | meaning | H2 |
|---|---|---|
| soundness | if then (only valid formulas are provable) | yes: the axioms are valid (they are valid templates, §6.2) and MP preserves validity |
| completeness | if then (every valid formula is provable) | yes (Post 1921; Kalmár 1935) |
| consistency | never both and | follows from soundness |
Hilbert systems are elegant for proving things about logic and terrible for automation. A proof may need any instance of any axiom, and MP can be applied to any pair of formulas, so the search space is infinite and unstructured. The slides conclude that we will focus on proof systems closer to semantic arguments, where every step decomposes the formula (the subformula property). Lecture 3 makes “proof system” precise in general, with soundness, completeness and termination as the three things to prove.
10. Modeling with propositional logic, and the exponential wall
10.1 From English to formulas
Translation in three steps:
- identify the atomic statements and give them names;
- recognize the connectives behind English keywords;
- reveal as much logical structure as possible (“John is not tall” is , not a new atom).
Script 05, Part 1 tabulates the usual keywords, with each formula’s values on the rows = 00, 01, 10, 11:
| English | formula | values on 00 01 10 11 |
|---|---|---|
| p and q; p but q; p, however q | p ∧ q | 0001 |
| p or q (inclusive) | p ∨ q | 0111 |
| either p or q (exclusive) | (p ∨ q) ∧ ¬(p ∧ q) | 0110 |
| if p then q; p only if q; p is sufficient for q | p ⇒ q | 1101 |
| p if q; p is necessary for q | q ⇒ p | 1011 |
| p unless q | ¬q ⇒ p (≡ p ∨ q) | 0111 |
| neither p nor q | ¬p ∧ ¬q (≡ ¬(p ∨ q)) | 1000 |
Pitfalls the truth table catches at once:
- “p only if q” is , not — the commonest translation error;
- English “or” is ambiguous, and the two readings differ exactly in the row where both hold;
- some English cannot be expressed at all: “but” and “and” become the same , and temporal or causal “and” (“she fell and broke her arm”) is lost.
10.2 Puzzles as entailment: knights and knaves
On Smullyan’s island, knights always tell the truth and knaves always lie. If means “X is a knight”, then X saying contributes to the knowledge base . Script 05, Part 2:
| puzzle | KB | models | conclusion |
|---|---|---|---|
| A: “We are both knaves.” | 1: A knave, B knight | , | |
| A: “At least one of us is a knave.” | 1: A knight, B knave | both determined | |
| A: “B is a knave.” B: “A and C are of the same kind.” | 2 | ; A, B not determined | |
| A: “I am a knave.” (the liar) | 0 | everything |
Puzzle 3 is the instructive one. Its two models disagree about A and B but agree that C is a knave. Entailment asks what holds in all models, not what one solution looks like.
The liar shows the danger of contradictory assumptions. An unsatisfiable entails every formula, since there is no model to contradict it. Verification tools therefore check that their assumptions are satisfiable (“vacuity checks”): a specification that proves everything proves nothing.
10.3 Combinatorial problems, and testing an encoding
Graph 3-coloring with variables (“vertex has color ”) and three families of constraints:
- each vertex has at least one color: ;
- at most one color: ;
- adjacent vertices differ: .
A model is then exactly a proper coloring. Script 05, Part 3 checks this by comparing the number of models with an independent count of colorings by brute force:
| graph | #vars | rows | #models | #colorings (direct) | #models without at-most-one |
|---|---|---|---|---|---|
| path of 4 vertices | 12 | 4,096 | 24 | 24 | 72 |
| 5-cycle | 15 | 32,768 | 30 | 30 | 60 |
| wheel W5 | 18 | 262,144 | 0 | 0 | 0 |
| Moser spindle | 21 | 2,097,152 | 0 | 0 | 0 |
The wheel and the Moser spindle are not 3-colorable. Proving that requires ruling out every row — 2,097,152 for the spindle, still instant bit-parallel.
Dropping the at-most-one constraints does not change satisfiability: any multi-colored solution can be trimmed. But the model count no longer matches. Model counting against an independent computation is a cheap, powerful test of an encoding, used again in Lecture 2.
10.4 Equivalence checking: the classic industrial question
Two circuits are equivalent if they compute the same outputs on every input. Build a miter: the disjunction over output bits of “the two outputs differ” (). The circuits are equivalent iff the miter is unsatisfiable, and a model of the miter is a concrete failing input.
Script 05, Part 4 builds -bit adders three ways:
- ripple: , ;
- or-carry: , — note that and give the same three-input function, which the checker must discover;
- buggy: the or-carry adder whose carry out of bit 2 forgets the case.
At 4 bits (8 inputs, 256 rows):
- ripple ≡ or-carry (miter unsatisfiable);
- the buggy circuit fails on 24 of 256 inputs, the first being , : correct sum 8, buggy circuit 0. The carry into bit 2 is 1, and bit 2 has , — exactly the forgotten case.
10.5 The exponential wall, measured
The miter of two -bit adders has inputs and rows. Script 05 times both truth-table implementations:
- row by row:
evaluateon each interpretation; - bit-parallel: whole columns at once.
Times from one run on the author’s machine; they vary by machine and from run to run:
| bits n | rows | row by row | bit-parallel |
|---|---|---|---|
| 4 | 256 | ≈ 4 ms | ≈ 0.06–0.09 ms |
| 7 | 16,384 | ≈ 0.5–1.2 s | ≈ 0.2 ms |
| 10 | 1,048,576 | – | ≈ 2 ms |
| 12 | 16,777,216 | – | ≈ 60–75 ms |
Extrapolating with cost ∝ rows × circuit size, calibrated on the largest measured (again machine-dependent):
| bits n | rows | row by row (predicted) | bit-parallel (predicted) |
|---|---|---|---|
| 16 | days | ≈ 20–30 s | |
| 20 | years | ≈ 2 hours | |
| 32 | ≈ years | ≈ years | |
| 64 | ≈ years | ≈ years |

Each extra bit multiplies the work by about 4. The bit-parallel version is thousands of times faster — and hits the same wall a few bits later. A 32-bit adder is out of reach; the age of the universe is about years.
Yet industrial tools check far bigger circuits every day, with SAT solvers that never enumerate rows. How that is possible is the story of Lectures 2–5.
10.6 Trees vs DAGs: a preview of Tseitin
In the “majority” style of adder, the carry uses twice. Written out as a tree, the formula doubles with every bit; stored as a DAG, with shared subformulas kept once, it grows linearly like the circuit (script 05, Part 5):
| bits n | 4 | 8 | 12 | 16 | 20 |
|---|---|---|---|---|---|
| majority carry: tree size | 151 | 2,551 | 40,951 | 655,351 | 10,485,751 |
| majority carry: DAG size | 29 | 57 | 85 | 113 | 141 |
Our evaluators memoize on subformulas, so they work on the DAG and never notice the blow-up. Algorithms that copy subtrees do notice it: the semantic argument, or the textbook CNF conversion of Lecture 2. The fix is to give every shared gate its own name, a fresh variable defined by the gate. That is the Tseitin encoding (Lecture 2). It answers “equisatisfiable” rather than “equivalent”, which, by the duality theorems of §5.3, is all a SAT solver needs.
Run it.
python3 05_modeling_and_the_exponential_wall.py(about 1–2 seconds): English, puzzles, coloring, the adder bug, the timing table and the tree/DAG sizes.
11. Summary
- Automated reasoning mechanizes inference over a formal language with a precise syntax, semantics and proof systems. Propositional logic is the simplest classical logic and the base of all others in the course.
- Formulas are defined inductively (atoms + formula-building operators + “nothing else”). This gives structural induction for proofs and structural recursion for algorithms. Conventions (precedence, right associativity) only abbreviate; unique readability makes each formula one tree.
- Semantics is compositional: an interpretation assigns truth values to variables, and connectives combine them. Over variables there are interpretations and at most meanings, though infinitely many formulas.
- Formulas are valid, unsatisfiable or contingent. Entailment and equivalence compare formulas. Validity, entailment and equivalence all reduce to unsatisfiability of a negation, so one SAT procedure decides them all.
- Valid templates stay valid under any substitution; replacing a part by an equivalent part preserves meaning — the license for every simplification.
- A set of connectives is functionally complete iff it escapes all five of Post’s invariants. Incompleteness is proved by an invariant plus structural induction. Small bases cost formula size.
- The truth-table method decides everything in steps; bit-parallelism gains a constant factor, not an escape.
- The semantic argument method refutes a hypothetical counterexample by case analysis on connectives. It is sound, complete and terminating, and open branches yield counterexamples. It can be exponentially better than truth tables (chains) or exponentially worse (all-clauses, random CNF), because its cases overlap and it re-splits satisfied disjunctions.
- Modeling translates English, puzzles, combinatorial problems and circuits into formulas. Model counting against an independent computation validates encodings. A miter reduces equivalence checking to unsatisfiability.
- Brute force hits a measurable exponential wall around 30 inputs. The rest of the course is about getting past it: normal forms and resolution (L2), proof systems (L3), DPLL (L4), CDCL (L5) — and beyond propositional logic.
12. Common pitfalls
| Pitfall | Why it is wrong | Correct view |
|---|---|---|
| Treating or as connectives | They are statements about formulas; you cannot write | iff links them (§5.3) |
| Reading “p only if q” as | “Only if” introduces the necessary condition | |
| “False ⇒ q is weird, so it must be false” | Material implication is false only when the premise is true and the conclusion false | §4.3: it is a promise that was not broken |
| Assuming English “or” is exclusive | Logic’s is inclusive | Exclusive or must be written: |
| Confusing “not valid” with “unsatisfiable” | A contingent formula is neither valid nor unsatisfiable | Three classes: valid / contingent / unsatisfiable (§5.1) |
| Believing substitution preserves satisfiability | It preserves validity and unsatisfiability, not contingency | becomes unsatisfiable under (§6.2) |
| Testing a few formulas and calling it a proof | Tests can refute a universal claim, never establish it | Structural induction (§3.3) |
| Thinking the semantic argument is always faster than truth tables | It can be exponentially slower (§8.9b, c) | Neither method escapes ; smarter search (DPLL/CDCL) is needed |
| “If every branch closes, the formula is unsatisfiable” | Depends on the starting judgement | Start : closure proves validity; start : closure proves unsatisfiability |
Expecting Or(Or(p, q), r) == Or(p, Or(q, r)) in our Python code | They are equivalent formulas but different trees | Use equivalent(f, g) for meaning, == for structure |
| Forgetting that an unsatisfiable knowledge base entails everything | No model exists to refute any conclusion | Check assumptions for satisfiability first (§10.2) |
13. Exercises
Answers are collapsed; try each exercise first.
1. (syntax) Which of the following are wffs of the official syntax (§2.2)? For each wff, give its main connective. (a) (b) (c) (d) (e)
Answer
(a) yes, main connective ¬. (b) no: the official syntax requires ; under the conventions it abbreviates that formula. (c) yes, main connective ⇔. (d) no: every binary connective brings its own parentheses, . (e) no: officially is , which has two pairs of parentheses, and has an extra outer pair with nothing produced by an operator inside it. Check with the parser: to_str(parse(s), full=True).
2. (structural induction) Prove that in every official wff, the number of left parentheses equals the number of connectives (counting ¬ too).
Answer
Base: an atom has 0 parentheses and 0 connectives. Step: adds one left parenthesis and one connective; adds one of each to (induction hypothesis). So the set of wffs with the property is inductive. ∎
3. (structural induction) Let be built from the single variable using only and . Prove .
Answer
Base: . Step: if and then (substitution of equivalents, §6.3, then idempotence), and similarly . ∎ (This is one way to see that is not complete: from one variable it can only build .)
4. (semantics) Classify each formula as valid, contingent or unsatisfiable: (a) (b) (c) (d)
Answer
(a) valid — surprising at first: if is true the first disjunct holds, if is false the second does. (b) contingent (false when = 1, = 0). (c) unsatisfiable: would have to equal both and . (d) contingent: = 0, = 1 falsifies it (this is “denying the antecedent” as a formula). Check: classify(parse("...")).
5. (entailment) True or false? Prove or give a counterexample. (a) If and then . (b) If then . (c) If then or .
Answer
(a) True: a model of is a model of , hence of . (b) True: every model of is a model of , hence of . (c) False: , , . Then , but satisfies and not , and satisfies and not . Entailment does not distribute over on the right — one reason case splits are unavoidable.
6. (duality) Prove that iff is unsatisfiable.
Answer
Both sides say: no interpretation makes every true and false. Left side: by definition, every interpretation satisfying all satisfies , i.e. none satisfies all and falsifies . Right side: the conjunction is true exactly under interpretations that satisfy all and falsify ; unsatisfiable means there are none. ∎
7. (substitution) (a) Find variable substitutions that turn into a valid formula and into an unsatisfiable one. (b) Prove that if is unsatisfiable, so is for every variable substitution .
Answer
(a) Valid: gives . Unsatisfiable: gives . (b) unsatisfiable means valid; by the valid-template theorem is valid; so is unsatisfiable. ∎
8. (connectives) Show that NAND (, ) alone is functionally complete.
Answer
and . Since is complete (§7.2), so is . Script 03 finds the second as the smallest NAND formula for : 7 nodes, .
9. (invariants) Prove that cannot be expressed with and alone.
Answer
Invariant: “the formula’s truth function is affine”, i.e. for a constant and a set of variables. Base: variables (, ) and (, ) are affine. Step: , and XOR of affine functions is affine (add the constants, take the symmetric difference of the sets). But is not affine: an affine function of that is not constant is true in exactly 2 of 4 rows, while is true in 1 (and it is not constant). ∎ Script 03 reports exactly 16 reachable truth tables over three variables for : the 16 affine functions.
10. (semantic argument) Prove axiom A2 valid by a semantic argument: . Then show that the derived rule “from and conclude ” is sound.
Answer
Assume A2. By ⇒⊭: and ; again ⇒⊭: , ; again: , . Split ⇒⊨ on : closes with ; otherwise . Split on : closes; otherwise ; split: closes with , closes with . All closed: valid. Run semantic_argument(parse("(p ⇒ (q ⇒ r)) ⇒ ((p ⇒ q) ⇒ (p ⇒ r))")) and print it with format_proof.
Derived rule: if and , the ⇒⊨ split gives (which closes immediately against ) or . So every non-closed continuation contains ; adding it directly loses nothing.
11. (semantic argument) Justify skip_fulfilled: if a branch already contains every judgement of one case of a β-rule, the β-judgement may be dropped without splitting. Why does soundness survive? Why does completeness?
Answer
Soundness is untouched: dropping a judgement only removes work; any closed branch is still contradictory. Completeness: in the Hintikka argument (§8.7), the dropped judgement is implied by the case that is already on the branch — those judgements are true under the constructed by the induction hypothesis, and the case implies the premise. So the open branch still yields a genuine counterexample. Termination: obviously still holds.
12. (semantic argument) Use the method to find all falsifying interpretations of .
Answer
gives and . Split ∨⊨: case , then split ∧⊭: closes, open → . Case , split ∧⊭: open → ; closes. Exactly the two “exclusive” rows.
13. (modeling) (a) Write “exactly one of ” as a formula and check that it has 3 models. (b) How many clauses does the pairwise “at most one” encoding need for variables? (c) A says: “If I am a knight, then B is a knave.” What are A and B?
Answer
(a) ; count_models gives 3. (b) — quadratic; Lecture 2 shows linear-size encodings with auxiliary variables. (c) . If is false, the right side is true, contradiction. So is true, and then : A is a knight, B a knave (one model).
14. (programming) Add a function simplify(f) to a copy of logic.py that removes and using laws such as , , , . Test it on 5,000 random formulas with p_const=0.3: the result must be equivalent to the input and either be a constant or contain no constants.
Answer (sketch)
Structural recursion: simplify the children first, then apply the laws at the root (e.g. for “and”: if either child is ⊥ return ⊥; if one is ⊤ return the other). Test: assert equivalent(f, simplify(f)) and a check that simplify(f) is ⊤, ⊥, or has no “true”/“false” node in subformulas. The correctness argument is substitution of equivalents (§6.3) plus induction.
15. (reflection) The bit-parallel truth table is thousands of times faster than the row-by-row loop in §10.5. Why does that not change the conclusion “a 64-bit adder is out of reach”? What kind of improvement would?
Answer
Both methods visit all rows; bit-parallelism only lowers the cost per row, a constant factor. A factor of buys about more bits, nowhere near 64. What is needed is an algorithm whose work is not proportional to the number of rows: one that reasons about many rows at once (propagation, learning, structure). That is what DPLL and CDCL provide — still exponential in the worst case (unless P = NP), but not on typical industrial instances.
14. Further reading
- Textbooks
- A. Bradley, Z. Manna, The Calculus of Computation, Springer 2007, Ch. 1 (§1.1–1.5 for this lecture; §1.6–1.7 for the next). The semantic-argument method and the substitution propositions used here are from §1.3 and §1.5.
- H. Enderton, A Mathematical Introduction to Logic, 2nd ed., 2001, §1.0–1.2 (formal languages, the induction principle); §1.3 (unique readability); §1.5 (completeness of connectives).
- D. Kroening, O. Strichman, Decision Procedures, 2nd ed., 2016, Ch. 1 (decision procedures, soundness and completeness).
- M. Ben-Ari, Mathematical Logic for Computer Science, 3rd ed., Springer 2012, Ch. 2–3 (semantic tableaux, Hilbert systems) — the “ML” book of the Iowa course.
- R. Smullyan, First-Order Logic, 1968 (analytic tableaux, Hintikka sets).
- History and context
- M. Davis, “The early history of automated deduction”, in Handbook of Automated Reasoning, 2001.
- J. Franco, J. Martin, “A history of satisfiability”, Ch. 1 of the Handbook of Satisfiability, 2nd ed., 2021.
- D. Knuth, The Art of Computer Programming, Vol. 4B, “Satisfiability” (2022): a deep, playful tour of SAT.
- Papers mentioned
- E. Post, “Introduction to a general theory of elementary propositions”, American Journal of Mathematics, 1921 (truth tables, completeness); “The two-valued iterative systems of mathematical logic”, 1941 (the five classes).
- S. Cook, “The complexity of theorem-proving procedures”, STOC 1971.
- M. D’Agostino, “Are tableaux an improvement on truth-tables?”, Journal of Logic, Language and Information, 1992.
- N. Rungta, “A billion SMT queries a day”, CAV 2022 (invited paper).
- M. Heule, O. Kullmann, V. Marek, “Solving and verifying the Boolean Pythagorean triples problem via cube-and-conquer”, SAT 2016.
- Slides: C. Tinelli, Propositional Logic Basics and Course Introduction, Iowa CS:4980, Spring 2024 (adapted from Stanford CS 257 slides by Barrett, Trippel and Wu).
15. Next lecture
Lecture 2 (Normal forms, SAT solving and resolution) takes the first step past the exponential wall.
- Normal forms. NNF, DNF and CNF fix a small internal language. Converting to CNF by distribution can blow up exponentially (the majority adder of §10.6 is a ready-made example). The Tseitin encoding avoids that by naming subformulas, giving an equisatisfiable formula of linear size.
- Resolution. On clauses there is a single inference rule, resolution, which is sound and refutationally complete. The Davis–Putnam procedure turns it into a decision procedure: eliminate variables, propagate units, drop pure literals.
- Code.
cnf.py,sat_families.pyandresolution.pybuild onlogic.py. The first experiments compare CNF sizes on the adders of this lecture and show how resolution proofs grow on the pigeonhole problem.