Siksha Sarovar

Siksha Sarovar (sikshasarovar.com) is a free educational web application that helps students in India learn programming and prepare for academic and competitive exams. The platform offers structured coding courses (C, C++, Python, Java, HTML, CSS, PHP, Power BI, AI, Machine Learning, Data Science), complete university curriculum notes for BCA/MCA students with previous year question papers, Class 10 and Class 12 CBSE/HBSE school notes, and dedicated preparation material for SSC, UPSC, Banking, Railway and other government exams. Browsing the site is completely free and requires no account. Users may optionally sign in with Google solely to save their learning progress, quiz scores and personal preferences across devices.

Privacy Policy | Terms of Service | Contact Siksha Sarovar | About Siksha Sarovar

v4.0.9 · PWA
Siksha Sarovar logo
Siksha Sarovar
Your Learning Universe

Siksha Sarovar is a free e-learning platform for coding courses, BCA university notes and competitive exam preparation. Optional Google sign-in saves your learning progress across devices.

Initializing knowledge base…
Compiling modules 0%

Unit 2: Propositional Logic, Truth Tables & Normal Forms

Lesson 5 of 17 in the free Mathematical Foundation of CS notes on Siksha Sarovar, written by Rohit Jangra.

4.1 Propositions and Connectives

A proposition is a declarative sentence that is definitively true (T) or false (F). "2 + 2 = 5" is a (false) proposition; "x + 1 = 3" and "Close the door" are not. Compound propositions are built with connectives, listed in decreasing precedence:

ConnectiveSymbolRead asTrue exactly when
Negation¬pnot pp is false
Conjunctionp ∧ qp and qboth true
Disjunctionp ∨ qp or q (inclusive)at least one true
Exclusive orp ⊕ qexactly one of p, qtruth values differ
Implicationp → qif p then qevery case except p = T, q = F
Biconditionalp ↔ qp iff qtruth values match

The implication row surprises students: when p is false, p → q is vacuously true. "If 1 = 2, then I am the President" is a true proposition. Related forms of p → q: converse q → p, inverse ¬p → ¬q, contrapositive ¬q → ¬p. Only the contrapositive is equivalent to the original; converse and inverse are equivalent to each other.

4.2 Truth Tables, Tautologies and Contradictions

A truth table for n variables has 2^n rows. A proposition is a tautology if every row is T (e.g., p ∨ ¬p), a contradiction if every row is F (e.g., p ∧ ¬p), and a contingency otherwise. Two propositions are logically equivalent (P ≡ Q) when P ↔ Q is a tautology.

4.3 Worked Example 1 — Prove (p → q) ≡ (¬p ∨ q)

pqp → q¬p¬p ∨ q
TTTFT
TFFFF
FTTTT
FFTTT

Columns 3 and 5 are identical in every row, hence p → q ≡ ¬p ∨ q. ∎ An immediate corollary by De Morgan: ¬(p → q) ≡ p ∧ ¬q — the only way an implication fails.

4.4 The Standard Equivalences (Law Table)

Law∧-form∨-form
Identityp ∧ T ≡ pp ∨ F ≡ p
Dominationp ∧ F ≡ Fp ∨ T ≡ T
Idempotentp ∧ p ≡ pp ∨ p ≡ p
Commutativep ∧ q ≡ q ∧ pp ∨ q ≡ q ∨ p
Associative(p ∧ q) ∧ r ≡ p ∧ (q ∧ r)(p ∨ q) ∨ r ≡ p ∨ (q ∨ r)
Distributivep ∧ (q ∨ r) ≡ (p ∧ q) ∨ (p ∧ r)p ∨ (q ∧ r) ≡ (p ∨ q) ∧ (p ∨ r)
De Morgan¬(p ∧ q) ≡ ¬p ∨ ¬q¬(p ∨ q) ≡ ¬p ∧ ¬q
Absorptionp ∧ (p ∨ q) ≡ pp ∨ (p ∧ q) ≡ p
Double negation¬(¬p) ≡ p

4.5 Normal Forms: DNF and CNF

  • DNF (Disjunctive Normal Form): an OR of AND-clauses, e.g., (p ∧ q) ∨ (¬p ∧ r).
  • CNF (Conjunctive Normal Form): an AND of OR-clauses, e.g., (p ∨ q) ∧ (¬q ∨ r). SAT solvers consume CNF.
  • Principal DNF (PDNF): OR of minterms — each clause contains every variable exactly once. One minterm per T-row of the truth table.
  • Principal CNF (PCNF): AND of maxterms, one per F-row (negate each variable that is T in that row).

Truth-table method for F = p ↔ q: T-rows are (T,T) and (F,F); F-rows are (T,F) and (F,T).

  • PDNF: (p ∧ q) ∨ (¬p ∧ ¬q)
  • PCNF: (¬p ∨ q) ∧ (p ∨ ¬q)

4.6 Worked Example 2 — PDNF by the Algebraic Method

Problem: Expand F(p, q, r) = (p ∧ q) ∨ (¬p ∧ r) into PDNF (every clause must mention p, q, and r).

  1. p ∧ q is missing r; multiply by the tautology (r ∨ ¬r): p ∧ q ≡ (p ∧ q ∧ r) ∨ (p ∧ q ∧ ¬r).
  2. ¬p ∧ r is missing q: ¬p ∧ r ≡ (¬p ∧ q ∧ r) ∨ (¬p ∧ ¬q ∧ r).
  3. PDNF: (p ∧ q ∧ r) ∨ (p ∧ q ∧ ¬r) ∨ (¬p ∧ q ∧ r) ∨ (¬p ∧ ¬q ∧ r) — minterms m7, m6, m3, m1.

Quick CNF conversion example: p → (q → r) ≡ ¬p ∨ (¬q ∨ r) ≡ ¬p ∨ ¬q ∨ r, a single clause.

4.7 Common Mistakes & CS Applications

  • Treating p → q as false when p is false — it is true.
  • Confusing ≡ (a meta-statement about all rows) with ↔ (a connective inside a formula).
  • Forgetting that "or" in logic is inclusive unless ⊕ is written.
  • Applications: compiler optimizers apply De Morgan and absorption to simplify branch conditions; database query planners normalize WHERE clauses to CNF; model checkers and SAT/SMT solvers verify hardware by testing satisfiability; digital circuits are propositional formulas in silicon (Unit 4).

🎯 Exam Focus

  1. Construct the truth table of (p → q) ∧ (q → r) → (p → r) and show it is a tautology.
  2. Using laws only (no truth table), prove ¬(p ∨ (¬p ∧ q)) ≡ ¬p ∧ ¬q. Name each law used.
  3. Define tautology, contradiction, and contingency with one example each.
  4. Obtain the PDNF and PCNF of (p ∧ q) ∨ (¬p ∧ r).
  5. Write the converse, inverse, and contrapositive of "If a number is divisible by 6, then it is divisible by 3." Which are true?
  6. Show that (p ⊕ q) ≡ (p ∨ q) ∧ ¬(p ∧ q).