Commutativity and Associativity
Order and grouping don't matter for AND and OR - rearrange operands freely.
Commutativity lets you rearrange terms freely—A $\land$ B is the same as B $\land$ A. Without this guarantee, you'd have to treat every ordering as a different expression, making simplification vastly more difficult. It also lets you line up matching terms for factoring and cancellation.
Commutativity
Commutativity means the order of operands can be swapped without changing the result:
- A $\lor$ B = B $\lor$ A (OR is commutative)
- A $\land$ B = B $\land$ A (AND is commutative)
Just like addition (3+5 = 5+3), you can rearrange the operands freely.
Associativity
Associativity means the grouping (parentheses) of operands can be changed without affecting the result:
- (A $\lor$ B) $\lor$ C = A $\lor$ (B $\lor$ C) (OR is associative)
- (A $\land$ B) $\land$ C = A $\land$ (B $\land$ C) (AND is associative)
This lets us write A $\lor$ B $\lor$ C or A $\land$ B $\land$ C without parentheses - the grouping doesn't matter!
Rearranging Expressions
Together, commutativity and associativity let us freely rearrange terms in an expression of all ANDs or all ORs:
- A $\lor$ B $\lor$ C = B $\lor$ C $\lor$ A = C $\lor$ A $\lor$ B = ... (any order)
- A $\land$ B $\land$ C = B $\land$ C $\land$ A = C $\land$ A $\land$ B = ... (any order)
This is useful for grouping related terms or matching patterns.
Commutativity Practice
Commutativity means operands can be swapped:
- A $\lor$ B = B $\lor$ A
- A $\land$ B = B $\land$ A
The operation (AND or OR) must stay the same.
Associativity Practice
Associativity means grouping (parentheses) can change:
- (A $\lor$ B) $\lor$ C = A $\lor$ (B $\lor$ C)
- (A $\land$ B) $\land$ C = A $\land$ (B $\land$ C)
All operations must be the same type (all AND or all OR).
Non-Commutative Operations
Not all operations are commutative. In Boolean logic:
Commutative:
- AND: A $\land$ B = B $\land$ A ✓
- OR: A $\lor$ B = B $\lor$ A ✓
- XOR: A $\oplus$ B = B $\oplus$ A ✓
- Equivalence: A $\leftrightarrow$ B = B $\leftrightarrow$ A ✓
NOT commutative:
- Implication: A $\to$ B $\neq$ B $\to$ A (in general)
"If it rains, the ground is wet" $\neq$ "If the ground is wet, it rains"
Mixed Operations Warning
Important: Associativity only works when all operations are the same!
- (A $\lor$ B) $\lor$ C = A $\lor$ (B $\lor$ C) ✓ (all OR)
- (A $\land$ B) $\land$ C = A $\land$ (B $\land$ C) ✓ (all AND)
- (A $\lor$ B) $\land$ C $\neq$ A $\lor$ (B $\land$ C) ✗ (mixed - NOT equal!)
When operations are mixed, changing parentheses changes the meaning!
Identifying Commutativity vs Associativity
Commutativity swaps operands: A $\lor$ B $\to$ B $\lor$ A
Associativity changes grouping: (A $\lor$ B) $\lor$ C $\to$ A $\lor$ (B $\lor$ C)
Key difference:
- Commutativity: two terms, positions swap
- Associativity: three+ terms, parentheses move
Flattening Expressions
Because of associativity, we can write chains of the same operation without parentheses:
- (A $\lor$ B) $\lor$ C = A $\lor$ B $\lor$ C
- A $\lor$ (B $\lor$ C) = A $\lor$ B $\lor$ C
- ((A $\land$ B) $\land$ C) $\land$ D = A $\land$ B $\land$ C $\land$ D
This is called "flattening" - we can evaluate in any order.
When Reordering Helps
When to reorder terms:
- To expose complements: P $\land$ Q $\land$ $\neg$P $\to$ P $\land$ $\neg$P $\land$ Q = F $\land$ Q = F
- To expose idempotence: P $\lor$ Q $\lor$ P $\to$ P $\lor$ P $\lor$ Q = P $\lor$ Q
- To enable absorption: P $\lor$ Q $\lor$ (P $\land$ R) $\to$ P $\lor$ (P $\land$ R) $\lor$ Q = P $\lor$ Q
- To align for factoring: (P $\land$ Q) $\lor$ (P $\land$ R) - P is already aligned!
Reordering doesn't simplify by itself, but it enables other laws.
Non-Commutative Operations
Not all operations are commutative!
| Operation | Commutative? | Example |
|---|---|---|
| AND, OR, XOR | Yes | P $\land$ Q = Q $\land$ P |
| Implication ($\to$) | No | P $\to$ Q $\neq$ Q $\to$ P |
| Subtraction | No | 5 - 3 $\neq$ 3 - 5 |
| Division | No | 6 ÷ 2 $\neq$ 2 ÷ 6 |
Implication is the main non-commutative operation in logic!
Finding Equivalent Reorderings
With commutativity and associativity, many reorderings are equivalent:
For P $\land$ Q $\land$ R, all of these are equivalent:
- P $\land$ Q $\land$ R
- Q $\land$ P $\land$ R
- R $\land$ Q $\land$ P
- (P $\land$ Q) $\land$ R
- P $\land$ (R $\land$ Q)
- etc.
3 terms $\to$ 6 orderings. 4 terms $\to$ 24 orderings!
Ready to test your understanding?
Bitwit uses spaced repetition to help you truly master concepts like this—not just read about them. Each card generates with different values, so you can't just memorize answers.
Practice Commutativity and Associativity →