3.1.4 · D4Boolean Algebra & Logic Gates

Exercises — Boolean variables and operations (AND, OR, NOT)

2,495 words11 min readBack to topic
Figure — Boolean variables and operations (AND, OR, NOT)

The number line above is your safety rail: every Boolean answer must land on a dot at 0 or 1. If a calculation ever produces 2, you used ordinary addition instead of OR.


Level 1 — Recognition

Exercise 1.1

Evaluate for (a) and (b) .

Recall Solution 1.1

WHAT: apply NOT = "flip". WHY: NOT is the one-input operation that outputs the opposite.

  • (a) .
  • (b) . Both answers sit on a dot at 0 or 1 — good.

Exercise 1.2

Fill in: , , , .

Recall Solution 1.2
  • — AND needs all inputs 1; one zero kills it.
  • — OR needs at least one 1.
  • — OR saturates; it does not become 2.
  • — no 1s at all, so AND is 0.

Exercise 1.3

How many rows does a truth table have for a function of 3 inputs? Of 4 inputs?

Recall Solution 1.3

WHY the formula : each input independently doubles the count of combinations.

  • 3 inputs: rows.
  • 4 inputs: rows.

Level 2 — Application

Exercise 2.1

Evaluate for .

Recall Solution 2.1

Step 1 (WHAT): NOT first — . WHY: NOT binds tightest. Step 2: OR — . WHY: neither operand is 1, so OR is 0. Answer: 0.

Exercise 2.2

Evaluate for .

Recall Solution 2.2

Step 1: NOT — . Step 2: AND — (both operands 1). WHY before OR: AND has higher precedence. Step 3: OR — . Answer: 1.

Exercise 2.3

Evaluate for . (Note: the bar covers the whole product.)

Recall Solution 2.3

WHY inside-out: the bar is a grouping symbol, so we finish everything under it first. Step 1: . Step 2: NOT the result — . Answer: 1. (This is exactly what a NAND gate does — see NAND and NOR gates.)


Level 3 — Analysis

Exercise 3.1

Build the full truth table for . Then describe in words what means.

Recall Solution 3.1

WHY 4 rows: 2 inputs combinations.

0 0 1 1
0 1 0 0
1 0 1 1
1 1 0 1

In words: is 0 only in the single row . So means "A is true, OR B is false" — equivalently "it is NOT the case that (A is 0 and B is 1)".

Exercise 3.2

Build the truth table for (3 inputs).

Recall Solution 3.2

WHY 8 rows: 3 inputs .

0 0 0 0 0 0
0 0 1 0 0 0
0 1 0 0 0 0
0 1 1 0 0 0
1 0 0 0 0 0
1 0 1 0 1 1
1 1 0 1 0 1
1 1 1 1 1 1

Notice: exactly when and at least one of is 1. That is — a preview of the distributive law in Boolean Algebra Laws.

Exercise 3.3

Two students claim these functions are the same: Are they equal? Prove it with a truth table.

Recall Solution 3.3

WHAT: tabulate both and compare column by column.

0 0 0 1 1 1 1
0 1 1 0 1 0 1
1 0 1 0 0 1 1
1 1 1 0 0 0 0

Verdict: NOT equal — rows 2 and 3 differ ( but ). The correct partner of is (De Morgan). Check: row 2 gives ✓. See De Morgan's Laws.


Level 4 — Synthesis

Exercise 4.1

A door unlocks when a valid key-card is present () and the correct PIN is entered (), or when the master override switch is on () regardless of anything else. Write a Boolean expression for Unlock, then give its truth table.

Recall Solution 4.1

WHAT the words map to: "key AND pin" ; "OR override" . WHY this shape: the two conditions are alternatives (OR), and inside the first, both parts are required (AND).

Unlock
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

Sanity check: every row with unlocks (override works). Among rows, only unlocks. Matches the story.

Exercise 4.2

Design a "exactly one of is 1" function (this is XOR) using only NOT, AND, OR. Give the expression and verify with a table.

Recall Solution 4.2

WHY this construction: "exactly one" splits into two mutually exclusive stories: (i) and ; (ii) and . Either story is acceptable, so join them with OR:

XOR
0 0 0 0 0
0 1 0 1 1
1 0 1 0 1
1 1 0 0 0

Answer confirmed: 1 exactly when the inputs differ. This is proof the three basic operations are functionally complete — even XOR is just shorthand for them.


Level 5 — Mastery

Exercise 5.1

Prove the absorption law using a truth table, and explain why it is true in one sentence.

Recall Solution 5.1
0 0 0 0
0 1 0 0
1 0 0 1
1 1 1 1
The last column equals the column exactly proven.
Why in words: if the whole OR is already 1 (the term adds nothing); if then too, so the OR is 0. Either way the result is . (More such identities in Boolean Algebra Laws.)

Exercise 5.2

A committee of three (, each voting 1 = yes) passes a motion by majority (2 or 3 yes votes). Build the truth table, then write a Boolean expression for Pass as an OR of AND-terms.

Recall Solution 5.2

WHAT: list all votes, mark rows with ones.

yes count Pass
0 0 0 0 0
0 0 1 1 0
0 1 0 1 0
0 1 1 2 1
1 0 0 1 0
1 0 1 2 1
1 1 0 2 1
1 1 1 3 1

WHY the expression: write one AND-term for each "at least this pair agrees": Each term is 1 when a specific pair both vote yes; the OR fires if any pair agrees — which is exactly "2 or 3 yes votes". Verify: row gives ✓; the all-yes row gives ✓ (OR saturates).

Exercise 5.3

Show that the single operation NAND, defined as , can build NOT all by itself. (This is why NAND is called universal.)

Recall Solution 5.3

Idea: feed the same signal into both inputs. WHY: with , the product is just (a variable ANDed with itself is unchanged — check: , ). Table:

0 0 1
1 1 0

The output column is exactly — so NAND alone gives NOT, and from NOT + NAND you can rebuild AND and OR too. This is the deep reason chips are mass-produced from NAND gates; more in NAND and NOR gates.


Recall summary

Recall One-line takeaways (click to reveal)

How many rows for inputs? ::: simplifies to? ::: (De Morgan) XOR in terms of AND/OR/NOT? ::: Majority-of-3 expression? ::: How does NAND make NOT? ::: Absorption law? :::

Connections