Intuition The big picture
The three basic gates are AND, OR, NOT. Everything else is built from them.
XOR and XNOR detect difference/sameness — they answer "are these inputs different?"
NAND and NOR are just AND/OR with the output inverted — but they are secretly the most powerful gates: each one alone can build every logic circuit (they are universal ).
WHY care? Real chips are made almost entirely of NAND (or NOR) transistors because they are cheap and universal, and XOR is the heart of adders, parity checkers and comparators.
Output is 0 0 0 only when all inputs are 1 1 1 . Otherwise output is 1 1 1 .
A NAND B = A ⋅ B ‾ A \text{ NAND } B = \overline{A \cdot B} A NAND B = A ⋅ B
WHY this formula? NAND literally means "invert the AND". So take AND (A ⋅ B A\cdot B A ⋅ B ), then NOT it (the overbar). Nothing more.
A
B
A·B
NAND = A ⋅ B ‾ \overline{A\cdot B} A ⋅ B
0
0
0
1
0
1
0
1
1
0
0
1
1
1
1
0
Output is 1 1 1 only when all inputs are 0 0 0 .
A NOR B = A + B ‾ A \text{ NOR } B = \overline{A + B} A NOR B = A + B
WHY? Invert the OR. OR is 1 1 1 if any input is 1 1 1 ; inverting it means output is 1 1 1 only when nothing is 1 1 1 .
A
B
A+B
NOR = A + B ‾ \overline{A+B} A + B
0
0
0
1
0
1
1
0
1
0
1
0
1
1
1
0
Output is 1 1 1 when inputs are different .
A ⊕ B = A ‾ B + A B ‾ A \oplus B = \overline{A}B + A\overline{B} A ⊕ B = A B + A B
HOW do we derive that expression? Read the truth table and use Sum-Of-Products : write one AND term for each row that outputs 1 1 1 , then OR them.
A
B
XOR
Which row?
0
0
0
—
0
1
1
A ‾ B \overline{A}B A B
1
0
1
A B ‾ A\overline{B} A B
1
1
0
—
Rows that give 1 1 1 : A = 0 , B = 1 A{=}0,B{=}1 A = 0 , B = 1 → A ‾ B \overline{A}B A B , and A = 1 , B = 0 A{=}1,B{=}0 A = 1 , B = 0 → A B ‾ A\overline{B} A B . OR them:
A ⊕ B = A ‾ B + A B ‾ A\oplus B = \overline{A}B + A\overline{B} A ⊕ B = A B + A B
Output is 1 1 1 when inputs are the same . It is the inverse of XOR.
A ⊙ B = A ⊕ B ‾ = A B + A ‾ B ‾ A \odot B = \overline{A\oplus B} = AB + \overline{A}\,\overline{B} A ⊙ B = A ⊕ B = A B + A B
WHY A B + A ‾ B ‾ AB + \overline{A}\,\overline{B} A B + A B ? Same SOP trick: the "same" rows are A = B = 0 A{=}B{=}0 A = B = 0 (→ A ‾ B ‾ \overline{A}\,\overline{B} A B ) and A = B = 1 A{=}B{=}1 A = B = 1 (→ A B AB A B ).
Intuition One gate to build them all
If you can make NOT, AND, OR from a single gate type, you can make any circuit from it. NAND can do all three, so NAND is universal . Same for NOR.
Deriving the three basics from NAND (from first principles):
NOT: tie both inputs together. A NAND A = A ⋅ A ‾ = A ‾ A \text{ NAND } A = \overline{A\cdot A} = \overline{A} A NAND A = A ⋅ A = A . ✅
Why this step? A ⋅ A = A A\cdot A = A A ⋅ A = A (idempotence), so the overbar gives A ‾ \overline A A .
AND: NAND then NOT. A ⋅ B ‾ ‾ = A ⋅ B \overline{\overline{A\cdot B}} = A\cdot B A ⋅ B = A ⋅ B . So AND = (A NAND B) fed into a NAND-as-NOT. ✅
OR: invert each input first, then NAND: A ‾ ⋅ B ‾ ‾ = A + B \overline{\overline A \cdot \overline B} = A + B A ⋅ B = A + B by De Morgan . ✅
That is why the chip industry can etch billions of identical NAND cells and wire them into anything.
Worked example Example 1 — Evaluate a NAND expression
Compute 1 ⋅ 0 ‾ \overline{1 \cdot 0} 1 ⋅ 0 .
Step 1: 1 ⋅ 0 = 0 1\cdot 0 = 0 1 ⋅ 0 = 0 . Why? AND needs both 1 1 1 ; one is 0 0 0 .
Step 2: 0 ‾ = 1 \overline{0} = 1 0 = 1 . Why? NOT flips it.
Result: 1 1 1 .
Worked example Example 2 — XOR as a parity detector
You have bits 1 , 0 , 1 1,0,1 1 , 0 , 1 . Is the number of 1s odd? Chain XORs: 1 ⊕ 0 = 1 1\oplus 0 = 1 1 ⊕ 0 = 1 , then 1 ⊕ 1 = 0 1 \oplus 1 = 0 1 ⊕ 1 = 0 .
Result 0 0 0 → even number of 1s.
Why this works? XOR outputs 1 1 1 only for an odd count of 1 1 1 s, because each extra 1 1 1 toggles the result.
Worked example Example 3 — Build XOR from NAND only (4 NANDs)
$$A\oplus B = \big(A \barwedge (A\barwedge B)\big)\ \barwedge\ \big(B\barwedge(A\barwedge B)\big)w h e r e where w h er e \barwedge= N A N D . ∗ ∗ C h e c k w i t h = NAND.
**Check with = N A N D . ∗ ∗ C h ec k w i t h A=1,B=0$:**
Step 1: A ⊼ B = 1 ⋅ 0 ‾ = 1 A\barwedge B = \overline{1\cdot0}=1 A ⊼ B = 1 ⋅ 0 = 1 . Why? NAND of (1,0).
Step 2: A ⊼ 1 = 1 ⋅ 1 ‾ = 0 A\barwedge 1 = \overline{1\cdot1}=0 A ⊼ 1 = 1 ⋅ 1 = 0 .
Step 3: B ⊼ 1 = 0 ⋅ 1 ‾ = 1 B\barwedge 1 = \overline{0\cdot1}=1 B ⊼ 1 = 0 ⋅ 1 = 1 .
Step 4: 0 ⊼ 1 = 0 ⋅ 1 ‾ = 1 0 \barwedge 1 = \overline{0\cdot1}=1 0 ⊼ 1 = 0 ⋅ 1 = 1 . ✅ matches 1 ⊕ 0 = 1 1\oplus0=1 1 ⊕ 0 = 1 .
Common mistake "NAND is the same as AND-then-nothing"
Why it feels right: the name starts with "AND", so people copy the AND table and forget the invert.
Fix: NAND = NOT(AND) . Its output is the opposite of AND everywhere. Only row (1,1) gives 0.
Common mistake "XOR and OR are basically the same"
Why it feels right: for (0,1) and (1,0) they agree, giving 1 1 1 .
Fix: they differ on (1,1): OR = 1 =1 = 1 , XOR = 0 =0 = 0 . XOR = "different", OR = "at least one".
A + B ‾ = A ‾ + B ‾ \overline{A+B} = \overline A + \overline B A + B = A + B "
Why it feels right: distributing the bar looks natural, like algebra.
Fix: De Morgan flips the operator: A + B ‾ = A ‾ ⋅ B ‾ \overline{A+B} = \overline A \cdot \overline B A + B = A ⋅ B . NOR becomes AND of inverses.
Recall Feynman: explain to a 12-year-old
Imagine two light switches.
XOR: the hallway light is ON only if the two switches disagree — one up, one down.
XNOR: light is ON only if they agree .
NAND: a lazy alarm that stays quiet only when both buttons are pressed together.
NOR: a picky alarm that beeps only when nobody touches any button.
And the magic trick: with a big enough pile of the NAND alarm you can rebuild every other gate — like LEGO where one brick makes everything.
Mnemonic Remember the outputs
N AND / N OR = N egated versions (add a bubble to AND/OR).
XOR = "eXclusively different" → 1 when Different.
XNOR = "eХactly same" → 1 when Same.
Universality: "NAND & NOR are the ONLY loners that can throw a whole party."
Row where NAND outputs 0? 2. Why is NOT possible from a single NAND? 3. XOR of (1,1)? 4. De Morgan for NOR?
When is NAND output 0? Only when all inputs are 1 (it is the inverse of AND).
When is NOR output 1? Only when all inputs are 0 (inverse of OR).
XOR outputs 1 when...? The inputs are different.
XNOR outputs 1 when...? The inputs are the same (equivalence).
Boolean expression for XOR? A ‾ B + A B ‾ \overline{A}B + A\overline{B} A B + A B .
Boolean expression for XNOR? A B + A ‾ B ‾ AB + \overline{A}\,\overline{B} A B + A B .
How do you make NOT from one NAND? Tie both inputs together:
A NAND A = A ‾ A\,\text{NAND}\,A = \overline{A} A NAND A = A .
Why is NAND called universal? NOT, AND, OR can all be built from NAND alone, so any circuit can.
De Morgan for NOR? A + B ‾ = A ‾ ⋅ B ‾ \overline{A+B} = \overline{A}\cdot\overline{B} A + B = A ⋅ B .
XOR of the bits 1,0,1 (chained) equals? 0 — an even number of 1s.
Difference between OR and XOR? They differ only at (1,1): OR=1, XOR=0.
How to build OR from NAND? Invert each input then NAND:
A ‾ ⋅ B ‾ ‾ = A + B \overline{\overline A \cdot \overline B} = A+B A ⋅ B = A + B .
Boolean Algebra Laws — De Morgan's theorem powers all these conversions
AND, OR, NOT gates — the basics these are built from
Sum of Products (SOP) — how XOR/XNOR expressions are derived
Half Adder and Full Adder — XOR = sum bit, AND = carry
Parity Bits & Error Detection — chained XOR checks parity
Karnaugh Maps — simplifying gate expressions
Universal Gates — NAND/NOR completeness
Intuition Hinglish mein samjho
Dekho, sabse pehle base gates hote hain AND, OR, NOT. Baaki sab inhi se bante hain. XOR ka matlab hai "dono inputs alag ho to output 1" — yaani difference detector. XNOR ulta hai: "dono same ho to 1" — equivalence check. Adder aur parity checker mein XOR hi dil ki tarah kaam karta hai.
NAND aur NOR actually AND aur OR ke upar ek bubble (NOT) laga dete hain. NAND ka output sirf tab 0 hota hai jab dono input 1 ho; NOR ka output sirf tab 1 hota hai jab dono input 0 ho. Yaad rakhne ka easy tareeka: N lagao to output ulta ho jaata hai.
Ab sabse important cheez — NAND aur NOR ko universal gates bolte hain. Iska matlab: sirf NAND se hi tum NOT, AND, OR — sab bana sakte ho. NOT banane ke liye dono input ek saath jod do (A NAND A = A ‾ A\,\text{NAND}\,A = \overline A A NAND A = A ). Isi wajah se real chips mein billions of identical NAND cells hote hain, kyunki ek hi type ki gate se poora processor ban jaata hai — cheap aur simple.
Ek common galti: log sochte hain A + B ‾ = A ‾ + B ‾ \overline{A+B} = \overline A + \overline B A + B = A + B . Galat! De Morgan kehta hai operator flip hota hai: A + B ‾ = A ‾ ⋅ B ‾ \overline{A+B} = \overline A \cdot \overline B A + B = A ⋅ B . Yeh rule hi NAND/NOR conversions ka engine hai, isko pakka yaad rakhna.