Bridge facts:
- $A \equiv B \iff (A \leftrightarrow B)$ is a tautology.
- $A$ is a tautology $\iff \neg A$ is unsatisfiable.
Decision aid — "which method / which law?"
Goal
Use
Prove $A \equiv B$ with few variables, total certainty
Truth table: tabulate both, compare columns.
Prove $A \equiv B$ with many variables
Algebra of logic: rewrite step by step, cite a law each line.
Negate a compound statement
Rewrite $\rightarrow$ as $\neg p\lor q$, then push $\neg$ in with De Morgan, then double-negation.
Simplify X or (X and Y)
Absorption → X.
Simplify (p and q) or (p and ¬q)
Factor (distributive) → p and (q or ¬q) → p.
Push a not through and/or
De Morgan (flip the connective).
Decide if a condition is ever true
Satisfiability: look for one $T$ row.
Decide if a condition is always true
Tautology: all rows $T$ (or show $\neg A$ unsatisfiable).
Common pitfalls
Pitfall
Reality
"or" means exactly one
Logical $\lor$ is inclusive (both counts). Use $\oplus$ for exactly one.
$p \rightarrow q$ false when $p$ false
False only when $p$ true and $q$ false. False hypothesis ⇒ vacuously true.
Converse $\equiv$ original
No. Only the contrapositive $\neg q\rightarrow\neg p$ is equivalent. Converse $q\rightarrow p$ is not.
Swapping and operands is always safe
Truth values: yes. Execution: no — short-circuit + side effects/exceptions depend on order.
Brute-forcing SAT is fine
$2^n$ rows: ~$10^9$ at $n=30$, ~$10^{18}$ at $n=60$ — an exponential wall.
"Tests pass" = correct
Tests check sampled cases; an equivalence proof covers all $2^n$.
Satisfiability snapshot (preview of Ch. 37)
Satisfiable = some row is $T$. Unsatisfiable = contradiction.
Easy to verify, (seemingly) hard to find a satisfying assignment ⇒ the signature of NP and
P vs. NP; SAT is the emblem (NP-complete, Cook–Levin, Ch. 37).
Truth table has $2^n$ rows ⇒ exhaustive check is exponential.
Toolkit additions — logic.py (built Ch. 1–3)
Function
Signature
Returns
Truth table
truth_table(fn, names)
list of (assignment_tuple, output) rows
Tautology test
is_tautology(fn, n)
True iff fn is true on all $2^n$ assignments
Equivalence test
equivalent(f, g, n)
True iff f and g agree on all $2^n$ assignments
Implementation core: enumerate assignments with itertools.product([True, False], repeat=n); a
proposition is just a Python function returning bool. Code tests broadly; a proof settles all
cases — use both.
We use cookies to improve your experience and show relevant ads. Privacy Policy