3.1.13Boolean Algebra & Logic Gates

Quine-McCluskey method

2,119 words10 min readdifficulty · medium2 backlinks

1. First principles: what are we even doing?


2. The algorithm (WHAT / HOW)

Goal: minimize f(A,B,C,D)=m(0,1,2,5,6,7,8,9,10,14)f(A,B,C,D)=\sum m(0,1,2,5,6,7,8,9,10,14).

Step 0 — List minterms in binary, group by number of 1s

Grouping by 1-count guarantees you only ever compare adjacent groups (a Hamming-1 neighbour must differ in exactly one 1).

Group (#1s) Minterm ABCD
0 0 0000
1 1 0001
1 2 0010
1 8 1000
2 5 0101
2 6 0110
2 9 1001
2 10 1010
3 7 0111
3 14 1110

Step 1 — Combine adjacent groups (size-2 terms)

Compare each term with every term in the next group. If they differ in one bit, combine and put - at that position. Tick (✓) every term that gets used (a ticked term is not prime by itself).

Pair ABCD
0,1 000-
0,2 00-0
0,8 -000
1,5 0-01
1,9 -001
2,6 0-10
2,10 -010
8,9 100-
8,10 10-0
5,7 01-1
6,7 011-
6,14 -110
10,14 1-10

Step 2 — Combine again (size-4 terms)

Two size-2 terms combine only if they have - in the same position AND differ in one bit.

Quad ABCD
0,1,8,9 -00-
0,2,8,10 -0-0
2,6,10,14 --10

No size-8 terms possible. Anything never ticked is a prime implicant.

Step 3 — Prime Implicant Chart

Rows = PIs, columns = original minterms. Mark ✗ where a PI covers a minterm.

Figure — Quine-McCluskey method

Find EPIs: scan each column. If a minterm is covered by exactly one PI, that PI is essential.

  • m9m9 covered only by PI1PI_1EPI (BˉCˉ\bar B\bar C)
  • m14m14 covered only by PI3PI_3EPI (CDˉC\bar D)
  • m5m5 covered only by PI4=AˉBDPI_4=\bar A B DEPI

Chosen EPIs so far: BˉCˉ,  CDˉ,  AˉBD\bar B\bar C,\;C\bar D,\;\bar A B D. Check coverage: they cover {0,1,8,9}{2,6,10,14}{5,7}\{0,1,8,9\}\cup\{2,6,10,14\}\cup\{5,7\} = all minterms. Done.


3. Worked example 2 (smaller, 3 vars)

Minimize f(A,B,C)=m(0,1,2,5,6,7)f(A,B,C)=\sum m(0,1,2,5,6,7).

Group by 1s: {0=000} | {1=001, 2=010} | {5=101, 6=110} | {7=111}

Combine (size-2):

  • 0,1→00- ; 0,2→0-0 ; 1,5→-01 ; 2,6→-10 ; 5,7→1-1 ; 6,7→11-

Why this step? Every pair here has Hamming distance 1, so one variable cancels — direct use of X+Xˉ=1X+\bar X=1.

Combine (size-4): none share a dash position + differ by one bit → all size-2 terms are prime.

Decode the PIs (order ABCABC):

  • 00-=AˉBˉ(0,1)=\bar A\bar B\,(0,1)
  • 0-0=AˉCˉ(0,2)=\bar A\bar C\,(0,2)
  • -01=BˉC(1,5)=\bar B C\,(1,5)
  • -10=BCˉ(2,6)=B\bar C\,(2,6)
  • 1-1=AC(5,7)=A C\,(5,7)
  • 11-=AB(6,7)=AB\,(6,7)

PI chart / EPI hunt:

  • m0m0 ∈ {00-,0-0} → not unique yet.
  • m7m7 ∈ {1-1,11-}; m5m5 ∈ {-01,1-1}; m6m6 ∈ {-10,11-}.

Pick a minimal cover — we need all of {0,1,2,5,6,7}\{0,1,2,5,6,7\}. Take: f=AˉBˉ+AC+BCˉ(covers 0,1;  5,7;  2,6).f = \bar A\bar B + AC + B\bar C \quad\text{(covers }0,1;\;5,7;\;2,6). Why: AˉBˉ\bar A\bar B→{0,1}, ACAC→{5,7}, BCˉB\bar C→{2,6}; union ={0,1,2,5,6,7}=\{0,1,2,5,6,7\} = all six. ✔ (Only 3 terms, 6 literals — minimal.)


4. Common mistakes


5. Active recall

Recall Feynman: explain to a 12-year-old

Imagine sorting cards with 0s and 1s on them. You line them up by how many 1s each card has. Then you look for two cards that are almost twins — same except one spot. You glue them into a card with a blank - in that spot, meaning "this spot doesn't matter." You keep gluing bigger and bigger stacks. When nothing else glues, the leftover stacks are your "biggest patterns." Finally you check which patterns you absolutely can't skip (because only they cover a certain card) — those go into your shortest recipe for the machine.

Flashcards

What single Boolean law powers all of Quine–McCluskey?
The combining theorem AB+ABˉ=AAB+A\bar B=A (i.e. X+Xˉ=1X+\bar X=1).
Why group minterms by number of 1s?
A Hamming-distance-1 neighbour must have exactly one more/fewer 1, so it lives in an adjacent group — this limits comparisons and guarantees only valid combinations.
What does a - in a QM term mean?
That variable was cancelled (X+XˉX+\bar X) and is irrelevant to the term.
Define a prime implicant.
An implicant that cannot be combined with another to remove a literal; i.e. it was never ticked during combining.
Define an essential prime implicant.
A PI that is the only one covering some particular minterm — it must appear in the final expression.
Two terms can combine into a larger group only if...
they have dashes in the SAME positions AND differ in exactly one bit.
How are don't-cares used in QM?
Used while combining (to form larger PIs) but NOT covered/columned in the prime implicant chart.
What is the purpose of the PI chart?
To pick a minimal subset of prime implicants covering every minterm (find EPIs, then cover the rest).
Can two minterms differing in 2 bits combine?
No — only Hamming distance 1 allows one variable to cancel.
Decode the pattern 01-1 in ABCD order.
A=0,B=1,CA=0,B=1,C dropped, D=1AˉBDD=1 \Rightarrow \bar A B D.

Connections

  • Karnaugh Maps — visual sibling; QM is the tabular generalization for many variables.
  • Sum of Products (SOP) — QM outputs a minimal SOP.
  • Boolean Algebra Laws — the combining/complement laws X+Xˉ=1X+\bar X=1.
  • Prime Implicants and Petrick's Method — Petrick handles non-essential PI selection algebraically.
  • Logic Gate Minimization — fewer literals ⇒ fewer gates ⇒ cheaper hardware.

Concept Map

fail beyond 4-5 vars

is tabular version of

is the engine of

needs

guaranteed by

listed as

combine adjacent

cannot combine further

sole cover of a minterm

must appear in

selected for

Karnaugh maps

Quine-McCluskey method

Combining theorem AB + A-notB = A

Hamming distance 1

Group minterms by 1-count

Minterms

Implicants

Prime implicants

Essential prime implicants

Minimal SOP

Hinglish (regional understanding)

Intuition Hinglish mein samjho

Dekho, Quine–McCluskey basically K-map ka table wala bada bhai hai. K-map 5 variable ke upar visually manage nahi hota, isliye QM ek mechanical, step-by-step method deta hai jise computer bhi kar sakta hai. Poore method ka dil sirf ek law hai: AB+ABˉ=AAB + A\bar B = A. Matlab agar do minterms sirf ek bit me difference rakhte hain, to woh ek variable cancel ho jata hai (kyunki X+Xˉ=1X+\bar X=1), aur us jagah hum ek dash - laga dete hain.

Process simple hai: pehle minterms ko unke number of 1s ke hisaab se groups me daalo. Fir adjacent groups ke terms compare karo — jinme sirf ek bit alag hai unko combine karke tick maar do. Yeh combine karte raho, size 2 → size 4 → size 8, jab tak aur kuch combine na ho. Jo terms kabhi tick nahi hue, woh prime implicants hain — yani jo aur simplify nahi ho sakte. Ek important cheez: pattern decode karte waqt position order fix hota hai (ABCD), aur dash wala variable gayab ho jata hai — jaise 01-1 ka matlab AˉBD\bar A B D hai, na ki AˉCD\bar A C D.

Ab prime implicant chart banao: rows me PIs, columns me original minterms. Jis minterm ko sirf ek hi PI cover kar raha hai, woh PI essential hai — usko answer me lena hi padega. Essential PIs le lo, phir dekho koi minterm bacha to nahi; agar bacha to remaining ko cover karne ke liye minimum PIs aur choose karo.

Do galtiyan sabse common hain: (1) 2 bit difference wale terms ko galti se combine kar dena — bilkul mat karo, sirf exactly ek bit difference. (2) saare PIs ko answer me daal dena — nahi, sirf essential wale guaranteed hain, baaki chart se minimal choose karo. Don't-care terms ko combine karte waqt use karo, par chart me unke liye column mat banao. Bas itna yaad rakho aur QM easy ho jayega!

Go deeper — visual, from zero

Test yourself — Boolean Algebra & Logic Gates

Connections