Operator precedence in Boolean logic: NOT, then AND, then XOR, then OR
Without brackets, NOT binds first, then AND, then XOR, then OR; implication and the biconditional come last. The three tables below show how the parser groups A OR B AND C, NOT A AND B and A XOR B OR C, and each page prints a fully bracketed form so you can check.
The order is the one used in Boolean algebra and in most programming languages: NOT, then AND, then XOR, then OR, with -> below OR and <-> below ->. So A OR B AND C is A OR (B AND C), NOT A AND B is (NOT A) AND B, and A XOR B OR C is (A XOR B) OR C. Chains of one operator need no brackets (A AND B AND C is one gate), a chain of implications associates to the right, and a chain of biconditionals is rejected until you bracket it.
The pitfall is not the rule but the reading. “Allow if the user is an admin or an editor and the document is unlocked” can mean admin OR (editor AND unlocked) or (admin OR editor) AND unlocked, and the two differ on the row admin = TRUE, unlocked = FALSE. The parser applies the rule; only the author knows which was meant, which is why every page prints the fully bracketed form next to what you typed, and why brackets around any mixed group are good manners.
Languages differ at the edges. Python puts not below comparison, so not a == b is not (a == b); C and Java rank && above || as here but put bitwise &, ^ and | in between with their own order; SQL ranks NOT, AND, OR the same way. The languages reference lists each one. In this language the spellings &&, ∧, · and the word AND all have the same precedence, as do the spellings of each other operator.
A OR B AND C, as parsed: A OR (B AND C): A OR B AND C
Fully grouped reading: A OR (B AND C)
| # | A | B | C | f |
|---|---|---|---|---|
| 0 | FALSE | FALSE | FALSE | FALSE |
| 1 | FALSE | FALSE | TRUE | FALSE |
| 2 | FALSE | TRUE | FALSE | FALSE |
| 3 | FALSE | TRUE | TRUE | TRUE |
| 4 | TRUE | FALSE | FALSE | TRUE |
| 5 | TRUE | FALSE | TRUE | TRUE |
| 6 | TRUE | TRUE | FALSE | TRUE |
| 7 | TRUE | TRUE | TRUE | TRUE |
Beginnerf is true exactly when at least one of the following holds (both may hold):
1. A is true
2. both B and C are true
In every other case, f is false.
About the operators:
- OR is inclusive: it is true when at least one part is true, including when several are.
- AND is true only when all of its parts are true.
Intermediatef is true exactly when at least one of the following holds (both may hold):
1. A is true
2. both B and C are true
In every other case, f is false.
Advancedf is true exactly when at least one of the following holds (both may hold) [inclusive disjunction ∨]:
1. A is true
2. both B and C are true [conjunction ∧]
In every other case, f is false.
Formal notation: A ∨ B ∧ C
NOT A AND B, as parsed: (NOT A) AND B: NOT A AND B
Fully grouped reading: NOT A AND B
| # | A | B | f |
|---|---|---|---|
| 0 | FALSE | FALSE | FALSE |
| 1 | FALSE | TRUE | TRUE |
| 2 | TRUE | FALSE | FALSE |
| 3 | TRUE | TRUE | FALSE |
Beginnerf is true exactly when A is false and B is true.
In every other case, f is false.
About the operators:
- AND is true only when all of its parts are true.
- NOT reverses a value: true becomes false and false becomes true.
Intermediatef is true exactly when A is false and B is true.
In every other case, f is false.
Advancedf is true exactly when A is false and B is true [conjunction ∧].
In every other case, f is false.
Formal notation: ¬A ∧ B
A XOR B OR C, as parsed: (A XOR B) OR C: A XOR B OR C
Fully grouped reading: (A XOR B) OR C
| # | A | B | C | f |
|---|---|---|---|---|
| 0 | FALSE | FALSE | FALSE | FALSE |
| 1 | FALSE | FALSE | TRUE | TRUE |
| 2 | FALSE | TRUE | FALSE | TRUE |
| 3 | FALSE | TRUE | TRUE | TRUE |
| 4 | TRUE | FALSE | FALSE | TRUE |
| 5 | TRUE | FALSE | TRUE | TRUE |
| 6 | TRUE | TRUE | FALSE | FALSE |
| 7 | TRUE | TRUE | TRUE | TRUE |
Beginnerf is true exactly when at least one of the following holds (both may hold):
1. exactly one of A and B is true (not both)
2. C is true
In every other case, f is false.
About the operators:
- OR is inclusive: it is true when at least one part is true, including when several are.
- XOR (exclusive or) is true when exactly one of its two parts is true.
Intermediatef is true exactly when at least one of the following holds (both may hold):
1. exactly one of A and B is true (not both)
2. C is true
In every other case, f is false.
Advancedf is true exactly when at least one of the following holds (both may hold) [inclusive disjunction ∨]:
1. exactly one of A and B is true (not both) [exclusive disjunction ⊕]
2. C is true
In every other case, f is false.
Formal notation: A ⊕ B ∨ C
The common slip
Trusting the default grouping of a mixed expression that was dictated or copied from prose. A OR B AND C is read as A OR (B AND C); if the sentence meant “A or B, and C”, the formula is wrong on the row A = TRUE, C = FALSE, and only brackets fix it.
Questions
Does the engine ever regroup what I wrote?
No. The printed formula keeps your grouping; the fully bracketed form shown on each page adds brackets to make the parse visible, and the equivalence checker will tell you whether two groupings happen to agree.
Where do NAND, NOR and XNOR fit?
Nowhere in the precedence order, because they are written as functions, NAND(A, B), which are atoms like a variable or a bracketed group. That is one reason the language keeps them in function form.
Related
Guides
Worked examples that use it
- Entry rule: (member OR invited) AND NOT banned, checked every way
- Entry rule slip: member OR (invited AND NOT banned) and the case that differs
- Majority of three (2-out-of-3 voting): truth table, K-map and NAND form
- Exactly one of three: why XOR is the wrong tool
- At most one of three: mutual exclusion
- Half adder carry: A AND B
Laws
- Identity law of Boolean algebra: A AND TRUE = A, A OR FALSE = A
- Null law (domination): A AND FALSE = FALSE, A OR TRUE = TRUE
- Idempotent law: A AND A = A, A OR A = A
- Complement law: A AND NOT A = FALSE, A OR NOT A = TRUE
- Absorption law: A OR (A AND B) = A, with proof
- De Morgan's laws: NOT (A AND B) = NOT A OR NOT B, with proof and examples
Tools
- Truth table generator: any Boolean expression, up to 12 variables, with intermediate columns
- Logic circuit generator: Boolean expression to gate diagram (SVG)
See also
- Associative law: (A AND B) AND C = A AND (B AND C)
- “A or B and C”: the grouping ambiguity and how to resolve it
- Precedence differs across languages: not a == b in Python
- Lesson 3: Grouping and precedence (beginner, 12 min)
- Logic symbols: meanings, LaTeX, Unicode and how to type them
- Boolean logic in Python: and, or, not, precedence and common mistakes
- Boolean logic in C: logical vs bitwise operators
- Implication (→, if–then): truth table and why a false antecedent makes it true
- Biconditional (↔, if and only if): truth table and examples
Operators and gates
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.