3.1.5Boolean Algebra & Logic Gates

Truth tables construction

2,083 words9 min readdifficulty · medium

What is a truth table? (WHAT)

WHY 2n2^n? Each input can independently take 2 values (0 or 1). With nn independent inputs, by the multiplication principle the number of combinations is

2×2××2n times=2n.\underbrace{2 \times 2 \times \cdots \times 2}_{n \text{ times}} = 2^n .

HOW to construct one — the recipe

Step-by-step method:

  1. Count the inputs → decide the number of rows =2n= 2^n.
  2. Make the input columns. A reliable pattern (standard convention): the rightmost column alternates 0,1,0,1,0,1,0,1,\dots; the next column alternates in pairs 0,0,1,10,0,1,1; the next in fours 0,0,0,0,1,1,1,10,0,0,0,1,1,1,1; etc. Column from left = MSB.
  3. Break the expression into intermediate columns (one per gate/sub-expression). This is the divide-and-conquer trick.
  4. Evaluate row by row, filling intermediates first, then the final output.
  5. Sanity-check the row count and a couple of extreme rows (all-0s, all-1s).
Figure — Truth tables construction

Worked example 1 — F=ABF = A \cdot B (AND), 2 inputs

WHY start here: 2 inputs → 22=42^2 = 4 rows. AND outputs 1 only when both are 1.

AA BB F=ABF=A\cdot B
0 0 0
0 1 0
1 0 0
1 1 1
  • Why this step (rows): 22=42^2=4, so exactly 4 rows — no more, no fewer.
  • Why the pattern: right column 0,1,0,10,1,0,1; left column 0,0,1,10,0,1,1 → all 4 combos appear once.
  • Why the outputs: AND = "all true", so only the last row (both 1) gives 1.

Worked example 2 — F=A+BF = \overline{A} + B , 2 inputs

We introduce an intermediate column A\overline{A} (NOT A), then OR it with BB.

AA BB A\overline{A} F=A+BF=\overline{A}+B
0 0 1 1
0 1 1 1
1 0 0 0
1 1 1 1
  • Why the A\overline{A} column: we compute the inside of the expression first so the final OR is trivial (Feynman: solve the small piece, then combine).
  • Why row 3 = 0: A=1A=0A=1 \Rightarrow \overline A =0, and B=0B=0, so 0+0=00+0=0. Every other row has at least one 1, so OR gives 1.
  • Insight: this table is identical to the material implication ABA \Rightarrow B. Same table ⇒ logically the same function.

Worked example 3 — 3 inputs: F=AB+CF = A\cdot B + \overline{C}

WHY: 3 inputs → 23=82^3 = 8 rows. We use two intermediate columns: ABA\cdot B and C\overline C.

AA BB CC ABA\cdot B C\overline C F=AB+CF=A\cdot B+\overline C
0 0 0 0 1 1
0 0 1 0 0 0
0 1 0 0 1 1
0 1 1 0 0 0
1 0 0 0 1 1
1 0 1 0 0 0
1 1 0 1 1 1
1 1 1 1 0 1
  • Why the column ordering: CC (rightmost) toggles every row 0,1,0,10,1,0,1\dots; BB toggles every 2; AA every 4. Guarantees all 8 combos.
  • Why the last row = 1: AB=1A\cdot B = 1, so OR is 1 regardless of C=0\overline C=0.
  • Why row 2 = 0: AB=0A\cdot B=0 and C=0\overline C = 0 (since C=1C=1) → 0+0=00+0=0.
  • 80/20 takeaway: once you can build the intermediate columns, any expression becomes mechanical.

Common mistakes (Steel-man + fix)


Active recall

Recall Cover the answers and test yourself
  • How many rows for nn inputs? → 2n2^n.
  • Why 2n2^n and not 2n2n? → independent inputs multiply choices.
  • What guarantees you list every combination once? → counting in binary 02n10\to 2^n-1.
  • What is the safest way to evaluate a complex expression? → build intermediate columns, NOT→AND→OR.
  • Two circuits have the same truth table — what does that mean? → they are logically equivalent.
Recall Feynman: explain to a 12-year-old

Imagine a light that turns on depending on some switches. A truth table is just a list of every way you could flip the switches, and for each way it tells you: is the light ON or OFF? To make sure you don't forget any switch-pattern, you count "0,1,2,3…" but in the robot's counting system (binary), where digits are only 0 and 1. Each count = one row. Then you check the rule for each row and write ON (1) or OFF (0). That's the whole magic — no guessing, everything is listed.


Connections

How many rows does a truth table with nn inputs have?
2n2^n
Why is it 2n2^n and not 2n2n?
Each input is independent with 2 possible values, so choices multiply: 2×2×=2n2\times2\times\cdots=2^n.
What is the reliable method to list all input combinations exactly once?
Count in binary from 00 to 2n12^n-1, padding each number to nn bits.
In the standard column pattern, how does the rightmost input column vary?
It alternates 0,1,0,1,0,1,0,1,\dots every single row.
What is the correct operator precedence when evaluating?
NOT first, then AND, then OR.
Why use intermediate columns when constructing a table?
They break the expression into small pieces, respect precedence, and reduce evaluation errors.
Two different circuits produce the same truth table — what can you conclude?
They are logically equivalent (perform the same function).
Give the output column of F=ABF=A\cdot B for inputs (00,01,10,11).
0,0,0,1
Give the output column of XOR ABA\oplus B for (00,01,10,11).
0,1,1,0 (1 when inputs differ).
How many rows for a 4-input function?
24=162^4 = 16.

Concept Map

captured by

lists

each 2 values

multiplication principle

recurrence R n = 2 R n-1

listed by

guarantees

split into

divide and conquer

same table means

verified by

Digital circuit promise

Truth table

Every input combination

n inputs

2^n rows

Count in binary 0 to 2^n-1

Complete no repeats

Intermediate gate columns

Final output value

Logically identical circuits

Sanity-check extreme rows

Hinglish (regional understanding)

Intuition Hinglish mein samjho

Dekho, ek truth table basically ek poori list hai har possible input combination ki, aur har combination ke liye output kya hoga — 0 ya 1. Agar circuit me nn inputs hain, to total rows 2n2^n hote hain, kyunki har input independently 2 values (0 ya 1) le sakta hai, to choices multiply hoti hain: 2×2×=2n2\times2\times\dots = 2^n. Yaad rakhna — 2n2n nahi, 2n2^n! Ye sabse common galti hai.

Banane ka easy tarika: binary me count karo 0 se lekar 2n12^n-1 tak. Har number ek row ban jaata hai, aur is se guarantee hota hai ki koi combination na chhoote na repeat ho. Convention: sabse right wala column 0,1,0,10,1,0,1 toggle karta hai har row, uske left wala 0,0,1,10,0,1,1 (pairs me), phir 0,0,0,0,1,1,1,10,0,0,0,1,1,1,1 (fours me). Ye pattern hamesha kaam karta hai.

Jab expression bada ho (jaise AB+CA\cdot B + \overline{C}), to seedhe mat solve karo — intermediate columns banao. Pehle ABA\cdot B ka column, phir C\overline{C} ka column, phir dono ko OR karke final FF. Precedence yaad rakho: pehle NOT, phir AND, phir OR (bilkul jaise maths me pehle multiply phir add). Isse mistakes kam ho jaati hain.

Ye topic kyun important hai? Kyunki agar do circuits ka truth table same hai, to wo logically equivalent hain — chahe dikhne me alag hon. Isi liye Boolean laws prove karne, K-map banane, aur SOP nikaalne me truth table hi foundation hai. Ek baar table bana lo, baaki sab mechanical ho jaata hai — that's the 80/20 power move!

Go deeper — visual, from zero

Test yourself — Boolean Algebra & Logic Gates

Connections