Logic Gates Guide

What's the key thing to understand about The Basic Logic Gates?

AND: output is 1 only if BOTH inputs are 1. OR: output is 1 if AT LEAST ONE input is 1. NOT: inverts the input (0→1, 1→0). NAND (NOT AND): output is 0 only if BOTH inputs are 1 — inverse of AND. NOR (NOT OR): output is 1 only if BOTH inputs are 0 — inverse of OR. XOR (exclusive OR): output is 1 if inputs are DIFFERENT (one 0 and one 1). XNOR: output is 1 if inputs are SAME (both 0 or both 1) — inverse of XOR. NAND and NOR are 'universal gates' — any logic circuit can be built from NAND gates alone, or NOR gates alone, without needing any other gate type at all.

What should I know about Boolean Algebra?

Logic gates are described by boolean algebra (George Boole, 1854). Key identities: A AND 1 = A. A AND 0 = 0. A OR 0 = A. A OR 1 = 1. A AND A = A. A OR A = A. A AND (NOT A) = 0. A OR (NOT A) = 1. De Morgan's laws: NOT (A AND B) = (NOT A) OR (NOT B). NOT (A OR B) = (NOT A) AND (NOT B). These laws are used to simplify complex circuits. Simplification reduces the number of gates needed, reducing cost, power consumption, and signal delay in integrated circuits.

What do I need to know about Logic Gates in Computers?

Every computation in a CPU is performed by combinations of logic gates. Adder circuit: a half adder (1-bit addition) uses XOR (for the sum bit) and AND (for the carry bit). Full adder: two half adders combined. A 64-bit adder requires 64 full adders. Flip-flops: made from NAND or NOR gates in a feedback configuration. Store 1 bit of memory — the building block of RAM and registers. Modern CPUs contain billions of transistors implementing these gates. Each transistor switches between 0 and 1 by having voltage either present or absent, the physical basis underlying every logical operation a computer performs.

What do I need to know about Logic Gates in Everyday Electronics?

Alarm systems: an AND gate — alarm triggers only if sensor is triggered AND system is armed. Traffic lights: complex combinational logic controls sequencing. Lifts: OR gates detect any floor button press. Priority circuits: NAND gates create interrupt priority systems in microcontrollers. Parental controls: AND gate — signal passes only if content rating allows AND parental control permits. Security keypads: multi-input AND gates — all digits of the correct code must be entered (each digit checked by its own AND condition) model exactly how a keypad lock validates a PIN.

What's the key thing to understand about De Morgan's Laws?

De Morgan's Laws connect NOT with AND/OR: NOT(A AND B) equals (NOT A) OR (NOT B), and NOT(A OR B) equals (NOT A) AND (NOT B). You can verify both with a truth table — the two sides always match on every row of A and B. These laws matter because they let you rewrite a logical expression into an equivalent one that might be easier to implement or simplify, especially when negating a compound condition in code (if not (a and b): becomes if (not a) or (not b):). They're also the basis for simplifying Boolean circuits, since swapping an AND gate followed by a NOT for an OR of inverted inputs (or vice versa) can reduce the number of gate types a circuit needs. Electronics engineers use De Morgan's Laws constantly when converting a design built from AND/OR/NOT gates into one built only from NAND or NOR gates, which are cheaper to manufacture.

What's the key thing to understand about NAND and NOR as Universal Gates?

NAND (NOT AND) and NOR (NOT OR) are called "universal gates" because either one, on its own, can reproduce every other logic gate — AND, OR, NOT, XOR, and more — through different wirings. A single NAND gate with both inputs tied together acts as a NOT gate; two NAND gates can build an AND gate; three can build an OR gate. This matters in real circuit design because manufacturing a chip from just one gate type simplifies production and testing. It's also why NAND gates are the building block of most computer memory (NAND flash storage takes its name directly from this gate) and why digital logic courses often set an exercise to "build an XOR gate using only NAND gates" — a good way to test whether De Morgan's Laws and gate equivalence are properly understood.

What should I know about Tautologies, Contradictions, and Logical Equivalence?

A truth table does more than evaluate a single logical expression for given inputs — comparing the final output column across every possible input combination reveals important structural properties of the statement itself. A tautology is a compound statement that evaluates to true for every possible combination of input truth values, such as P ∨ ¬P ('P or not P'), which is always true regardless of whether P itself is true or false — its entire output column in the truth table is T. A contradiction is the opposite: a statement that is false for every input combination, such as P ∧ ¬P ('P and not P'), whose output column is entirely F. Most statements are neither, being true for some input combinations and false for others, called contingencies. Truth tables also reveal logical equivalence: two statements are logically equivalent if and only if they produce identical output columns for every combination of inputs, even if the statements look structurally different. This is exactly how De Morgan's laws are proven true rather than simply asserted: building the truth table for ¬(P ∧ Q) alongside the truth table for ¬P ∨ ¬Q shows the two columns match in every row, confirming the statements are logically equivalent for all possible truth values of P and Q.

Worked Example: Building a Truth Table for a Compound Statement

Consider the compound statement (P AND Q) OR (NOT P). With two input variables, there are 2² = 4 possible combinations of truth values to check, and working through each one systematically produces the full truth table. When P is true and Q is true: P AND Q is true, so the whole OR expression is true regardless of NOT P. When P is true and Q is false: P AND Q is false, and NOT P is also false (since P is true), so the whole expression is false. When P is false and Q is true: P AND Q is false, but NOT P is true, so the OR makes the whole expression true. When P is false and Q is false: P AND Q is false, and NOT P is true, so the expression is true again. The completed table below shows the result is true in three of the four rows — true whenever P is false, or whenever both P and Q are true, which turns out to be logically equivalent to the simpler expression Q OR (NOT P).

PQNOT PP AND Q(P AND Q) OR (NOT P)
TTFTT
TFFFF
FTTFT
FFTFT

Worked Example: Building a Truth Table for (A OR B) AND (NOT C)

This compound statement has three variables, so the truth table needs 2^3 = 8 rows. List all combinations of A, B, C from TTT down to FFF, then build intermediate columns. For A=T, B=T, C=T: (A OR B) = T, NOT C = F, so the result is T AND F = F. For A=T, B=F, C=F: (A OR B) = T, NOT C = T, result = T AND T = T. For A=F, B=F, C=F: (A OR B) = F, NOT C = T, result = F AND T = F. Working through all eight rows shows the full statement is true only when at least one of A or B is true AND C is false -- exactly four of the eight rows (TTF, TFF, FTF, FFF would need checking individually, but the pattern is: true whenever C=F and at least one of A,B is T). This systematic row-by-row approach -- fill intermediate columns left to right, then combine -- is how truth tables for arbitrarily complex statements are built without having to hold the whole expression in your head at once.

Truth Tables for Conditional and Biconditional Statements

Beyond AND, OR, and NOT, two connectives that often confuse newcomers are the conditional (IF...THEN, written P→Q) and the biconditional (IF AND ONLY IF, written P↔Q).

PQP → Q (conditional)P ↔ Q (biconditional)
TTTT
TFFF
FTTF
FFTT

The conditional P→Q is only false when P is true but Q is false -- it is considered true whenever the premise P is false, regardless of Q, which is the counterintuitive 'vacuous truth' case that trips up students (a false premise cannot make a conditional statement false, since the statement makes no claim when its condition never holds). The biconditional P↔Q, by contrast, is true exactly when P and Q share the same truth value, which is why it is used to express logical equivalence between two statements.

Logic Gate & Truth Table Calculator

Results update automatically as you type

Enter values above to calculate