Section 1 · 9 min read

Propositional and first order logic

Connectives, equivalences, normal forms, inference rules, quantifiers and the validity questions GATE asks about propositional and predicate logic.

On this page
  1. Propositional logic
  2. First order (predicate) logic
  3. Worked examples
  4. Common traps
  5. Quick revision

GATE asks one or two questions from logic almost every year. They fall into four patterns: decide whether a formula is a tautology, find an equivalent formula, translate English into predicate logic, and decide which first order formulas are valid. All four reward a small set of identities used quickly and correctly.

Propositional logic

Connectives and truth tables

A proposition is a statement that is either true (T) or false (F). Formulas are built with ¬\lnot, ∧\land, ∨\lor, →\to and ↔\leftrightarrow.

pp qq p∧qp \land q p∨qp \lor q p→qp \to q p↔qp \leftrightarrow q p⊕qp \oplus q
T T T T T T F
T F F T F F T
F T F T T F T
F F F F T T F

The only row where p→qp \to q is false is p=T,q=Fp = T, q = F. Almost every tautology check uses this fact: to show A→BA \to B is a tautology, assume AA true and BB false and derive a contradiction.

Classification of formulas

  • Tautology (valid): true in every row.
  • Contradiction (unsatisfiable): false in every row.
  • Satisfiable: true in at least one row.
  • Contingency: satisfiable but not a tautology.

AA is a tautology exactly when ¬A\lnot A is unsatisfiable. AA and BB are logically equivalent (A≡BA \equiv B) exactly when A↔BA \leftrightarrow B is a tautology. AA logically implies BB exactly when A→BA \to B is a tautology.

Equivalences to know by heart

Name Equivalence
Implication p→q≡¬p∨qp \to q \equiv \lnot p \lor q
Contrapositive p→q≡¬q→¬pp \to q \equiv \lnot q \to \lnot p
De Morgan ¬(p∧q)≡¬p∨¬q\lnot(p \land q) \equiv \lnot p \lor \lnot q, ¬(p∨q)≡¬p∧¬q\lnot(p \lor q) \equiv \lnot p \land \lnot q
Negated implication ¬(p→q)≡p∧¬q\lnot(p \to q) \equiv p \land \lnot q
Exportation p→(q→r)≡(p∧q)→rp \to (q \to r) \equiv (p \land q) \to r
Distribution p∨(q∧r)≡(p∨q)∧(p∨r)p \lor (q \land r) \equiv (p \lor q) \land (p \lor r)
Absorption p∨(p∧q)≡pp \lor (p \land q) \equiv p, p∧(p∨q)≡pp \land (p \lor q) \equiv p
Biconditional p↔q≡(p→q)∧(q→p)≡(p∧q)∨(¬p∧¬q)p \leftrightarrow q \equiv (p \to q) \land (q \to p) \equiv (p \land q) \lor (\lnot p \land \lnot q)
Case split (p→r)∧(q→r)≡(p∨q)→r(p \to r) \land (q \to r) \equiv (p \lor q) \to r
(p→q)∧(p→r)≡p→(q∧r)(p \to q) \land (p \to r) \equiv p \to (q \land r)

Two non-equivalences show up as distractors: (p→q)→r(p \to q) \to r is not the same as p→(q→r)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.

The converse q→pq \to p and the inverse ¬p→¬q\lnot p \to \lnot q are equivalent to each other but not to p→qp \to q.

Normal forms and functional completeness

Every formula has a CNF (AND of clauses, each an OR of literals) and a DNF (OR of terms, each an AND of literals). Read the DNF off the true rows of the truth table and the CNF off the false rows.

A set of connectives is functionally complete if it can express every Boolean function. {¬,∧}\{\lnot, \land\}, {¬,∨}\{\lnot, \lor\}, {¬,→}\{\lnot, \to\}, {NAND}\{\text{NAND}\} and {NOR}\{\text{NOR}\} are complete. {∧,∨}\{\land, \lor\}, {∧,∨,→,↔}\{\land, \lor, \to, \leftrightarrow\} and {⊕,↔}\{\oplus, \leftrightarrow\} are not: the first two cannot produce F when all inputs are T, and the last can only produce affine (XOR-type) functions. Also, {→,F}\{\to, F\} is complete because ¬p≡p→F\lnot p \equiv p \to F.

There are 22n2^{2^n} distinct Boolean functions of nn variables, so 22n2^{2^n} pairwise non-equivalent formulas.

Rules of inference

An argument with premises P1,…,PkP_1, \dots, P_k and conclusion CC is valid when (P1∧⋯∧Pk)→C(P_1 \land \dots \land P_k) \to C is a tautology.

Rule From Infer
Modus ponens pp, p→qp \to q qq
Modus tollens ¬q\lnot q, p→qp \to q ¬p\lnot p
Hypothetical syllogism p→qp \to q, q→rq \to r p→rp \to r
Disjunctive syllogism p∨qp \lor q, ¬p\lnot p qq
Resolution p∨qp \lor q, ¬p∨r\lnot p \lor r q∨rq \lor r
Constructive dilemma p→qp \to q, r→sr \to s, p∨rp \lor r q∨sq \lor s

Two classical fallacies: affirming the consequent (qq, p→qp \to q, so pp) and denying the antecedent (¬p\lnot p, p→qp \to q, so ¬q\lnot q).

First order (predicate) logic

Quantifiers

∀x P(x)\forall x\, P(x) is true when PP holds for every element of the domain; ∃x P(x)\exists x\, P(x) when it holds for at least one. On a finite domain {a1,…,an}\{a_1, \dots, a_n\}, ∀\forall is a big AND and ∃\exists is a big OR. That view makes most validity questions mechanical.

Negation moves quantifiers across: ¬∀x P(x)≡∃x ¬P(x),¬∃x P(x)≡∀x ¬P(x).\lnot \forall x\, P(x) \equiv \exists x\, \lnot P(x), \qquad \lnot \exists x\, P(x) \equiv \forall x\, \lnot P(x).

Distribution laws

Formula Status
∀x (P∧Q)↔∀x P∧∀x Q\forall x\,(P \land Q) \leftrightarrow \forall x\, P \land \forall x\, Q valid
∃x (P∨Q)↔∃x P∨∃x Q\exists x\,(P \lor Q) \leftrightarrow \exists x\, P \lor \exists x\, Q valid
∀x P∨∀x Q→∀x (P∨Q)\forall x\, P \lor \forall x\, Q \to \forall x\,(P \lor Q) valid, converse not valid
∃x (P∧Q)→∃x P∧∃x Q\exists x\,(P \land Q) \to \exists x\, P \land \exists x\, Q valid, converse not valid
∃x ∀y R(x,y)→∀y ∃x R(x,y)\exists x\, \forall y\, R(x,y) \to \forall y\, \exists x\, R(x,y) valid, converse not valid
∀x ∀y↔∀y ∀x\forall x\, \forall y \leftrightarrow \forall y\, \forall x, same for ∃∃\exists\exists valid

A quick memory aid: ∀\forall is AND-like, so it distributes over AND; ∃\exists is OR-like, so it distributes over OR.

When xx does not occur free in QQ: ∀x (P(x)→Q)≡∃x P(x)→Q\forall x\,(P(x) \to Q) \equiv \exists x\, P(x) \to Q and ∃x (P(x)→Q)≡∀x P(x)→Q\exists x\,(P(x) \to Q) \equiv \forall x\, P(x) \to Q. The quantifier flips when it moves out of the antecedent. This trips up many candidates.

Translating English

The standard patterns:

English Formula
Every AA is BB ∀x (A(x)→B(x))\forall x\,(A(x) \to B(x))
Some AA is BB ∃x (A(x)∧B(x))\exists x\,(A(x) \land B(x))
No AA is BB ∀x (A(x)→¬B(x))\forall x\,(A(x) \to \lnot B(x))
Not every AA is BB ∃x (A(x)∧¬B(x))\exists x\,(A(x) \land \lnot B(x))
Only AAs are BB ∀x (B(x)→A(x))\forall x\,(B(x) \to A(x))

Rule of thumb: ∀\forall pairs with →\to, and ∃\exists pairs with ∧\land. ∃x (A(x)→B(x))\exists x\,(A(x) \to B(x)) is almost always wrong, because any xx outside AA makes it true.

Worked examples

Worked example 1: Tautology by contradiction

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

  1. Assume it is false. Then r=Fr = F and the antecedent is true.
  2. p→rp \to r true with r=Fr = F forces p=Fp = F. Likewise q=Fq = F.
  3. Then p∨q=Fp \lor q = F, contradicting the antecedent being true.

No falsifying row exists, so it is a tautology (it is the case split rule).

Worked example 2: Counting satisfying assignments

How many assignments to a,b,c,da, b, c, d satisfy (a↔b)∧(c⊕d)(a \leftrightarrow b) \land (c \oplus d)?

The two conjuncts share no variables. a↔ba \leftrightarrow b is true for 2 of the 4 assignments to (a,b)(a, b), and c⊕dc \oplus d for 2 of the 4 assignments to (c,d)(c, d). Answer: 2×2=42 \times 2 = 4 out of 16.

When conjuncts share no variables, multiply counts. When they share variables, split on a shared variable and count each branch.

Worked example 3: Negating a nested statement

Negate "for every ε>0\varepsilon > 0 there is a δ>0\delta > 0 such that for all xx, ∣x∣<δ→∣f(x)∣<ε|x| < \delta \to |f(x)| < \varepsilon".

Formula: ∀ε ∃δ ∀x (∣x∣<δ→∣f(x)∣<ε)\forall \varepsilon\, \exists \delta\, \forall x\,(|x| < \delta \to |f(x)| < \varepsilon), with the domain restrictions on ε,δ\varepsilon, \delta understood.

Flip each quantifier and negate the matrix: ∃ε ∀δ ∃x (∣x∣<δ∧∣f(x)∣≥ε).\exists \varepsilon\, \forall \delta\, \exists x\,\big(|x| < \delta \land |f(x)| \ge \varepsilon\big).

Worked example 4: Validity on a small domain

Is ∀x ∃y R(x,y)→∃y ∀x R(x,y)\forall x\, \exists y\, R(x,y) \to \exists y\, \forall x\, R(x,y) valid?

Try the domain {1,2}\{1, 2\} with R={(1,1),(2,2)}R = \{(1,1), (2,2)\}, which is equality. Every xx has a partner (y=xy = x), so the left side is true. No single yy is related to both 1 and 2, so the right side is false. The formula is not valid. To refute validity, one small counter-model is enough. To prove validity, argue from the meaning of the quantifiers as in the distribution table.

Worked example 5: Which conclusion follows

Premises: "If it rains, the match is cancelled", "If the match is cancelled, tickets are refunded", "Tickets were not refunded". Let r,c,fr, c, f be the three atoms. Premises: r→cr \to c, c→fc \to f, ¬f\lnot f.

  1. Hypothetical syllogism: r→fr \to f.
  2. Modus tollens with ¬f\lnot f: ¬r\lnot r.
  3. Also ¬c\lnot c by modus tollens on c→fc \to f.

Valid conclusions: ¬r\lnot r, ¬c\lnot c, and anything they imply, such as ¬r∨x\lnot r \lor x for any xx.

Common traps

  • Treating p→qp \to q as false when pp is false. A false antecedent makes the implication true (vacuous truth).
  • Thinking →\to is associative. (p→q)→r(p \to q) \to r and p→(q→r)p \to (q \to r) differ at p=F,r=Fp = F, r = F.
  • Writing ∃x (A(x)→B(x))\exists x\,(A(x) \to B(x)) for "some AA is BB".
  • Distributing ∀\forall over ∨\lor or ∃\exists over ∧\land.
  • Swapping ∃x ∀y\exists x\, \forall y and ∀y ∃x\forall y\, \exists x. Only ∃∀→∀∃\exists\forall \to \forall\exists is valid.
  • Pulling a quantifier out of the antecedent of an implication without flipping it.
  • In "only if" sentences: "pp only if qq" means p→qp \to q, not q→pq \to p.
  • "pp unless qq" means ¬q→p\lnot q \to p, which is p∨qp \lor q.

Quick revision

  • p→q≡¬p∨q≡¬q→¬pp \to q \equiv \lnot p \lor q \equiv \lnot q \to \lnot p. ¬(p→q)≡p∧¬q\lnot(p \to q) \equiv p \land \lnot q.
  • Tautology check: assume the implication false, look for a contradiction.
  • Exportation: p→(q→r)≡(p∧q)→rp \to (q \to r) \equiv (p \land q) \to r.
  • (p→r)∧(q→r)≡(p∨q)→r(p \to r) \land (q \to r) \equiv (p \lor q) \to r; (p→r)∨(q→r)≡(p∧q)→r(p \to r) \lor (q \to r) \equiv (p \land q) \to r.
  • 22n2^{2^n} distinct Boolean functions of nn variables.
  • NAND and NOR alone are complete; {∧,∨}\{\land, \lor\} is not.
  • ¬∀≡∃¬\lnot\forall \equiv \exists\lnot, ¬∃≡∀¬\lnot\exists \equiv \forall\lnot.
  • ∀\forall distributes over ∧\land; ∃\exists distributes over ∨\lor.
  • ∃x ∀y→∀y ∃x\exists x\, \forall y \to \forall y\, \exists x is valid; the converse is not.
  • ∀\forall goes with →\to, ∃\exists goes with ∧\land.
  • One counter-model on a 2 element domain is enough to show a formula is not valid.

Further reading

Test this section