Skip to content

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 OR B AND C
#ABCf
0FALSEFALSEFALSEFALSE
1FALSEFALSETRUEFALSE
2FALSETRUEFALSEFALSE
3FALSETRUETRUETRUE
4TRUEFALSEFALSETRUE
5TRUEFALSETRUETRUE
6TRUETRUEFALSETRUE
7TRUETRUETRUETRUE
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
A OR B AND C A OR B AND C A B C f OR AND
A OR B AND C A OR B AND C A B C f OR AND

NOT A AND B, as parsed: (NOT A) AND B: NOT A AND B

Fully grouped reading: NOT A AND B

NOT A AND B
#ABf
0FALSEFALSEFALSE
1FALSETRUETRUE
2TRUEFALSEFALSE
3TRUETRUEFALSE
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
NOT A AND B NOT A AND B A B f AND NOT
NOT A AND B NOT A AND B A B f AND NOT

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 XOR B OR C
#ABCf
0FALSEFALSEFALSEFALSE
1FALSEFALSETRUETRUE
2FALSETRUEFALSETRUE
3FALSETRUETRUETRUE
4TRUEFALSEFALSETRUE
5TRUEFALSETRUETRUE
6TRUETRUEFALSEFALSE
7TRUETRUETRUETRUE
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
A XOR B OR C A XOR B OR C A B C f OR XOR
A XOR B OR C A XOR B OR C A B C f OR XOR

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

Laws

Tools

See also

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.