Skip to content

Commutative law: A AND B = B AND A, A OR B = B OR A

The commutative law says that the order of the operands does not matter: A AND B = B AND A, A OR B = B OR A, and the same for XOR.

Swapping the inputs of an AND, an OR or an XOR gate changes nothing, which is why these gates are drawn without distinguishing their inputs and why the engine treats the operand order of a chain as a presentation detail. The law is not in the engine's named catalogue because the simplifier applies it implicitly whenever it matches a rule; it is stated here because it is the first law in every textbook list and the one students search for.

Not every operator commutes. Implication does not: A -> B and B -> A are different claims (one is the converse of the other), and NAND and NOR commute as two-input gates but do not associate, which is why the engine keeps them in function form. The biconditional commutes, like XNOR.

The proofs below cover AND and OR on the four rows over A and B.

Statement

A AND B = B AND AA OR B = B OR A

Proof by truth table: A AND B = B AND A

A AND B = B AND A
#ABlhsrhs
0FALSEFALSEFALSEFALSE
1FALSETRUEFALSEFALSE
2TRUEFALSEFALSEFALSE
3TRUETRUETRUETRUE
lhs ≡ rhs holds · lhs and rhs agree on every assignment. · Exhaustively checked and solver cross-checked · 4 rows

The same law in four notations

WordsA AND B
ProgrammingA && B
MathematicalA ∧ B
AlgebraA·B
LaTeXA \cdot B
WordsB AND A
ProgrammingB && A
MathematicalB ∧ A
AlgebraB·A
LaTeXB \cdot A
A AND B = B AND A A AND B = B AND A A B lhsPRIMARY rhs AND AND
A AND B = B AND A A AND B = B AND A A B lhsPRIMARY rhs AND AND

Proof by truth table: A OR B = B OR A

A OR B = B OR A
#ABlhsrhs
0FALSEFALSEFALSEFALSE
1FALSETRUETRUETRUE
2TRUEFALSETRUETRUE
3TRUETRUETRUETRUE
lhs ≡ rhs holds · lhs and rhs agree on every assignment. · Exhaustively checked and solver cross-checked · 4 rows

The same law in four notations

WordsA OR B
ProgrammingA || B
MathematicalA ∨ B
AlgebraA + B
LaTeXA + B
WordsB OR A
ProgrammingB || A
MathematicalB ∨ A
AlgebraB + A
LaTeXB + A
A OR B = B OR A A OR B = B OR A A B lhsPRIMARY rhs OR OR
A OR B = B OR A A OR B = B OR A A B lhsPRIMARY rhs OR OR

The common slip

Assuming implication commutes. “If it rains, the ground is wet” and “if the ground is wet, it rains” are different claims, and the equivalence checker shows the row where they differ.

Questions

Does the engine reorder my operands when printing?

No. The printed formula keeps the order and the grouping you wrote; the semantics specification says that printing never regroups. The simplifier matches its laws in either order, so (A AND B) OR A is absorbed exactly like A OR (A AND B).

Related

Lesson that teaches this

Tools

See also

Laws

Generated from the Tangibool engine, semantics tangibool-semantics/1, engine 1.0.0, build . Every table, map, simplification and verdict on these pages was computed by the Tangibool engine when the site was built, and every claim was re-checked by the same exact checker the app uses. Limits are stated where they apply. © 2026 Foreranger LTD.