Introduction

Propositional logic studies statements that are either true or false, and how the truth of a compound statement depends on the truth of its parts. It gives a precise language for conditions ("if the cache misses and the bus is free, then fetch"), for specifications, and for correctness arguments.

In computer science it is the logic of Boolean expressions and digital circuits, the base of first-order logic, the setting of the satisfiability problem (SAT, the first problem shown NP-complete), and the language of program assertions. The working skills are deciding whether a formula is a tautology, whether two formulas are equivalent, and whether an argument is valid.

Prerequisites

  • No formal prerequisite. Familiarity with the Boolean values true and false and with truth tables is helpful.

Core concepts

Propositions and connectives

A proposition is a declarative sentence that is either true (T, 1) or false (F, 0), but not both. "7 is prime" is a proposition; "x>3x > 3" is not, because its truth depends on xx (it becomes a proposition once xx is fixed, or once it is quantified; see first-order logic). "Close the door" is not a proposition.

Propositional variables p,q,r,…p, q, r, \ldots stand for propositions. Compound formulas are built with connectives:

ConnectiveSymbolRead asTrue exactly when
Negation¬p\neg pnot pppp is false
Conjunctionp∧qp \land qpp and qqboth are true
Disjunctionp∨qp \lor qpp or qq (inclusive)at least one is true
Exclusive orp⊕qp \oplus qpp xor qqexactly one is true
Implicationp→qp \to qif pp then qqnot (pp true and qq false)
Biconditionalp↔qp \leftrightarrow qpp if and only if qqboth have the same value

Truth tables

ppqq¬p\neg pp∧qp \land qp∨qp \lor qp⊕qp \oplus qp→qp \to qp↔qp \leftrightarrow q
TTFTTFTT
TFFFTTFF
FTTFTTTF
FFTFFFTT

A formula with nn distinct variables has a truth table of 2n2^n rows. There are 22n2^{2^n} distinct truth functions of nn variables (16 for n=2n = 2), because each of the 2n2^n rows can independently be T or F.

Precedence convention. ¬\neg binds tightest, then ∧\land, then ∨\lor, then →\to, then ↔\leftrightarrow. Implication is right-associative: p→q→rp \to q \to r means p→(q→r)p \to (q \to r). When in doubt, add parentheses.

Implication in detail

p→qp \to q is false in exactly one row: pp true, qq false. When pp is false, the implication is vacuously true. The implication does not claim any causal link between pp and qq.

Ways to read p→qp \to q: "if pp then qq", "pp only if qq", "qq if pp", "pp is sufficient for qq", "qq is necessary for pp", "qq unless ¬p\neg p".

From p→qp \to q we form three related implications:

NameFormEquivalent to p→qp \to q?
Converseq→pq \to pNo
Inverse¬p→¬q\neg p \to \neg qNo (it is equivalent to the converse)
Contrapositive¬q→¬p\neg q \to \neg pYes
Truth tables of the connectives and the four forms of an implication
Figure 1. Left: the truth table of the five binary connectives. Right: an implication, its converse, inverse and contrapositive, with arrows marking the two equivalent pairs.

Tautology, contradiction, contingency, satisfiability

  • A tautology (valid formula) is true in every row: p∨¬pp \lor \neg p.
  • A contradiction (unsatisfiable formula) is false in every row: p∧¬pp \land \neg p.
  • A contingency is neither.
  • A formula is satisfiable if at least one row makes it true. Writing φ\varphi for a formula, valid implies satisfiable; φ\varphi is valid if and only if ¬φ\neg\varphi is unsatisfiable.

Logical equivalence and logical implication

  • A≡BA \equiv B (logically equivalent) means AA and BB have the same truth value in every row; equivalently, A↔BA \leftrightarrow B is a tautology.
  • A⇒BA \Rightarrow B (logically implies, or BB is a logical consequence of AA) means every row making AA true makes BB true; equivalently, A→BA \to B is a tautology.

Note the difference between the connective →\to (part of a formula) and the relation ⇒\Rightarrow (a statement about two formulas).

Laws of equivalence

All of the following hold for any formulas p,q,rp, q, r and can be checked by truth tables.

LawForm
Identityp∧T≡pp \land T \equiv p, p∨F≡pp \lor F \equiv p
Dominationp∨T≡Tp \lor T \equiv T, p∧F≡Fp \land F \equiv F
Idempotentp∨p≡pp \lor p \equiv p, p∧p≡pp \land p \equiv p
Double negation¬¬p≡p\neg\neg p \equiv p
Commutativep∨q≡q∨pp \lor q \equiv q \lor p, p∧q≡q∧pp \land q \equiv q \land p
Associative(p∨q)∨r≡p∨(q∨r)(p \lor q) \lor r \equiv p \lor (q \lor r), same for ∧\land
Distributivep∧(q∨r)≡(p∧q)∨(p∧r)p \land (q \lor r) \equiv (p \land q) \lor (p \land r), p∨(q∧r)≡(p∨q)∧(p∨r)p \lor (q \land r) \equiv (p \lor q) \land (p \lor r)
De Morgan¬(p∧q)≡¬p∨¬q\neg(p \land q) \equiv \neg p \lor \neg q, ¬(p∨q)≡¬p∧¬q\neg(p \lor q) \equiv \neg p \land \neg q
Absorptionp∨(p∧q)≡pp \lor (p \land q) \equiv p, p∧(p∨q)≡pp \land (p \lor q) \equiv p
Negationp∨¬p≡Tp \lor \neg p \equiv T, p∧¬p≡Fp \land \neg p \equiv F

Equivalences involving implication and the biconditional:

p→q≡¬p∨q≡¬q→¬p,¬(p→q)≡p∧¬q,p \to q \equiv \neg p \lor q \equiv \neg q \to \neg p, \qquad \neg(p \to q) \equiv p \land \neg q,
(p→q)∧(p→r)≡p→(q∧r),(p→r)∧(q→r)≡(p∨q)→r,(p \to q) \land (p \to r) \equiv p \to (q \land r), \qquad (p \to r) \land (q \to r) \equiv (p \lor q) \to r,
p→(q→r)≡(p∧q)→r(exportation),p \to (q \to r) \equiv (p \land q) \to r \quad \text{(exportation)},
p↔q≡(p→q)∧(q→p)≡(p∧q)∨(¬p∧¬q)≡¬(p⊕q).p \leftrightarrow q \equiv (p \to q) \land (q \to p) \equiv (p \land q) \lor (\neg p \land \neg q) \equiv \neg(p \oplus q).

Two traps: (p→q)→r≢p→(q→r)(p \to q) \to r \not\equiv p \to (q \to r) (implication is not associative); and (p→r)∨(q→r)≡(p∧q)→r(p \to r) \lor (q \to r) \equiv (p \land q) \to r, not (p∨q)→r(p \lor q) \to r.

Normal forms and functional completeness

  • A literal is a variable or its negation. A clause is a disjunction of literals.
  • Conjunctive normal form (CNF): a conjunction of clauses, for example (p∨¬q)∧(q∨r)(p \lor \neg q) \land (q \lor r).
  • Disjunctive normal form (DNF): a disjunction of conjunctions of literals.
  • Every formula has an equivalent CNF and an equivalent DNF. The full DNF takes one conjunction (minterm) per true row of the truth table; the full CNF takes one clause (maxterm) per false row.

Conversion recipe: (1) eliminate ↔\leftrightarrow and →\to using the equivalences above; (2) push negations inward with De Morgan and double negation; (3) distribute ∨\lor over ∧\land (for CNF) or ∧\land over ∨\lor (for DNF).

A set of connectives is functionally complete if every truth function can be expressed with it. {¬,∧,∨}\{\neg, \land, \lor\} is complete (by the full DNF), and so are {¬,∧}\{\neg, \land\}, {¬,∨}\{\neg, \lor\}, {¬,→}\{\neg, \to\}, {NAND}\{\text{NAND}\} and {NOR}\{\text{NOR}\}. The sets {∧,∨}\{\land, \lor\}, {∧,∨,→,↔}\{\land, \lor, \to, \leftrightarrow\} and {↔,⊕}\{\leftrightarrow, \oplus\} are not complete: the first two cannot express ¬p\neg p, because every formula built only from them is true when all variables are true; the last can express only affine (xor-linear) functions: it can express ¬p\neg p as p⊕(p↔p)p \oplus (p \leftrightarrow p), but never p∧qp \land q. The details of NAND and NOR gates belong to Boolean Algebra.

Arguments and rules of inference

An argument with premises P1,…,PkP_1, \ldots, P_k and conclusion CC is valid if every row that makes all premises true also makes CC true; equivalently,

(P1∧P2∧⋯∧Pk)→Cis a tautology.(P_1 \land P_2 \land \cdots \land P_k) \to C \quad \text{is a tautology.}

Validity concerns form, not truth: a valid argument with a false premise can have a false conclusion. An argument is sound if it is valid and its premises are true.

RulePremisesConclusion
Modus ponenspp, p→qp \to qqq
Modus tollens¬q\neg q, p→qp \to q¬p\neg p
Hypothetical syllogismp→qp \to q, q→rq \to rp→rp \to r
Disjunctive syllogismp∨qp \lor q, ¬p\neg pqq
Additionppp∨qp \lor q
Simplificationp∧qp \land qpp
Conjunctionpp, qqp∧qp \land q
Resolutionp∨qp \lor q, ¬p∨r\neg p \lor rq∨rq \lor r

Two classic fallacies (invalid forms):

  • Affirming the consequent: from p→qp \to q and qq, conclude pp. Counterexample row: p=F,q=Tp = F, q = T.
  • Denying the antecedent: from p→qp \to q and ¬p\neg p, conclude ¬q\neg q. Same counterexample row.

Proof by contradiction (refutation). To show premises Γ\Gamma entail CC, show that Γ∪{¬C}\Gamma \cup \{\neg C\} is unsatisfiable. Resolution theorem provers and SAT solvers work this way.

Worked examples

Example 1: tautology check by a shortcut

Is ((p→q)∧(q→r))→(p→r)((p \to q) \land (q \to r)) \to (p \to r) a tautology?

An implication is false only when its antecedent is true and its consequent is false. So suppose p→rp \to r is false: then p=Tp = T and r=Fr = F. For q→rq \to r to be true with r=Fr = F we need q=Fq = F; then p→qp \to q is T→F=FT \to F = F. The antecedent is false, so no falsifying row exists. The formula is a tautology (it is hypothetical syllogism).

This "try to falsify" method is much faster than an 8-row truth table.

Example 2: equivalence by algebra

Show (p→q)∧(p→¬q)≡¬p(p \to q) \land (p \to \neg q) \equiv \neg p.

(¬p∨q)∧(¬p∨¬q)≡¬p∨(q∧¬q)≡¬p∨F≡¬p,(\neg p \lor q) \land (\neg p \lor \neg q) \equiv \neg p \lor (q \land \neg q) \equiv \neg p \lor F \equiv \neg p,

using the distributive law in reverse, the negation law and identity.

Example 3: validity of an argument

Premises: "If it rains, the match is cancelled" (r→cr \to c); "If the match is cancelled, we go home" (c→hc \to h); "We did not go home" (¬h\neg h). Conclusion: "It did not rain" (¬r\neg r).

From c→hc \to h and ¬h\neg h, modus tollens gives ¬c\neg c. From r→cr \to c and ¬c\neg c, modus tollens gives ¬r\neg r. Valid.

Now change the conclusion to "It rained" (rr). The row r=F,c=F,h=Fr = F, c = F, h = F makes all three premises true and the conclusion false, so this argument is invalid.

Example 4: counting satisfying assignments

How many of the 8 assignments to p,q,rp, q, r satisfy (p∨q)∧(¬p∨r)(p \lor q) \land (\neg p \lor r)?

  • p=Tp = T: need r=Tr = T; qq is free: 2 assignments.
  • p=Fp = F: need q=Tq = T; rr is free: 2 assignments.

Total 4. (Note that the resolvent q∨rq \lor r is true in all 4, as resolution guarantees.)

Example 5: CNF conversion

Convert ¬(p→(q∧r))\neg(p \to (q \land r)) to CNF.

¬(¬p∨(q∧r))≡p∧¬(q∧r)≡p∧(¬q∨¬r).\neg(\neg p \lor (q \land r)) \equiv p \land \neg(q \land r) \equiv p \land (\neg q \lor \neg r).

This is already a conjunction of two clauses, so it is in CNF (and also in DNF after distributing: (p∧¬q)∨(p∧¬r)(p \land \neg q) \lor (p \land \neg r)).

Important properties and observations

  • p→qp \to q is true whenever pp is false or qq is true. Use the single falsifying row to test an implication.
  • "Only if" reverses the reading: "pp only if qq" is p→qp \to q, not q→pq \to p.
  • "Unless": "pp unless qq" is usually translated ¬q→p\neg q \to p, equivalently p∨qp \lor q.
  • Implication is neither commutative nor associative. The biconditional and xor are both commutative and associative.
  • p⊕q≡¬(p↔q)p \oplus q \equiv \neg(p \leftrightarrow q) and p⊕q⊕rp \oplus q \oplus r is true exactly when an odd number of the three are true.
  • Rewrite each →\to as ¬p∨q\neg p \lor q before simplifying.
  • Validity of an argument is decidable: truth tables give an algorithm with 2n2^n rows. Deciding satisfiability efficiently in general (SAT) is NP-complete, so no polynomial algorithm is known.

GATE examination perspective

  • Tautology and equivalence MCQs/MSQs. Use "try to falsify" for implications; use algebra for equivalences; fall back to a truth table only for small formulas.
  • English-to-logic translation. Watch "only if", "unless", "necessary", "sufficient" and "neither... nor" (¬p∧¬q\neg p \land \neg q).
  • Valid argument questions. Identify modus ponens/tollens chains, and test fallacies by finding a single counterexample row.
  • Counting questions. Number of truth functions 22n2^{2^n}; number of satisfying assignments by case analysis on one variable.
  • Trap: confusing the inverse (¬p→¬q\neg p \to \neg q) with the contrapositive (¬q→¬p\neg q \to \neg p).
  • Trap: treating (p→q)→r(p \to q) \to r as p→(q→r)p \to (q \to r). Check the row p=F,r=Fp = F, r = F: the left side is false, the right side is true.

Summary

Sources

  1. K. H. Rosen, Discrete Mathematics and Its Applications, 7th ed., McGraw-Hill, 2012: Sections 1.1 (Propositional Logic), 1.3 (Propositional Equivalences) and 1.6 (Rules of Inference).

Next steps