Back to Program Verification Index | Previous: (y-01) Introduction to Program Verification | Next: (y-03) First-Order Logic
Mental Model for Propositional Logic
- Propositional Logic is the simplest “language” of logic. It deals with statements that are either true or false.
- A satisfiable formula is one that can be true; a valid formula is one that must be true (no matter what).
- SMT Solvers (like Z3) are our robotic assistants. They take a complex formula and either find a way to make it true or prove it’s impossible.
- Proof Systems are a set of mechanical rules for deriving truth. They allow us to move from premises to conclusions without making mistakes.
Introduction to Propositional Logic

Propositional logic (PL) is the foundation of program verification. We use it to describe the state of a program and the conditions that must hold at each point in the code.
Syntax of Propositional Logic

A PL formula is built from:
- Variables:
- Constants:
false,true - Connectives: (not), (and), (or), (implication), (equivalence)
🧠 Deep Dive: Precedence
Just like math has PEMDAS, logic has its own order:
- (Highest)
- (Lowest)
Example: is .
Semantics: What do formulas mean?

A variable assignment () maps every variable to a truth value (true or false).
- Satisfiable: There exists at least one assignment that makes the formula true.
- Valid (Tautology): Every possible assignment makes the formula true.
- Unsatisfiable (Contradiction): No assignment makes it true.
Key Theorem: A formula is valid if and only if is unsatisfiable.
Truth Tables

Truth tables are the “brute force” way to check logic. You list every possible combination of inputs and calculate the output.
Example: Truth Table for

Let .
| F | F | T | F | T | F |
| F | T | T | T | F | F |
| T | F | F | T | T | F |
| T | T | T | T | F | F |
Conclusion: Since the final column is false for every possible assignment, is unsatisfiable.
Limitation: For variables, you need rows. If you have 100 variables (common in program verification), the table would have more rows than atoms in the universe!
Using SMT Solvers (Z3) for SAT

Instead of truth tables, we use SMT Solvers. They use clever algorithms (like CDCL) to solve formulas with thousands of variables in milliseconds.
In SMT-LIB notation, we write formulas in prefix notation (like Lisp).
Example for :
(declare-fun P () Bool)
(declare-fun Q () Bool)
(assert (and (=> P Q) (or P Q)))
(check-sat)
(get-model)Proof Systems: NPL

A Proof System is a set of rules for deriving implications (meaning “if all formulas in are true, then must be true”).
Rules of NPL
Rules are written as .
| Rule | Name | Formula |
|---|---|---|
| Axiom | (Ax) | |
| RAA | (RAA) | (Reductio ad Absurdum) |
| Intro | () | |
| Elim | () | (for ) |
| Intro | () | (for ) |
| Elim | () | |
| Intro | () | |
| Elim | () | (Modus Ponens) |
| Intro | () | |
| Elim | () | (Ex Falso Quodlibet) |
🧠 Deep Dive: A Derivation Example
Goal: Prove . Let .
- Bottom-up: We want to prove .
- Use (I): This splits the proof into two branches: and .
- Left branch: . Since , this is finished by (Ax).
- Right branch: . Since , we use (E) (Modus Ponens).
- This requires proving and . Both are finished by (Ax) as they are in .
💡 Intuition: Formal Proofs
A formal proof is like a game of LEGO. You start with your base blocks (axioms) and use the connection rules to build the final shape (the conclusion). If you follow the rules, the final shape is guaranteed to be stable.
Guide for Finding a Derivation

- Start at the bottom: Write the goal implication as the root of your tree.
- Look at the Top-Level Operator: If the RHS is , use () to split the problem.
- Use (Ax) ASAP: As soon as the formula on the right is in the set on the left, you’ve finished that branch.
- No replacements: You cannot swap for without a specific rule; the proof system is purely mechanical/syntactic.
Summary
- Syntax: The “grammar” of logic (atoms and connectives).
- Semantics: The “meaning” (truth values and assignments).
- Satisfiability: Can it be true? Validity: Must it be true?
- SMT Solvers: Automated tools for solving logic.
- Proof Systems: Mechanical rules for human (or machine) reasoning.
Self-Check
- State the relationship between validity and unsatisfiability used to reduce checking validity to a SAT query.
Answer
A formula is valid if and only if is unsatisfiable. This lets SMT solvers check validity by negating the formula and asking the satisfiability question instead, which is the direction the solver natively supports.
- Given , what does a truth table show about its satisfiability?
Answer
The truth table evaluates for all four assignments of and and the final column is false in every row. So is unsatisfiable: no assignment makes it true, which also means is valid.
- Why are truth tables impractical for real verification problems, and what replaces them?
Answer
For variables, a truth table needs rows, so 100 variables already exceeds astronomical sizes. SMT solvers like Z3 replace the brute-force enumeration with smarter algorithms (CDCL and friends) that handle thousands of variables in milliseconds. The lecture writes the formula in SMT-LIB prefix notation and invokes
check-saton the solver.
- What is the difference between the (I) rule and the (E) rule in NPL?
Answer
(I) is the introduction rule: from separate proofs of and it concludes . (E) is the elimination rule: from a proof of it concludes . Introduction builds conjunctions; elimination takes them apart.
- Sketch how to derive in NPL.
Answer
Start at the goal and apply (I), splitting into two sub-goals: and . The first is closed immediately by (Ax) because . For the second, apply (E) (modus ponens) using and , both of which close by (Ax).
Back to Program Verification Index | Previous: (y-01) Introduction to Program Verification | Next: (y-03) First-Order Logic | (y) Return to Notes | (y) Return to Home