// reference · NOT AND
⊼ NAND_
NAND is the negation of conjunction: p ⊼ q is equivalent to ¬(p ∧ q). It is false only when p and q are both true and true in every other case. Its importance goes beyond logic: every Boolean function can be built using NAND alone.
Truth table: p ⊼ q
| p | q | p ⊼ q★ |
|---|---|---|
| T | T | F |
| T | F | T |
| F | T | T |
| F | F | T |
Classification: Contingency · 4 rows
Definition
p ⊼ q ("p NAND q") is true except when both propositions are true. Its name contracts NOT AND. The symbol ⊼ is also known as the Sheffer stroke, and some texts write it p | q (but in programming that bar means OR, so the calculator reserves | for disjunction).
How to read it
p ⊼ q is read "p NAND q", "not both p and q", or "it is not the case that p and q". It formalizes statements like "you can't have your cake and eat it too": at least one of the two must fail.
When it is true
The table has four rows. With p = T and q = T, p ⊼ q = F. With p = T and q = F, p ⊼ q = T. With p = F and q = T, p ⊼ q = T. With p = F and q = F, p ⊼ q = T.
Three true rows and one false row: it is a contingency and its table is exactly that of p ∧ q with every value flipped.
Everyday example
A security alarm that always fires except when the door is closed AND the system is disarmed. With any other combination (door open, system armed, or both) the alarm sounds.
In hardware, the NAND gate is the cheapest to build with CMOS transistors, which is why integrated circuits are often implemented entirely with NAND gates.
Properties and equivalences
Definition: p ⊼ q ≡ ¬(p ∧ q). By De Morgan: p ⊼ q ≡ ¬p ∨ ¬q. As a conditional: p ⊼ q ≡ p ⇒ ¬q.
It is commutative (p ⊼ q ≡ q ⊼ p) but NOT associative: (p ⊼ q) ⊼ r is not equivalent to p ⊼ (q ⊼ r). Nor is it idempotent: p ⊼ p ≡ ¬p.
Functional completeness: NOT, AND and OR can all be built from NAND alone. ¬p ≡ p ⊼ p; p ∧ q ≡ (p ⊼ q) ⊼ (p ⊼ q); p ∨ q ≡ (p ⊼ p) ⊼ (q ⊼ q). Since any formula can be written with NOT, AND and OR, any formula can be written with NAND only.
Common mistakes
Misapplying De Morgan and thinking p ⊼ q ≡ ¬p ∧ ¬q. That is NOR, not NAND. The negation of a conjunction is a disjunction of negations.
Grouping NAND as if it were associative. With three or more operands the parentheses change the result; the calculator honours the parentheses you write and, without them, evaluates left to right.
Equivalent expressions
Try it yourself
Edit the expression in the calculator and watch how every step of the table changes.
Open in the calculator →Related laws and rules
Frequently asked questions
What does NAND mean? ▼
It contracts NOT AND: the negation of conjunction. p ⊼ q is false only when p and q are both true.
Why is NAND called a universal operator? ▼
Because NAND alone can build NOT (p ⊼ p), AND ((p ⊼ q) ⊼ (p ⊼ q)) and OR ((p ⊼ p) ⊼ (q ⊼ q)), and those three express every Boolean function.
Is NAND associative? ▼
No. (p ⊼ q) ⊼ r and p ⊼ (q ⊼ r) have different tables. Always use parentheses when chaining several NANDs.
