3.1.5 · D3Boolean Algebra & Logic Gates

Worked examples — Truth tables construction

2,580 words12 min readBack to topic

Before anything, we only ever use two symbols for a signal:


The scenario matrix

Every truth-table problem you can be asked is one (or a blend) of these cells. Each worked example below is tagged with the cell(s) it covers.

# Case class What makes it tricky Covered by
C1 2 inputs, single gate the baseline, all-0s & all-1s corners Ex 1
C2 NOT inside an OR/AND evaluate the inside first (intermediate column) Ex 2
C3 3 inputs, mixed AND+OR precedence NOT→AND→OR, 8 rows Ex 3
C4 Degenerate input (a variable that cancels out) column that turns out irrelevant Ex 4
C5 Constant / limiting output (always 0 or always 1) tautology & contradiction Ex 5
C6 Equivalence proof (two different-looking expressions, same table) compare column-by-column Ex 6
C7 Real-world word problem translate English → Boolean → table Ex 7
C8 Exam twist: precedence trap vs the classic wrong reading Ex 8

Ex 1 — C1: baseline, 2 inputs, single OR gate

Steps:

  1. Count inputs → rows. Two inputs, so rows. Why this step? Fix the size before filling, so you can't skip or duplicate a row.
  2. Lay the input columns by binary count : right column ; left column . Why this step? Binary counting is a checksum that all combos appear exactly once.
  3. Apply OR to each row. unless both are . Why this step? OR only fails (gives 0) at the single all-0 corner.
0 0 0
0 1 1
1 0 1
1 1 1

Verify: Exactly one row is (the all-0s corner), three are . That matches "at least one 1". Row count . ✓


Ex 2 — C2: NOT living inside a bigger expression

Steps:

  1. Rows: . Binary columns as before.
  2. Make an intermediate column . Flip every value. Why this step? We solve the small inside piece first, so the outer AND becomes trivial ([divide-and-conquer](Boolean Algebra Laws)).
  3. AND with . Both must be . Why this step? AND lights up only where both intermediate values are .
0 0 1 0
0 1 1 1
1 0 0 0
1 1 0 0

Verify: Exactly one row is — the row , matching "A false and B true". ✓


Ex 3 — C3: three inputs, mixed AND + OR (precedence)

Steps:

  1. Rows: . Right column toggles every row; every 2; every 4. Why this step? Guarantees all 8 combinations, no gaps.
  2. Intermediate column . only in the two rows where . Why this step? AND binds tighter than OR, so it must be computed first — build it as its own column so you never mis-order.
  3. OR that with . if either or .
0 0 0 0 0
0 0 1 0 1
0 1 0 0 0
0 1 1 0 1
1 0 0 0 0
1 0 1 0 1
1 1 0 1 1
1 1 1 1 1

Verify: Rows with (four of them) are all . The extra row is also . Total = 5 ones. ✓ Read the -rows off directly and you have the SOP form.


Ex 4 — C4: a degenerate input (does the variable matter?)

Steps:

  1. Rows: .
  2. Intermediates: , then , then . Why this step? Three small pieces beat one error-prone mental leap.
  3. OR the two product terms.
0 0 1 0 0 0
0 1 0 0 0 0
1 0 1 0 1 1
1 1 0 1 0 1

Verify: The column equals the column exactly — never changes the answer. So . This is the law (see Boolean Algebra Laws). is a degenerate input here. ✓


Ex 5 — C5: limiting outputs — always 1, and always 0

Steps:

  1. Rows: each has input → rows. (The smallest non-trivial table.)
  2. Intermediate , then combine. Why this step? These two are the boundary cases every table lives between.
0 1 1 0
1 0 1 0

Verify:

  • is in every row → a tautology (always true). Output column has zero 0s.
  • is in every row → a contradiction (always false). Output column has zero 1s. These are the two limiting shapes of any output column. ✓

Ex 6 — C6: equivalence proof (De Morgan)

Steps:

  1. One shared input block, rows, so we compare fairly.
  2. Build : intermediate , then bar it.
  3. Build : intermediates , then OR. Why this step? Two expressions are logically equal iff their output columns are identical row-by-row.
0 0 0 1 1 1 1
0 1 0 1 1 0 1
1 0 0 1 0 1 1
1 1 1 0 0 0 0

Verify: and columns are identical (). Therefore — this is De Morgan's Law, proved by table. ✓ (Boolean Algebra Laws)


Ex 7 — C7: real-world word problem

Steps:

  1. Translate English → Boolean. "Engine on" . "Unbuckled" . "And" . So . Why this step? Word problems are just Boolean expressions in disguise — nail the translation first.
  2. Rows: two inputs .
  3. Intermediate , then AND with .
Meaning
0 0 1 0 engine off → silent
0 1 0 0 engine off → silent
1 0 1 1 on & unbuckled → BUZZ
1 1 0 0 on & buckled → silent

Verify: The buzzer fires in exactly one row — engine on (), unbuckled () — which is precisely the real safety rule. Units check: output is a bit (buzz/silent), inputs are bits. ✓


Ex 8 — C8: exam twist — the precedence trap

Steps:

  1. Rows: three inputs → .
  2. Correct column : intermediate , then OR with .
  3. Wrong column : intermediate , then AND with . Why this step? Putting both side by side exposes exactly which rows the trap corrupts.
0 0 0 0 0 0 0
0 0 1 0 0 0 0
0 1 0 0 0 1 0
0 1 1 1 1 1 1
1 0 0 0 1 1 0
1 0 1 0 1 1 1
1 1 0 0 1 1 0
1 1 1 1 1 1 1

Verify: Compare columns and . They differ in rows : rows and 2 rows disagree. has 5 ones, has 3 ones. The correct answer is . ✓


Coverage check — did we hit every cell?

Scenario matrix

C1 single gate

C2 NOT inside

C3 three inputs mixed

C4 degenerate input

C5 limiting output

C6 equivalence

C7 word problem

C8 precedence trap

Ex 1

Ex 2

Ex 3

Ex 4

Ex 5

Ex 6

Ex 7

Ex 8

Every cell in the matrix has a fully worked, verified example. ✓


Active recall

Recall Test yourself
  • In Ex 4, why did vanish from the answer? ::: Because , so ; the variable cancels.
  • What is the output column of a tautology like ? ::: All s (zero zeros).
  • How do you prove two expressions are equivalent? ::: Build both tables; they must match row-by-row.
  • Correct reading of ? ::: — AND binds tighter than OR.
  • In how many rows do and disagree? ::: 2 rows (both with ).

Connections

Why can an input variable "vanish" from a truth table's output?
Because of , so ; the variable's value never changes the output.
What output column marks a contradiction?
All zeros — the expression is never true (e.g. ).
How do you prove De Morgan's law ?
Build both truth tables; both give the column , so they are equivalent.