digiwleeaLearn
Open the lab →

Logic gates and Boolean algebra cheat sheet

Truth tables for every basic gate, what each outputs, which are universal, how each is built, and the Boolean algebra identities for simplifying expressions.

The six basic logic gates are NOT, AND, NAND, OR, NOR, and XOR. Each takes one or two bits in and produces one bit out, fully described by its truth table. NAND and NOR are universal: every other gate can be built from either one alone. Below the gates you will find the Boolean algebra identities (including De Morgan's laws) used to simplify logic.

At a glance

GateOutput is 1 whenExpressionUniversal?
NOTthe input is 0F = NOT ANo
ANDboth inputs are 1F = A AND BNo
NANDnot both inputs are 1F = NOT (A AND B)Yes
ORat least one input is 1F = A OR BNo
NORboth inputs are 0F = NOT (A OR B)Yes
XORthe inputs differF = A XOR BNo

Each gate in detail

NOT

F = NOT A
AF
01
10

One PMOS over one NMOS sharing the input: the smallest CMOS gate, two transistors.

Full NOT lesson →

AND

F = A AND B
ABF
000
010
100
111

A NAND followed by a NOT: the double inversion cancels, leaving AND.

Full AND lesson →

NAND

F = NOT (A AND B)
ABF
001
011
101
110

Two NMOS in series (pull-down), two PMOS in parallel (pull-up): four transistors, universal.

Full NAND lesson →

OR

F = A OR B
ABF
000
011
101
111

A NOR followed by a NOT, mirroring how AND is built from NAND.

Full OR lesson →

NOR

F = NOT (A OR B)
ABF
001
010
100
110

NAND's mirror: two PMOS in series (pull-up), two NMOS in parallel (pull-down). Also universal.

Full NOR lesson →

XOR

F = A XOR B
ABF
000
011
101
110

No single CMOS gate does it: built from four NAND gates. The sum bit of binary addition.

Full XOR lesson →
One more worth knowing: XNOR (exclusive-NOR) is XOR inverted. Its output is 1 exactly when the two inputs are the same (both 0 or both 1), which makes it a one-bit equality check. Build it as an XOR followed by a NOT.

Boolean algebra identities

The laws for simplifying logic expressions. Notation: · is AND, + is OR, and A' is NOT A. Involution (double negation): (A')' = A.

LawAND formOR form
IdentityA · 1 = AA + 0 = A
NullA · 0 = 0A + 1 = 1
IdempotentA · A = AA + A = A
ComplementA · A' = 0A + A' = 1
AbsorptionA · (A + B) = AA + A · B = A
CommutativeA · B = B · AA + B = B + A
Associative(A · B) · C = A · (B · C)(A + B) + C = A + (B + C)
DistributiveA · (B + C) = A·B + A·CA + B·C = (A + B)·(A + C)
De Morgan's(A · B)' = A' + B'(A + B)' = A' · B'
De Morgan's laws are why NAND and NOR are universal: they let you turn any AND into an OR (and back) by pushing a NOT through, so one repeated gate can express every function. Practice simplifying with the Boolean algebra lesson or the Boolean simplifier tool, and minimize visually with a Karnaugh map.